Re-work menu spawning for Command and Projected views to be a bit more straightforward and allow spawning up context menu when right clicking the DummyEntry (#1316)

This commit is contained in:
blitzmann
2017-10-29 12:22:15 -04:00
parent 8647fe460c
commit e5a0ef1877
2 changed files with 30 additions and 26 deletions

View File

@@ -168,6 +168,9 @@ class CommandView(d.Display):
self.update(stuff)
def get(self, row):
if row == -1:
return None
numFits = len(self.fits)
if numFits == 0:
@@ -193,23 +196,21 @@ class CommandView(d.Display):
wx.CallAfter(self.spawnMenu)
def spawnMenu(self):
fitID = self.mainFrame.getActiveFit()
if fitID is None:
return
sel = self.GetFirstSelected()
menu = None
if sel != -1:
item = self.get(sel)
if item is None:
return
context = ()
item = self.get(sel)
if item is not None:
fitSrcContext = "commandFit"
fitItemContext = item.name
context = ((fitSrcContext, fitItemContext),)
context += ("commandView",),
menu = ContextMenu.getMenu((item,), *context)
elif sel == -1:
fitID = self.mainFrame.getActiveFit()
if fitID is None:
return
context = (("commandView",),)
menu = ContextMenu.getMenu([], *context)
context += (("commandView",),)
menu = ContextMenu.getMenu((item,) if item is not None else [], *context)
if menu is not None:
self.PopupMenu(menu)

View File

@@ -223,6 +223,9 @@ class ProjectedView(d.Display):
self.update(stuff)
def get(self, row):
if row == -1:
return None
numMods = len(self.modules)
numDrones = len(self.drones)
numFighters = len(self.fighters)
@@ -260,13 +263,17 @@ class ProjectedView(d.Display):
wx.CallAfter(self.spawnMenu)
def spawnMenu(self):
fitID = self.mainFrame.getActiveFit()
if fitID is None:
return
sel = self.GetFirstSelected()
menu = None
if sel != -1:
item = self.get(sel)
if item is None:
return
context = ()
item = self.get(sel)
if item is not None:
sMkt = Market.getInstance()
if isinstance(item, es_Drone):
srcContext = "projectedDrone"
itemContext = sMkt.getCategoryByItem(item.item).name
@@ -290,14 +297,10 @@ class ProjectedView(d.Display):
fitSrcContext = "projectedFit"
fitItemContext = item.name
context = ((fitSrcContext, fitItemContext),)
context += ("projected",),
menu = ContextMenu.getMenu((item,), *context)
elif sel == -1:
fitID = self.mainFrame.getActiveFit()
if fitID is None:
return
context = (("projected",),)
menu = ContextMenu.getMenu([], *context)
context += (("projected",),)
menu = ContextMenu.getMenu((item,) if item is not None else [], *context)
if menu is not None:
self.PopupMenu(menu)