Gray out unused toggles
This commit is contained in:
@@ -136,6 +136,12 @@ class Market():
|
||||
def isMetaIdActive(self, meta):
|
||||
return meta in self.activeMetas
|
||||
|
||||
def getMetaName(self, metaId):
|
||||
for name, ids in self.META_MAP.items():
|
||||
for id in ids:
|
||||
if metaId == id:
|
||||
return name
|
||||
|
||||
def getVariations(self, marketGroupId):
|
||||
if len(self.activeMetas) == 0:
|
||||
return tuple()
|
||||
|
||||
@@ -186,7 +186,10 @@ class MarketBrowser(wx.Panel):
|
||||
btn = event.EventObject
|
||||
if not ctrl:
|
||||
for name in ("normal", "faction", "complex", "officer"):
|
||||
getattr(self, name).SetValue(False)
|
||||
btn = getattr(self, name)
|
||||
btn.SetValue(False)
|
||||
btn.Enable(True)
|
||||
|
||||
cMarket.disableMetaGroup(name)
|
||||
|
||||
btn.SetValue(True)
|
||||
@@ -231,6 +234,9 @@ class MarketBrowser(wx.Panel):
|
||||
self.itemView.DeleteAllItems()
|
||||
if clear:
|
||||
self.search.Clear()
|
||||
|
||||
for name in ("normal", "faction", "complex", "officer"):
|
||||
getattr(self, name).Enable(True)
|
||||
self.searching = False
|
||||
|
||||
def filteredSearchAdd(self):
|
||||
@@ -239,8 +245,10 @@ class MarketBrowser(wx.Panel):
|
||||
|
||||
idNameMap = {}
|
||||
idGroupMap = {}
|
||||
usedMetas = set()
|
||||
cMarket = controller.Market.getInstance()
|
||||
for id, name, group, metaGroupID, iconFile in self.searchResults:
|
||||
usedMetas.add(metaGroupID)
|
||||
if cMarket.isMetaIdActive(metaGroupID):
|
||||
iconId = self.addItemViewImage(iconFile)
|
||||
index = self.itemView.InsertImageStringItem(sys.maxint, name, iconId)
|
||||
@@ -248,6 +256,13 @@ class MarketBrowser(wx.Panel):
|
||||
idGroupMap[id] = group
|
||||
self.itemView.SetItemData(index, id)
|
||||
|
||||
#Gray out empty toggles
|
||||
for name in ("normal", "faction", "complex", "officer"):
|
||||
getattr(self, name).Enable(False)
|
||||
|
||||
for meta in usedMetas:
|
||||
getattr(self, cMarket.getMetaName(meta)).Enable(True)
|
||||
|
||||
def sort(id1, id2):
|
||||
grp = cmp(idGroupMap[id1], idGroupMap[id2])
|
||||
if grp != 0:
|
||||
|
||||
Reference in New Issue
Block a user