Remove a few stale variables.

Add a market class to the controller.
Add a method in the Market controller to grab the market root.
Display the market root in the market browser.
This commit is contained in:
cncfanatics
2010-08-15 17:40:00 +02:00
parent 3e3ae52bb5
commit 8d0c2042ea
6 changed files with 86 additions and 3 deletions

View File

@@ -26,6 +26,13 @@ def getStaticBitmap(name, parent, location):
static.SetBitmap(getBitmap(name,location))
return static
locationMap = {"pack": os.path.join(config.homePath, "icons")}
def getBitmap(name,location):
path = os.path.join(config.path, location, name + ".png")
if location in locationMap:
location = locationMap[location]
path = os.path.join(location, "icon%s.png" % name)
else:
location = os.path.join(config.path, location)
path = os.path.join(location, name + ".png")
return wx.Image(path).ConvertToBitmap()

View File

@@ -18,6 +18,8 @@
#===============================================================================
import wx
import controller
import bitmapLoader
class MarketBrowser(wx.Panel):
def __init__(self, parent):
@@ -29,8 +31,27 @@ class MarketBrowser(wx.Panel):
vbox.Add(self.splitter, 1, wx.EXPAND)
self.SetSizer(vbox)
self.marketView = wx.TreeCtrl(self.splitter)
self.itemView = wx.TreeCtrl(self.splitter)
treeStyle = self.marketView.GetWindowStyleFlag()
treeStyle |= wx.TR_HIDE_ROOT
self.marketView.SetWindowStyleFlag(treeStyle)
self.itemView.SetWindowStyleFlag(treeStyle)
self.splitter.SplitHorizontally(self.marketView, self.itemView)
self.splitter.SetMinimumPaneSize(10)
self.marketRoot = self.marketView.AddRoot("Market")
self.itemRoot = self.itemView.AddRoot("Market")
self.marketImageList = wx.ImageList(24, 24)
self.marketView.SetImageList(self.marketImageList)
cMarket = controller.Market.getInstance()
root = cMarket.getMarketRoot()
for id, name, iconFile in root:
iconId = self.marketImageList.Add(bitmapLoader.getBitmap(iconFile, "pack"))
self.marketView.AppendItem(self.marketRoot, name, iconId)