fix booster menu causing crashes (#424)
This commit is contained in:
@@ -43,15 +43,10 @@ class GangView ( ScrolledPanel ):
|
||||
self.helpText = wx.StaticText( self, wx.ID_ANY, help, wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
|
||||
helpSizer.Add( self.helpText, 1, wx.ALL, 5 )
|
||||
|
||||
self.FitDNDPopupMenu = wx.Menu()
|
||||
|
||||
self.options = ["Fleet", "Wing", "Squad"]
|
||||
|
||||
self.fleet = {}
|
||||
for id, option in enumerate(self.options):
|
||||
item = self.FitDNDPopupMenu.Append(-1, option)
|
||||
# We bind it to the mainFrame because it may be called from either this class or from FitItem via shipBrowser
|
||||
self.mainFrame.Bind(wx.EVT_MENU, self.OnPopupItemSelected, item)
|
||||
|
||||
# set content for each commander
|
||||
self.fleet[id] = {}
|
||||
@@ -61,6 +56,8 @@ class GangView ( ScrolledPanel ):
|
||||
self.fleet[id]['chChar'] = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [] )
|
||||
self.fleet[id]['fitSizer'] = wx.BoxSizer( wx.VERTICAL )
|
||||
|
||||
self.FitDNDPopupMenu = self.buildBoostermenu()
|
||||
|
||||
contentFGSizer = wx.FlexGridSizer( 5, 3, 0, 0 )
|
||||
contentFGSizer.AddGrowableCol( 1 )
|
||||
contentFGSizer.SetFlexibleDirection( wx.BOTH )
|
||||
@@ -130,6 +127,15 @@ class GangView ( ScrolledPanel ):
|
||||
self.RefreshBoosterFits()
|
||||
self.RefreshCharacterList()
|
||||
|
||||
def buildBoostermenu(self):
|
||||
menu = wx.Menu()
|
||||
|
||||
for id, option in enumerate(self.options):
|
||||
item = menu.Append(-1, option)
|
||||
# We bind it to the mainFrame because it may be called from either this class or from FitItem via shipBrowser
|
||||
self.mainFrame.Bind(wx.EVT_MENU, self.OnPopupItemSelected, item)
|
||||
return menu
|
||||
|
||||
def OnEnterWindow(self, event):
|
||||
obj = event.GetEventObject()
|
||||
obj.SetCursor(wx.StockCursor(wx.CURSOR_HAND))
|
||||
@@ -371,7 +377,7 @@ class GangView ( ScrolledPanel ):
|
||||
def OnPopupItemSelected(self, event):
|
||||
''' Fired when booster popup item is selected '''
|
||||
# Get menu selection ID via self.options
|
||||
menuItem = self.FitDNDPopupMenu.FindItemById(event.GetId())
|
||||
menuItem = event.EventObject.FindItemById(event.GetId())
|
||||
type = self.options.index(menuItem.GetText())
|
||||
|
||||
if self.draggedFitID:
|
||||
|
||||
@@ -1536,13 +1536,13 @@ class FitItem(SFItem.SFBrowserItem):
|
||||
menu = wx.Menu()
|
||||
toggleItem = menu.Append(wx.ID_ANY, "Booster Fit", kind=wx.ITEM_CHECK)
|
||||
menu.Check(toggleItem.GetId(), self.fitBooster)
|
||||
|
||||
menu.Break()
|
||||
self.Bind(wx.EVT_MENU, self.OnToggleBooster, toggleItem)
|
||||
|
||||
if self.mainFrame.getActiveFit():
|
||||
# If there is an active fit, get menu for setting individual boosters
|
||||
menu.AppendSeparator()
|
||||
boosterMenu = self.mainFrame.additionsPane.gangPage.FitDNDPopupMenu
|
||||
boosterMenu = self.mainFrame.additionsPane.gangPage.buildBoostermenu()
|
||||
menu.AppendSubMenu(boosterMenu, 'Set Booster')
|
||||
|
||||
self.PopupMenu(menu, pos)
|
||||
|
||||
Reference in New Issue
Block a user