From f85a5211e00246415130a01102eb85781e9d9d13 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Sun, 22 Aug 2010 23:18:45 +0200 Subject: [PATCH] Do some ground work on implementing metaGroup filtertoggles. Rest tomorrow, too tiiiiired. --- controller/market.py | 17 +++++++++++++++++ gui/marketBrowser.py | 13 ++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/controller/market.py b/controller/market.py index 923d7f359..aa35078b0 100644 --- a/controller/market.py +++ b/controller/market.py @@ -23,6 +23,11 @@ class Market(): instance = None FORCED_SHIPS = ("Freiki", "Mimir", "Utu", "Adrestia", "Ibis", "Impairor", "Velator", "Reaper") FORCED_GROUPS = ("Rookie ship",) + META_MAP = {"normal": (1, 2,), + "faction": (4, 3), + "complex": (6,), + "officer": (5,)} + @classmethod def getInstance(cls): if cls.instance == None: @@ -30,6 +35,9 @@ class Market(): return cls.instance + def __init__(self): + self.activeMetas = set() + def getItems(self, id): """ Get the items contained in the marketGroup with the passed id. @@ -114,3 +122,12 @@ class Market(): root.append((id, mg.name, mg.icon.iconFile if mg.icon else "")) return root + + def activateMetaGroup(self, name): + self.activeMetas.add(name) + + def disableMetaGroup(self, name): + self.activeMetas.remove(name) + + def getVariations(self, item): + pass diff --git a/gui/marketBrowser.py b/gui/marketBrowser.py index 1ce2255ed..409e9dbca 100644 --- a/gui/marketBrowser.py +++ b/gui/marketBrowser.py @@ -93,10 +93,12 @@ class MarketBrowser(wx.Panel): p.SetSizer(box) vbox.Add(p, 0, wx.EXPAND) for name in ("normal", "faction", "complex", "officer"): - btn = wx.Button(p, wx.ID_ANY, name.capitalize(), style=wx.BU_EXACTFIT) + btn = wx.ToggleButton(p, wx.ID_ANY, name.capitalize(), style=wx.BU_EXACTFIT) setattr(self, name, btn) box.Add(btn, 1, wx.ALIGN_CENTER) + btn.Bind(wx.EVT_TOGGLEBUTTON, self.toggleMetagroup) + self.normal.SetValue(True) p.SetMinSize((wx.SIZE_AUTO_WIDTH, btn.GetSize()[1] + 5)) def addMarketViewImage(self, iconFile): @@ -154,3 +156,12 @@ class MarketBrowser(wx.Panel): self.itemView.SortItems(lambda id1, id2: cmp(idNameMap[id1], idNameMap[id2])) self.itemView.SetColumnWidth(0, wx.LIST_AUTOSIZE) + + def toggleMetagroup(self, event): + ctrl = wx.GetMouseState().ControlDown() + if not ctrl: + for name in ("normal", "faction", "complex", "officer"): + getattr(self, name).SetValue(False) + + event.EventObject.SetValue(True) +