From aaadcb9b4541c331b5230dda1f81fe7c00d22407 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Thu, 20 Feb 2014 00:57:12 -0500 Subject: [PATCH] Add "Flag as Booster" item to fitting menu --- gui/gangView.py | 5 ++++- gui/shipBrowser.py | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/gui/gangView.py b/gui/gangView.py index 88080a56f..69846835f 100644 --- a/gui/gangView.py +++ b/gui/gangView.py @@ -43,7 +43,8 @@ class GangView ( ScrolledPanel ): for option in self.options: item = self.FitDNDPopupMenu.Append(-1, option) - self.Bind(wx.EVT_MENU, self.OnPopupItemSelected, item) + # 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) contentFGSizer = wx.FlexGridSizer( 5, 3, 0, 0 ) contentFGSizer.AddGrowableCol( 1 ) @@ -372,6 +373,7 @@ class GangView ( ScrolledPanel ): choice.SetSelection(1) def handleDrag(self, type, fitID): + ''' Handle dragging of fit to fleet interface. This is also fired when right-clicking fit if there's an active one ''' #Those are drags coming from pyfa sources, NOT builtin wx drags self.draggedFitID = None if type == "fit": @@ -388,6 +390,7 @@ class GangView ( ScrolledPanel ): # wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=activeFit)) def OnPopupItemSelected(self, event): + ''' Fired when booster popup item is selected ''' item = self.FitDNDPopupMenu.FindItemById(event.GetId()) text = item.GetText() booster = self.options.index(text) diff --git a/gui/shipBrowser.py b/gui/shipBrowser.py index d51fac100..517576187 100644 --- a/gui/shipBrowser.py +++ b/gui/shipBrowser.py @@ -1341,12 +1341,26 @@ class FitItem(SFItem.SFBrowserItem): 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") if not self.shipBmp: self.shipBmp = bitmapLoader.getBitmap("ship_no_image_big","icons") + self.fitMenu = wx.Menu() + item = self.fitMenu.Append(-1, "Flag As Booster Fit") + self.Bind(wx.EVT_MENU, self.OnPopupItemSelected, item) + + 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.mainFrame.additionsPane.gangPage.draggedFitID = self.fitID + self.shipFittingInfo = shipFittingInfo self.shipName, self.fitName, self.timestamp = shipFittingInfo @@ -1424,15 +1438,22 @@ class FitItem(SFItem.SFBrowserItem): self.Bind(wx.EVT_RIGHT_UP, self.OnContextMenu) + def OnPopupItemSelected(self, event): + ''' Fires when fit menu item is selected ''' + print "Set booster flag in DB" + event.Skip() + def OnContextMenu(self, event): - self.mainFrame.additionsPane.gangPage.handleDrag("fit", self.fitID) + ''' Handles context menu for fit. Dragging is handled by MouseLeftUp() ''' + pos = wx.GetMousePosition() + pos = self.ScreenToClient(pos) + self.PopupMenu(self.fitMenu, pos) event.Skip() def GetType(self): return 3 - def OnTimer(self, event): if self.selTimerID == event.GetId():