Merge branch 'feature/tabbed-fits' into dev
This commit is contained in:
@@ -690,7 +690,10 @@ class Fit(object):
|
||||
|
||||
# For fits that are under local's Command, we do the same thing
|
||||
for value in self.boostedOnto.values():
|
||||
value.boosted_fit.__resetDependantCalcs()
|
||||
# apparently this is a thing that happens when removing a command fit from a fit and then switching to
|
||||
# that command fit. Same as projected clears, figure out why.
|
||||
if value.boosted_fit:
|
||||
value.boosted_fit.__resetDependantCalcs()
|
||||
|
||||
# it should be noted that command bursts don't affect other command bursts
|
||||
|
||||
|
||||
67
gui/builtinContextMenus/tabbedFits.py
Normal file
67
gui/builtinContextMenus/tabbedFits.py
Normal file
@@ -0,0 +1,67 @@
|
||||
# coding: utf-8
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from service.fit import Fit
|
||||
import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.builtinViews.emptyView import BlankPage
|
||||
|
||||
|
||||
class TabbedFits(ContextMenu):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
|
||||
if self.mainFrame.getActiveFit() is None or srcContext not in ("projected", "commandView"):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, selection):
|
||||
return "Currently Open Fits"
|
||||
|
||||
def getSubMenu(self, context, selection, rootMenu, i, pitem):
|
||||
self.fitLookup = {}
|
||||
self.context = context
|
||||
sFit = Fit.getInstance()
|
||||
|
||||
m = wx.Menu()
|
||||
|
||||
# If on Windows we need to bind out events into the root menu, on other
|
||||
# platforms they need to go to our sub menu
|
||||
if "wxMSW" in wx.PlatformInfo:
|
||||
bindmenu = rootMenu
|
||||
else:
|
||||
bindmenu = m
|
||||
|
||||
for page in self.mainFrame.fitMultiSwitch.pages:
|
||||
if isinstance(page, BlankPage):
|
||||
continue
|
||||
fit = sFit.getFit(page.activeFitID, basic=True)
|
||||
id = ContextMenu.nextID()
|
||||
mitem = wx.MenuItem(rootMenu, id, '{}: {}'.format(fit.ship.item.name, fit.name))
|
||||
bindmenu.Bind(wx.EVT_MENU, self.handleSelection, mitem)
|
||||
self.fitLookup[id] = fit
|
||||
m.AppendItem(mitem)
|
||||
|
||||
return m
|
||||
|
||||
def handleSelection(self, event):
|
||||
sFit = Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
fit = self.fitLookup[event.Id]
|
||||
|
||||
if self.context == 'commandView':
|
||||
sFit.addCommandFit(fitID, fit)
|
||||
elif self.context == 'projected':
|
||||
sFit.project(fitID, fit)
|
||||
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
|
||||
TabbedFits.register()
|
||||
@@ -206,4 +206,5 @@ from gui.builtinContextMenus import ( # noqa: E402,F401
|
||||
implantSets,
|
||||
fighterAbilities,
|
||||
commandFits,
|
||||
tabbedFits
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user