Rework GUI booster-related commands
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
0
gui/fitCommands/booster/__init__.py
Normal file
0
gui/fitCommands/booster/__init__.py
Normal file
@@ -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
|
||||
28
gui/fitCommands/booster/remove.py
Normal file
28
gui/fitCommands/booster/remove.py
Normal file
@@ -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
|
||||
30
gui/fitCommands/booster/sideEffectToggleState.py
Normal file
30
gui/fitCommands/booster/sideEffectToggleState.py
Normal file
@@ -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
|
||||
28
gui/fitCommands/booster/toggleState.py
Normal file
28
gui/fitCommands/booster/toggleState.py
Normal file
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user