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:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user