Instead of sending id, send parent item (which contains ID). This allows us to access the item to modify bitmap or any other value for it.
This commit is contained in:
@@ -67,7 +67,7 @@ class ChangeAffectingSkills(ContextMenu):
|
|||||||
rootMenu.Bind(wx.EVT_MENU, self.handleSkillChange, menuItem)
|
rootMenu.Bind(wx.EVT_MENU, self.handleSkillChange, menuItem)
|
||||||
return menuItem
|
return menuItem
|
||||||
|
|
||||||
def getSubMenu(self, context, selection, menu, i, id):
|
def getSubMenu(self, context, selection, menu, i, pitem):
|
||||||
self.context = context
|
self.context = context
|
||||||
self.skillIds = {}
|
self.skillIds = {}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ class DamagePattern(ContextMenu):
|
|||||||
|
|
||||||
def getText(self, itmContext, selection):
|
def getText(self, itmContext, selection):
|
||||||
sDP = service.DamagePattern.getInstance()
|
sDP = service.DamagePattern.getInstance()
|
||||||
|
sFit = service.Fit.getInstance()
|
||||||
|
fitID = self.mainFrame.getActiveFit()
|
||||||
|
self.fit = sFit.getFit(fitID)
|
||||||
|
|
||||||
self.patterns = sDP.getDamagePatternList()
|
self.patterns = sDP.getDamagePatternList()
|
||||||
self.patterns.sort( key=lambda p: (p.name not in ["Uniform",
|
self.patterns.sort( key=lambda p: (p.name not in ["Uniform",
|
||||||
"Selected Ammo"], p.name) )
|
"Selected Ammo"], p.name) )
|
||||||
@@ -73,15 +77,19 @@ class DamagePattern(ContextMenu):
|
|||||||
item.SetBitmap(bitmap)
|
item.SetBitmap(bitmap)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
def getSubMenu(self, context, selection, menu, i, id):
|
def getSubMenu(self, context, selection, menu, i, pitem):
|
||||||
menu.Bind(wx.EVT_MENU, self.handlePatternSwitch) # this bit is required for some reason
|
menu.Bind(wx.EVT_MENU, self.handlePatternSwitch) # this bit is required for some reason
|
||||||
|
|
||||||
if self.m[i] not in self.subMenus:
|
if self.m[i] not in self.subMenus:
|
||||||
# if we're trying to get submenu to something that shouldn't have one,
|
# if we're trying to get submenu to something that shouldn't have one,
|
||||||
# redirect event of the item to handlePatternSwitch and put pattern in
|
# redirect event of the item to handlePatternSwitch and put pattern in
|
||||||
# our patternIds mapping, then return None for no submenu
|
# our patternIds mapping, then return None for no submenu
|
||||||
|
id = pitem.GetId()
|
||||||
self.patternIds[id] = self.singles[i]
|
self.patternIds[id] = self.singles[i]
|
||||||
menu.Bind(wx.EVT_MENU, self.handlePatternSwitch, id=id)
|
menu.Bind(wx.EVT_MENU, self.handlePatternSwitch, pitem)
|
||||||
|
if self.patternIds[id] == self.fit.damagePattern:
|
||||||
|
bitmap = bitmapLoader.getBitmap("state_active_small", "icons")
|
||||||
|
pitem.SetBitmap(bitmap)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
sub = wx.Menu()
|
sub = wx.Menu()
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class ModuleAmmoPicker(ContextMenu):
|
|||||||
m.Append(id, u'─ %s ─' % text)
|
m.Append(id, u'─ %s ─' % text)
|
||||||
m.Enable(id, False)
|
m.Enable(id, False)
|
||||||
|
|
||||||
def getSubMenu(self, context, selection, menu, i, id):
|
def getSubMenu(self, context, selection, menu, i, pitem):
|
||||||
self.context = context
|
self.context = context
|
||||||
menu.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
|
menu.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
|
||||||
m = wx.Menu()
|
m = wx.Menu()
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class TargetResists(ContextMenu):
|
|||||||
m.Append(id, u'─ %s ─' % text)
|
m.Append(id, u'─ %s ─' % text)
|
||||||
m.Enable(id, False)
|
m.Enable(id, False)
|
||||||
|
|
||||||
def getSubMenu(self, context, selection, menu, i, id):
|
def getSubMenu(self, context, selection, menu, i, pitem):
|
||||||
self.context = context
|
self.context = context
|
||||||
menu.Bind(wx.EVT_MENU, self.handleResistSwitch)
|
menu.Bind(wx.EVT_MENU, self.handleResistSwitch)
|
||||||
m = wx.Menu()
|
m = wx.Menu()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class WhProjector(ContextMenu):
|
|||||||
def activate(self, fullContext, selection, i):
|
def activate(self, fullContext, selection, i):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def getSubMenu(self, context, selection, menu, i, id):
|
def getSubMenu(self, context, selection, menu, i, pitem):
|
||||||
self.idmap = {}
|
self.idmap = {}
|
||||||
menu.Bind(wx.EVT_MENU, self.handleSelection)
|
menu.Bind(wx.EVT_MENU, self.handleSelection)
|
||||||
m = wx.Menu()
|
m = wx.Menu()
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class ContextMenu(object):
|
|||||||
item = wx.MenuItem(menu, id, text)
|
item = wx.MenuItem(menu, id, text)
|
||||||
menu.info[id] = (m, fullContext, it)
|
menu.info[id] = (m, fullContext, it)
|
||||||
|
|
||||||
sub = m.getSubMenu(srcContext, selection, menu, it, id)
|
sub = m.getSubMenu(srcContext, selection, menu, it, item)
|
||||||
if sub is not None:
|
if sub is not None:
|
||||||
item.SetSubMenu(sub)
|
item.SetSubMenu(sub)
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ class ContextMenu(object):
|
|||||||
def activate(self, context, selection, i):
|
def activate(self, context, selection, i):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getSubMenu(self, context, selection, menu, i):
|
def getSubMenu(self, context, selection, menu, i, pitem):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getText(self, context, selection):
|
def getText(self, context, selection):
|
||||||
|
|||||||
Reference in New Issue
Block a user