Skip to content

Commit

Permalink
Fix #307 by moving menu code to spawn event
Browse files Browse the repository at this point in the history
  • Loading branch information
blitzmann committed Jun 27, 2015
1 parent 95eb5a6 commit 98815f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
4 changes: 2 additions & 2 deletions gui/characterEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ def __init__(self, parent):
self.viewsNBContainer = wx.Notebook(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0)

self.sview = SkillTreeView(self.viewsNBContainer)
self.iview = ImplantsTreeView(self.viewsNBContainer)
#self.iview = ImplantsTreeView(self.viewsNBContainer)
#=======================================================================
# RC2
self.iview.Show(False)
#self.iview.Show(False)
#=======================================================================
self.aview = APIView(self.viewsNBContainer)

Expand Down
38 changes: 17 additions & 21 deletions gui/shipBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,9 +1427,6 @@ def __init__(self, parent, fitID=None, shipFittingInfo=("Test", "cnc's avatar",

self.deleted = False

# @todo: replace all getActiveFit() in class with this variable and test
self.activeFit = self.mainFrame.getActiveFit()

if shipID:
self.shipBmp = bitmapLoader.getBitmap(str(shipID),"ships")

Expand All @@ -1442,19 +1439,6 @@ def __init__(self, parent, fitID=None, shipFittingInfo=("Test", "cnc's avatar",
# see GH issue #62
if self.fitBooster is None: self.fitBooster = False

# access these by index based on toggle for booster fit

self.fitMenu = wx.Menu()
self.toggleItem = self.fitMenu.Append(-1, "Booster Fit", kind=wx.ITEM_CHECK)
self.fitMenu.Check(self.toggleItem.GetId(), self.fitBooster)
self.Bind(wx.EVT_MENU, self.OnPopupItemSelected, self.toggleItem)

if self.activeFit:
# If there is an active fit, get menu for setting individual boosters
self.fitMenu.AppendSeparator()
boosterMenu = self.mainFrame.additionsPane.gangPage.FitDNDPopupMenu
self.fitMenu.AppendMenu(wx.ID_ANY, 'Set Booster', boosterMenu)

self.boosterBmp = bitmapLoader.getBitmap("fleet_fc_small", "icons")
self.copyBmp = bitmapLoader.getBitmap("fit_add_small", "icons")
self.renameBmp = bitmapLoader.getBitmap("fit_rename_small", "icons")
Expand Down Expand Up @@ -1531,24 +1515,36 @@ def __init__(self, parent, fitID=None, shipFittingInfo=("Test", "cnc's avatar",

self.Bind(wx.EVT_RIGHT_UP, self.OnContextMenu)

def OnPopupItemSelected(self, event):
''' Fires when fit menu item is selected '''
# currently only have one menu option (toggle booster)
def OnToggleBooster(self, event):
sFit = service.Fit.getInstance()
sFit.toggleBoostFit(self.fitID)
self.fitBooster = not self.fitBooster
self.boosterBtn.Show(self.fitBooster)
self.fitMenu.Check(self.toggleItem.GetId(), self.fitBooster)
self.Refresh()
wx.PostEvent(self.mainFrame, BoosterListUpdated())
event.Skip()

def OnContextMenu(self, event):
''' Handles context menu for fit. Dragging is handled by MouseLeftUp() '''
pos = wx.GetMousePosition()
pos = self.ScreenToClient(pos)

# Even though we may not select a booster, automatically set this so that the fleet pane knows which fit we're applying
self.mainFrame.additionsPane.gangPage.draggedFitID = self.fitID
self.PopupMenu(self.fitMenu, pos)

menu = wx.Menu()
toggleItem = menu.Append(self.toggleBoosterID, "Booster Fit", kind=wx.ITEM_CHECK)
menu.Check(toggleItem.GetId(), self.fitBooster)

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
menu.AppendSubMenu(boosterMenu, 'Set Booster')

self.PopupMenu(boosterMenu, pos)

event.Skip()

Expand Down

0 comments on commit 98815f2

Please sign in to comment.