diff --git a/gui/builtinAdditionPanes/boosterView.py b/gui/builtinAdditionPanes/boosterView.py index da2bf2daa..3758017e6 100644 --- a/gui/builtinAdditionPanes/boosterView.py +++ b/gui/builtinAdditionPanes/boosterView.py @@ -158,7 +158,7 @@ class BoosterView(d.Display): col = self.getColumn(event.Position) if col == self.getColIndex(State): fitID = self.mainFrame.getActiveFit() - self.mainFrame.command.Submit(cmd.GuiToggleBoosterCommand(fitID, row)) + self.mainFrame.command.Submit(cmd.GuiToggleBoosterStateCommand(fitID, row)) def spawnMenu(self, event): sel = self.GetFirstSelected() diff --git a/gui/builtinContextMenus/boosterSideEffects.py b/gui/builtinContextMenus/boosterSideEffects.py index 3878cc323..529a3d2f6 100644 --- a/gui/builtinContextMenus/boosterSideEffects.py +++ b/gui/builtinContextMenus/boosterSideEffects.py @@ -65,7 +65,7 @@ class BoosterSideEffect(ContextMenu): fitID = self.mainFrame.getActiveFit() fit = Fit.getInstance().getFit(fitID) index = fit.boosters.index(self.booster) - self.mainFrame.command.Submit(cmd.GuiToggleBoosterSideEffectCommand(fitID, index, effect.effectID)) + self.mainFrame.command.Submit(cmd.GuiToggleBoosterSideEffectStateCommand(fitID, index, effect.effectID)) BoosterSideEffect.register() diff --git a/gui/fitCommands/__init__.py b/gui/fitCommands/__init__.py index 371a6136f..ea60de870 100644 --- a/gui/fitCommands/__init__.py +++ b/gui/fitCommands/__init__.py @@ -1,4 +1,7 @@ -from .guiAddBooster import GuiAddBoosterCommand +from .booster.add import GuiAddBoosterCommand +from .booster.remove import GuiRemoveBoosterCommand +from .booster.sideEffectToggleState import GuiToggleBoosterSideEffectStateCommand +from .booster.toggleState import GuiToggleBoosterStateCommand from .guiAddCargo import GuiAddCargoCommand from .guiAddCharge import GuiModuleAddChargeCommand from .guiAddCommand import GuiAddCommandCommand @@ -23,7 +26,6 @@ from .guiModuleToCargo import GuiModuleToCargoCommand from .guiMutaConvert import GuiMutaConvertCommand from .guiMutaRevert import GuiMutaRevertCommand from .guiRebaseItems import GuiRebaseItemsCommand -from .guiRemoveBooster import GuiRemoveBoosterCommand from .guiRemoveCargo import GuiRemoveCargoCommand from .guiRemoveCommand import GuiRemoveCommandCommand from .guiRemoveDrone import GuiRemoveDroneCommand @@ -34,8 +36,6 @@ from .guiRemoveProjected import GuiRemoveProjectedCommand from .guiSetMode import GuiSetModeCommand from .guiSetSpoolup import GuiSetSpoolup from .guiSwapCloneModule import GuiModuleSwapOrCloneCommand -from .guiToggleBooster import GuiToggleBoosterCommand -from .guiToggleBoosterSideEffect import GuiToggleBoosterSideEffectCommand from .guiToggleCommand import GuiToggleCommandCommand from .guiToggleDrone import GuiToggleDroneCommand from .guiToggleFighter import GuiToggleFighterCommand diff --git a/gui/fitCommands/booster/__init__.py b/gui/fitCommands/booster/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/gui/fitCommands/guiAddBooster.py b/gui/fitCommands/booster/add.py similarity index 51% rename from gui/fitCommands/guiAddBooster.py rename to gui/fitCommands/booster/add.py index 579b1b521..fdb0bf2b7 100644 --- a/gui/fitCommands/guiAddBooster.py +++ b/gui/fitCommands/booster/add.py @@ -2,30 +2,28 @@ import wx import gui.mainFrame from gui import globalEvents as GE -from gui.fitCommands.helpers import InternalCommandHistory, BoosterInfo +from gui.fitCommands.calcCommands.booster.add import CalcAddBoosterCommand +from gui.fitCommands.helpers import BoosterInfo, InternalCommandHistory from service.fit import Fit -from .calcCommands.booster.add import CalcAddBoosterCommand class GuiAddBoosterCommand(wx.Command): def __init__(self, fitID, itemID): wx.Command.__init__(self, True, 'Add Booster') - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.internalHistory = InternalCommandHistory() self.fitID = fitID self.itemID = itemID def Do(self): if self.internalHistory.submit(CalcAddBoosterCommand(fitID=self.fitID, boosterInfo=BoosterInfo(itemID=self.itemID))): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True return False def Undo(self): - self.internalHistory.undoAll() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) - return True + success = self.internalHistory.undoAll() + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) + return success diff --git a/gui/fitCommands/booster/remove.py b/gui/fitCommands/booster/remove.py new file mode 100644 index 000000000..bde8fabb0 --- /dev/null +++ b/gui/fitCommands/booster/remove.py @@ -0,0 +1,28 @@ +import wx + +import gui.mainFrame +from gui import globalEvents as GE +from gui.fitCommands.calcCommands.booster.remove import CalcRemoveBoosterCommand +from gui.fitCommands.helpers import InternalCommandHistory +from service.fit import Fit + + +class GuiRemoveBoosterCommand(wx.Command): + def __init__(self, fitID, position): + wx.Command.__init__(self, True, 'Remove Booster') + self.internalHistory = InternalCommandHistory() + self.fitID = fitID + self.position = position + + def Do(self): + if self.internalHistory.submit(CalcRemoveBoosterCommand(fitID=self.fitID, position=self.position)): + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) + return True + return False + + def Undo(self): + success = self.internalHistory.undoAll() + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) + return success diff --git a/gui/fitCommands/booster/sideEffectToggleState.py b/gui/fitCommands/booster/sideEffectToggleState.py new file mode 100644 index 000000000..263baebb6 --- /dev/null +++ b/gui/fitCommands/booster/sideEffectToggleState.py @@ -0,0 +1,30 @@ +import wx + +import gui.mainFrame +from gui import globalEvents as GE +from gui.fitCommands.calcCommands.booster.sideEffectToggleState import CalcToggleBoosterSideEffectStateCommand +from gui.fitCommands.helpers import InternalCommandHistory +from service.fit import Fit + + +class GuiToggleBoosterSideEffectStateCommand(wx.Command): + + def __init__(self, fitID, position, effectID): + wx.Command.__init__(self, True, 'Toggle Booster Side Effect State') + self.internalHistory = InternalCommandHistory() + self.fitID = fitID + self.position = position + self.effectID = effectID + + def Do(self): + if self.internalHistory.submit(CalcToggleBoosterSideEffectStateCommand(fitID=self.fitID, position=self.position, effectID=self.effectID)): + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) + return True + return False + + def Undo(self): + success = self.internalHistory.undoAll() + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) + return success diff --git a/gui/fitCommands/booster/toggleState.py b/gui/fitCommands/booster/toggleState.py new file mode 100644 index 000000000..ad1027b9e --- /dev/null +++ b/gui/fitCommands/booster/toggleState.py @@ -0,0 +1,28 @@ +import wx + +import gui.mainFrame +from gui import globalEvents as GE +from gui.fitCommands.calcCommands.booster.toggleState import CalcToggleBoosterStateCommand +from gui.fitCommands.helpers import InternalCommandHistory +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() + self.fitID = fitID + self.position = position + + def Do(self): + if self.internalHistory.submit(CalcToggleBoosterStateCommand(fitID=self.fitID, position=self.position)): + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) + return True + return False + + def Undo(self): + success = self.internalHistory.undoAll() + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) + return success diff --git a/gui/fitCommands/guiRemoveBooster.py b/gui/fitCommands/guiRemoveBooster.py deleted file mode 100644 index ed763a5f2..000000000 --- a/gui/fitCommands/guiRemoveBooster.py +++ /dev/null @@ -1,30 +0,0 @@ -import wx -from service.fit import Fit - -import gui.mainFrame -from gui import globalEvents as GE -from .calcCommands.booster.remove import CalcRemoveBoosterCommand - - -class GuiRemoveBoosterCommand(wx.Command): - def __init__(self, fitID, position): - wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() - self.fitID = fitID - self.position = position - - def Do(self): - if self.internal_history.Submit(CalcRemoveBoosterCommand(self.fitID, self.position)): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) - return True - return False - - def Undo(self): - for _ in self.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) - return True diff --git a/gui/fitCommands/guiToggleBooster.py b/gui/fitCommands/guiToggleBooster.py deleted file mode 100644 index 688a9c85b..000000000 --- a/gui/fitCommands/guiToggleBooster.py +++ /dev/null @@ -1,30 +0,0 @@ -import wx -from service.fit import Fit - -import gui.mainFrame -from gui import globalEvents as GE -from .calcCommands.booster.toggleState import CalcToggleBoosterStateCommand - - -class GuiToggleBoosterCommand(wx.Command): - def __init__(self, fitID, position): - wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() - self.fitID = fitID - self.position = position - - def Do(self): - if self.internal_history.Submit(CalcToggleBoosterStateCommand(self.fitID, self.position)): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) - return True - return False - - def Undo(self): - for _ in self.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) - return True diff --git a/gui/fitCommands/guiToggleBoosterSideEffect.py b/gui/fitCommands/guiToggleBoosterSideEffect.py deleted file mode 100644 index 862b56a01..000000000 --- a/gui/fitCommands/guiToggleBoosterSideEffect.py +++ /dev/null @@ -1,31 +0,0 @@ -import wx -from service.fit import Fit - -import gui.mainFrame -from gui import globalEvents as GE -from .calcCommands.booster.sideEffectToggleState import CalcToggleBoosterSideEffectStateCommand - - -class GuiToggleBoosterSideEffectCommand(wx.Command): - - def __init__(self, fitID, position, effectID): - wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.internal_history = wx.CommandProcessor() - self.fitID = fitID - self.position = position - self.effectID = effectID - - def Do(self): - if self.internal_history.Submit(CalcToggleBoosterSideEffectStateCommand(self.fitID, self.position, self.effectID)): - Fit.getInstance().recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) - return True - return False - - def Undo(self): - for _ in self.internal_history.Commands: - self.internal_history.Undo() - Fit.getInstance().recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) - return True