Finish reworking booster command invokation

This commit is contained in:
DarkPhoenix
2019-04-20 00:07:27 +03:00
parent 1177575f77
commit 85b046a640
3 changed files with 13 additions and 4 deletions

View File

@@ -165,7 +165,11 @@ class BoosterView(d.Display):
if col == self.getColIndex(State):
fitID = self.mainFrame.getActiveFit()
booster = self.boosters[self.GetItemData(row)]
self.mainFrame.command.Submit(cmd.GuiToggleBoosterStateCommand(fitID=fitID, position=self.original.index(booster)))
if booster in self.original:
position = self.original.index(booster)
self.mainFrame.command.Submit(cmd.GuiToggleBoosterStateCommand(
fitID=fitID,
position=position))
def spawnMenu(self, event):
sel = self.GetFirstSelected()

View File

@@ -9,6 +9,7 @@ from service.settings import ContextMenuSettings
class BoosterSideEffect(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.settings = ContextMenuSettings.getInstance()
@@ -58,14 +59,17 @@ class BoosterSideEffect(ContextMenu):
def handleMode(self, event):
effect = self.effectIds[event.Id]
if effect is False or effect not in self.booster.sideEffects:
booster = self.booster
if effect is False or effect not in booster.sideEffects:
event.Skip()
return
fitID = self.mainFrame.getActiveFit()
fit = Fit.getInstance().getFit(fitID)
index = fit.boosters.index(self.booster)
self.mainFrame.command.Submit(cmd.GuiToggleBoosterSideEffectStateCommand(fitID, index, effect.effectID))
if booster in fit.boosters:
index = fit.boosters.index(booster)
self.mainFrame.command.Submit(cmd.GuiToggleBoosterSideEffectStateCommand(
fitID=fitID, position=index, effectID=effect.effectID))
BoosterSideEffect.register()

View File

@@ -8,6 +8,7 @@ from service.fit import Fit
class GuiToggleBoosterStateCommand(wx.Command):
def __init__(self, fitID, position):
wx.Command.__init__(self, True, 'Toggle Booster State')
self.internalHistory = InternalCommandHistory()