Rework local fighters GUI commands

This commit is contained in:
DarkPhoenix
2019-04-14 21:42:58 +03:00
parent 51a11edc36
commit cc8575b275
34 changed files with 150 additions and 121 deletions

View File

@@ -94,7 +94,7 @@ class ImplantView(wx.Panel):
def OnRadioSelect(self, event):
fitID = self.mainFrame.getActiveFit()
if fitID is not None:
self.mainFrame.command.Submit(cmd.GuiChangeImplantLocation(fitID, ImplantLocation.FIT if self.rbFit.GetValue() else ImplantLocation.CHARACTER))
self.mainFrame.command.Submit(cmd.GuiChangeImplantLocationCommand(fitID, ImplantLocation.FIT if self.rbFit.GetValue() else ImplantLocation.CHARACTER))
class ImplantDisplay(d.Display):

View File

@@ -50,19 +50,19 @@ class ChangeAmount(ContextMenu):
cleanInput = int(float(re.sub(r'[^0-9.]', '', dlg.input.GetLineText(0).strip())))
if isinstance(thing, es_Cargo):
self.mainFrame.command.Submit(cmd.GuiChangeCargoAmount(fitID, thing.itemID, cleanInput))
self.mainFrame.command.Submit(cmd.GuiChangeCargoAmountCommand(fitID, thing.itemID, cleanInput))
elif isinstance(thing, Drone):
if srcContext == "projectedDrone":
self.mainFrame.command.Submit(cmd.GuiChangeProjectedDroneQty(fitID, thing.itemID, cleanInput))
self.mainFrame.command.Submit(cmd.GuiChangeProjectedDroneQtyCommand(fitID, thing.itemID, cleanInput))
else:
self.mainFrame.command.Submit(cmd.GuiChangeDroneAmount(fitID, fit.drones.index(thing), cleanInput))
self.mainFrame.command.Submit(cmd.GuiChangeDroneAmountCommand(fitID, fit.drones.index(thing), cleanInput))
elif isinstance(thing, es_Fit):
self.mainFrame.command.Submit(cmd.GuiChangeProjectedFitQty(fitID, thing.ID, cleanInput))
self.mainFrame.command.Submit(cmd.GuiChangeProjectedFitQtyCommand(fitID, thing.ID, cleanInput))
elif isinstance(thing, es_Fighter):
if srcContext == "projectedFighter":
self.mainFrame.command.Submit(cmd.GuiChangeProjectedFighterAmount(fitID, fit.projectedFighters.index(thing), cleanInput))
self.mainFrame.command.Submit(cmd.GuiChangeProjectedFighterAmountCommand(fitID, fit.projectedFighters.index(thing), cleanInput))
else:
self.mainFrame.command.Submit(cmd.GuiChangeFighterQty(fitID, fit.fighters.index(thing), cleanInput))
self.mainFrame.command.Submit(cmd.GuiChangeFighterAmountCommand(fitID, fit.fighters.index(thing), cleanInput))
ChangeAmount.register()

View File

@@ -66,7 +66,7 @@ class FighterAbility(ContextMenu):
index = fit.projectedFighters.index(self.fighter)
else:
index = fit.fighters.index(self.fighter)
self.mainFrame.command.Submit(cmd.GuiToggleFighterAbilityCommand(fitID, index, ability.effectID, self.isProjected))
self.mainFrame.command.Submit(cmd.GuiToggleFighterAbilityCommand(fitID, index, ability.effectID))
FighterAbility.register()

View File

@@ -75,7 +75,7 @@ class SpoolUp(ContextMenu):
spoolAmount = self.cycleMap[event.Id]
else:
return
self.mainFrame.command.Submit(cmd.GuiSetSpoolup(
self.mainFrame.command.Submit(cmd.GuiSetSpoolupCommand(
fitID=self.mainFrame.getActiveFit(),
position=self.mod.modPosition,
spoolType=spoolType,

View File

@@ -3,22 +3,27 @@ from .booster.remove import GuiRemoveBoosterCommand
from .booster.sideEffectToggleState import GuiToggleBoosterSideEffectStateCommand
from .booster.toggleState import GuiToggleBoosterStateCommand
from .cargo.add import GuiAddCargoCommand
from .cargo.changeAmount import GuiChangeCargoAmount
from .cargo.changeAmount import GuiChangeCargoAmountCommand
from .cargo.remove import GuiRemoveCargoCommand
from .commandFit.add import GuiAddCommandFitCommand
from .commandFit.remove import GuiRemoveCommandFitCommand
from .commandFit.toggleState import GuiToggleCommandFitStateCommand
from .guiAddCharge import GuiModuleAddChargeCommand
from .drone.add import GuiAddDroneCommand
from .guiAddFighter import GuiAddFighterCommand
from .drone.changeAmount import GuiChangeDroneAmountCommand
from .drone.remove import GuiRemoveDroneCommand
from .drone.toggleState import GuiToggleDroneStateCommand
from .fighter.abilityToggleState import GuiToggleFighterAbilityCommand
from .fighter.add import GuiAddFighterCommand
from .fighter.changeAmount import GuiChangeFighterAmountCommand
from .fighter.remove import GuiRemoveFighterCommand
from .fighter.toggleState import GuiToggleFighterCommand
from .guiAddCharge import GuiModuleAddChargeCommand
from .guiAddModule import GuiModuleAddCommand
from .guiAddProjected import GuiAddProjectedCommand
from .guiCargoToModule import GuiCargoToModuleCommand
from .drone.changeAmount import GuiChangeDroneAmount
from .guiChangeFighterQty import GuiChangeFighterQty
from .guiChangeProjectedDroneQty import GuiChangeProjectedDroneQty
from .guiChangeProjectedFighterAmount import GuiChangeProjectedFighterAmount
from .guiChangeProjectedFitQty import GuiChangeProjectedFitQty
from .guiChangeProjectedDroneQty import GuiChangeProjectedDroneQtyCommand
from .guiChangeProjectedFighterAmount import GuiChangeProjectedFighterAmountCommand
from .guiChangeProjectedFitQty import GuiChangeProjectedFitQtyCommand
from .guiFillWithModule import GuiFillWithModuleCommand
from .guiFitRename import GuiFitRenameCommand
from .guiImportMutatedModule import GuiImportMutatedModuleCommand
@@ -27,19 +32,14 @@ from .guiModuleToCargo import GuiModuleToCargoCommand
from .guiMutaConvert import GuiMutaConvertCommand
from .guiMutaRevert import GuiMutaRevertCommand
from .guiRebaseItems import GuiRebaseItemsCommand
from .drone.remove import GuiRemoveDroneCommand
from .guiRemoveFighter import GuiRemoveFighterCommand
from .guiRemoveModule import GuiModuleRemoveCommand
from .guiRemoveProjected import GuiRemoveProjectedCommand
from .guiSetMode import GuiSetModeCommand
from .guiSetSpoolup import GuiSetSpoolup
from .guiSetSpoolup import GuiSetSpoolupCommand
from .guiSwapCloneModule import GuiModuleSwapOrCloneCommand
from .drone.toggleState import GuiToggleDroneStateCommand
from .guiToggleFighter import GuiToggleFighterCommand
from .guiToggleFighterAbility import GuiToggleFighterAbilityCommand
from .guiToggleModuleState import GuiModuleStateChangeCommand
from .guiToggleProjected import GuiToggleProjectedCommand
from .implant.add import GuiAddImplantCommand
from .implant.changeLocation import GuiChangeImplantLocation
from .implant.changeLocation import GuiChangeImplantLocationCommand
from .implant.remove import GuiRemoveImplantCommand
from .implant.toggleState import GuiToggleImplantStateCommand

View File

@@ -16,7 +16,8 @@ class GuiAddBoosterCommand(wx.Command):
self.itemID = itemID
def Do(self):
if self.internalHistory.submit(CalcAddBoosterCommand(fitID=self.fitID, boosterInfo=BoosterInfo(itemID=self.itemID))):
cmd = CalcAddBoosterCommand(fitID=self.fitID, boosterInfo=BoosterInfo(itemID=self.itemID))
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -15,7 +15,8 @@ class GuiRemoveBoosterCommand(wx.Command):
self.position = position
def Do(self):
if self.internalHistory.submit(CalcRemoveBoosterCommand(fitID=self.fitID, position=self.position)):
cmd = CalcRemoveBoosterCommand(fitID=self.fitID, position=self.position)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -17,7 +17,8 @@ class GuiToggleBoosterSideEffectStateCommand(wx.Command):
self.effectID = effectID
def Do(self):
if self.internalHistory.submit(CalcToggleBoosterSideEffectStateCommand(fitID=self.fitID, position=self.position, effectID=self.effectID)):
cmd = CalcToggleBoosterSideEffectStateCommand(fitID=self.fitID, position=self.position, effectID=self.effectID)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -15,7 +15,8 @@ class GuiToggleBoosterStateCommand(wx.Command):
self.position = position
def Do(self):
if self.internalHistory.submit(CalcToggleBoosterStateCommand(fitID=self.fitID, position=self.position)):
cmd = CalcToggleBoosterStateCommand(fitID=self.fitID, position=self.position)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -16,7 +16,8 @@ class GuiAddCargoCommand(wx.Command):
self.amount = amount
def Do(self):
if self.internalHistory.submit(CalcAddCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=self.amount))):
cmd = CalcAddCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=self.amount))
if self.internalHistory.submit(cmd):
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False

View File

@@ -9,7 +9,7 @@ from gui.fitCommands.calcCommands.cargo.remove import CalcRemoveCargoCommand
from gui.fitCommands.helpers import CargoInfo, InternalCommandHistory
class GuiChangeCargoAmount(wx.Command):
class GuiChangeCargoAmountCommand(wx.Command):
def __init__(self, fitID, itemID, amount):
wx.Command.__init__(self, True, 'Change Cargo Amount')
@@ -20,11 +20,13 @@ class GuiChangeCargoAmount(wx.Command):
def Do(self):
if self.amount > 0:
if self.internalHistory.submit(CalcChangeCargoAmountCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=self.amount))):
cmd = CalcChangeCargoAmountCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=self.amount))
if self.internalHistory.submit(cmd):
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
else:
if self.internalHistory.submit(CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))):
cmd = CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))
if self.internalHistory.submit(cmd):
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False

View File

@@ -17,7 +17,8 @@ class GuiRemoveCargoCommand(wx.Command):
self.itemID = itemID
def Do(self):
if self.internalHistory.submit(CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))):
cmd = CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))
if self.internalHistory.submit(cmd):
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False

View File

@@ -16,7 +16,8 @@ class GuiAddCommandFitCommand(wx.Command):
self.commandFitID = commandFitID
def Do(self):
if self.internalHistory.submit(CalcAddCommandCommand(fitID=self.fitID, commandFitID=self.commandFitID)):
cmd = CalcAddCommandCommand(fitID=self.fitID, commandFitID=self.commandFitID)
if self.internalHistory.submit(cmd):
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
Fit.getInstance().recalc(self.fitID)
return True

View File

@@ -16,7 +16,8 @@ class GuiRemoveCommandFitCommand(wx.Command):
self.commandFitID = commandFitID
def Do(self):
if self.internalHistory.submit(CalcRemoveCommandCommand(fitID=self.fitID, commandFitID=self.commandFitID)):
cmd = CalcRemoveCommandCommand(fitID=self.fitID, commandFitID=self.commandFitID)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -16,7 +16,8 @@ class GuiToggleCommandFitStateCommand(wx.Command):
self.commandFitID = commandFitID
def Do(self):
if self.internalHistory.submit(CalcToggleCommandFitStateCommand(fitID=self.fitID, commandFitID=self.commandFitID)):
cmd = CalcToggleCommandFitStateCommand(fitID=self.fitID, commandFitID=self.commandFitID)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -16,7 +16,8 @@ class GuiAddDroneCommand(wx.Command):
self.itemID = itemID
def Do(self):
if self.internalHistory.submit(CalcAddLocalDroneCommand(fitID=self.fitID, droneInfo=DroneInfo(itemID=self.itemID, amount=1, amountActive=0))):
cmd = CalcAddLocalDroneCommand(fitID=self.fitID, droneInfo=DroneInfo(itemID=self.itemID, amount=1, amountActive=0))
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -10,7 +10,7 @@ from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiChangeDroneAmount(wx.Command):
class GuiChangeDroneAmountCommand(wx.Command):
def __init__(self, fitID, position, amount):
wx.Command.__init__(self, True, 'Change Drone Amount')
@@ -21,12 +21,14 @@ class GuiChangeDroneAmount(wx.Command):
def Do(self):
if self.amount > 0:
if self.internalHistory.submit(CalcChangeLocalDroneAmountCommand(fitID=self.fitID, position=self.position, amount=self.amount)):
cmd = CalcChangeLocalDroneAmountCommand(fitID=self.fitID, position=self.position, amount=self.amount)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
else:
if self.internalHistory.submit(CalcRemoveLocalDroneCommand(fitID=self.fitID, position=self.position, amount=math.inf)):
cmd = CalcRemoveLocalDroneCommand(fitID=self.fitID, position=self.position, amount=math.inf)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -17,7 +17,8 @@ class GuiRemoveDroneCommand(wx.Command):
self.amount = amount
def Do(self):
if self.internalHistory.submit(CalcRemoveLocalDroneCommand(fitID=self.fitID, position=self.position, amount=self.amount)):
cmd = CalcRemoveLocalDroneCommand(fitID=self.fitID, position=self.position, amount=self.amount)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -16,7 +16,8 @@ class GuiToggleDroneStateCommand(wx.Command):
self.position = position
def Do(self):
if self.internalHistory.submit(CalcToggleLocalDroneStateCommand(fitID=self.fitID, position=self.position)):
cmd = CalcToggleLocalDroneStateCommand(fitID=self.fitID, position=self.position)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

View File

@@ -1,31 +1,31 @@
import wx
from service.fit import Fit
import gui.mainFrame
from gui import globalEvents as GE
from .calcCommands.fighter.abilityToggleState import CalcToggleFighterAbilityStateCommand
from gui.fitCommands.calcCommands.fighter.abilityToggleState import CalcToggleFighterAbilityStateCommand
from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiToggleFighterAbilityCommand(wx.Command):
def __init__(self, fitID, position, effectID, isProjected):
wx.Command.__init__(self, True, "")
self.internalHistory = wx.CommandProcessor()
def __init__(self, fitID, position, effectID):
wx.Command.__init__(self, True, 'Toggle Fighter Ability State')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.position = position
self.effectID = effectID
self.isProjected = isProjected
def Do(self):
if self.internalHistory.Submit(CalcToggleFighterAbilityStateCommand(self.fitID, self.isProjected, self.position, self.effectID)):
cmd = CalcToggleFighterAbilityStateCommand(fitID=self.fitID, projected=False, position=self.position, effectID=self.effectID)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
for _ in self.internalHistory.Commands:
self.internalHistory.Undo()
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return success

View File

@@ -2,28 +2,29 @@ import wx
import gui.mainFrame
from gui import globalEvents as GE
from gui.fitCommands.helpers import FighterInfo
from gui.fitCommands.calcCommands.fighter.localAdd import CalcAddLocalFighterCommand
from gui.fitCommands.helpers import FighterInfo, InternalCommandHistory
from service.fit import Fit
from .calcCommands.fighter.localAdd import CalcAddLocalFighterCommand
class GuiAddFighterCommand(wx.Command):
def __init__(self, fitID, itemID):
wx.Command.__init__(self, True, "Fighter Add")
self.internalHistory = wx.CommandProcessor()
wx.Command.__init__(self, True, 'Add Fighter')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.itemID = itemID
def Do(self):
if self.internalHistory.Submit(CalcAddLocalFighterCommand(fitID=self.fitID, fighterInfo=FighterInfo(itemID=self.itemID))):
cmd = CalcAddLocalFighterCommand(fitID=self.fitID, fighterInfo=FighterInfo(itemID=self.itemID))
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
for _ in self.internalHistory.Commands:
self.internalHistory.Undo()
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return success

View File

@@ -0,0 +1,39 @@
import wx
import gui.mainFrame
from gui import globalEvents as GE
from gui.fitCommands.calcCommands.fighter.changeAmount import CalcChangeFighterAmountCommand
from gui.fitCommands.calcCommands.fighter.localRemove import CalcRemoveLocalFighterCommand
from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiChangeFighterAmountCommand(wx.Command):
def __init__(self, fitID, position, amount):
wx.Command.__init__(self, True, 'Change Fighter Amount')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.position = position
self.amount = amount
def Do(self):
if self.amount > 0:
cmd = CalcChangeFighterAmountCommand(fitID=self.fitID, projected=False, position=self.position, amount=self.amount)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
else:
cmd = CalcRemoveLocalFighterCommand(fitID=self.fitID, position=self.position)
if self.internalHistory.submit(cmd):
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

View File

@@ -1,29 +1,30 @@
import wx
from service.fit import Fit
import gui.mainFrame
from gui import globalEvents as GE
from .calcCommands.fighter.localRemove import CalcRemoveLocalFighterCommand
from gui.fitCommands.calcCommands.fighter.localRemove import CalcRemoveLocalFighterCommand
from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiRemoveFighterCommand(wx.Command):
def __init__(self, fitID, position):
wx.Command.__init__(self, True, "Fighter Remove")
wx.Command.__init__(self, True, 'Remove Fighter')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.position = position
self.internalHistory = wx.CommandProcessor()
def Do(self):
success = self.internalHistory.Submit(CalcRemoveLocalFighterCommand(self.fitID, self.position))
if success:
cmd = CalcRemoveLocalFighterCommand(fitID=self.fitID, position=self.position)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
for _ in self.internalHistory.Commands:
self.internalHistory.Undo()
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return success

View File

@@ -1,28 +1,30 @@
import wx
from service.fit import Fit
import gui.mainFrame
from gui import globalEvents as GE
from .calcCommands.fighter.toggleState import CalcToggleFighterStateCommand
from gui.fitCommands.calcCommands.fighter.toggleState import CalcToggleFighterStateCommand
from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiToggleFighterCommand(wx.Command):
def __init__(self, fitID, position):
wx.Command.__init__(self, True, "")
self.internalHistory = wx.CommandProcessor()
wx.Command.__init__(self, True, 'Toggle Fighter State')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.position = position
def Do(self):
if self.internalHistory.Submit(CalcToggleFighterStateCommand(self.fitID, False, self.position)):
cmd = CalcToggleFighterStateCommand(fitID=self.fitID, projected=False, position=self.position)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
for _ in self.internalHistory.Commands:
self.internalHistory.Undo()
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return success

View File

@@ -1,32 +0,0 @@
import wx
import gui.mainFrame
from gui import globalEvents as GE
from .calcCommands.fighter.changeAmount import CalcChangeFighterAmountCommand
from service.fit import Fit
from logbook import Logger
pyfalog = Logger(__name__)
class GuiChangeFighterQty(wx.Command):
def __init__(self, fitID, position, amount=1):
wx.Command.__init__(self, True, "")
self.fitID = fitID
self.position = position
self.amount = amount
self.internalHistory = wx.CommandProcessor()
def Do(self):
cmd = CalcChangeFighterAmountCommand(self.fitID, False, self.position, self.amount)
if self.internalHistory.Submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
pyfalog.debug("{} Undo()".format(self))
for _ in self.internalHistory.Commands:
self.internalHistory.Undo()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -7,7 +7,7 @@ from logbook import Logger
pyfalog = Logger(__name__)
class GuiChangeProjectedDroneQty(wx.Command):
class GuiChangeProjectedDroneQtyCommand(wx.Command):
def __init__(self, fitID, itemID, amount=1):
wx.Command.__init__(self, True, "")
self.fitID = fitID

View File

@@ -7,7 +7,7 @@ from logbook import Logger
pyfalog = Logger(__name__)
class GuiChangeProjectedFighterAmount(wx.Command):
class GuiChangeProjectedFighterAmountCommand(wx.Command):
def __init__(self, fitID, position, amount):
wx.Command.__init__(self, True, "")

View File

@@ -7,7 +7,7 @@ from logbook import Logger
pyfalog = Logger(__name__)
class GuiChangeProjectedFitQty(wx.Command):
class GuiChangeProjectedFitQtyCommand(wx.Command):
def __init__(self, fitID, pfitID, amount=1):
wx.Command.__init__(self, True, "")
self.fitID = fitID

View File

@@ -6,7 +6,7 @@ from gui import globalEvents as GE
from .calcCommands.module.changeSpool import CalcChangeModuleSpoolCommand
class GuiSetSpoolup(wx.Command):
class GuiSetSpoolupCommand(wx.Command):
def __init__(self, fitID, position, spoolType, spoolAmount, context):
wx.Command.__init__(self, True, "Booster Add")

View File

@@ -18,10 +18,9 @@ class GuiAddImplantCommand(wx.Command):
self.itemID = itemID
def Do(self):
if (
self.internalHistory.submit(CalcAddImplantCommand(fitID=self.fitID, implantInfo=ImplantInfo(itemID=self.itemID))) and
self.internalHistory.submit(CalcChangeImplantLocationCommand(fitID=self.fitID, source=ImplantLocation.FIT))
):
cmdImplant = CalcAddImplantCommand(fitID=self.fitID, implantInfo=ImplantInfo(itemID=self.itemID))
cmdLocation = CalcChangeImplantLocationCommand(fitID=self.fitID, source=ImplantLocation.FIT)
if self.internalHistory.submit(cmdImplant) and self.internalHistory.submit(cmdLocation):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -7,7 +7,7 @@ from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiChangeImplantLocation(wx.Command):
class GuiChangeImplantLocationCommand(wx.Command):
def __init__(self, fitID, source):
wx.Command.__init__(self, True, 'Change Implant Location')
@@ -16,7 +16,8 @@ class GuiChangeImplantLocation(wx.Command):
self.source = source
def Do(self):
if self.internalHistory.submit(CalcChangeImplantLocationCommand(fitID=self.fitID, source=self.source)):
cmd = CalcChangeImplantLocationCommand(fitID=self.fitID, source=self.source)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -16,7 +16,8 @@ class GuiRemoveImplantCommand(wx.Command):
self.position = position
def Do(self):
if self.internalHistory.submit(CalcRemoveImplantCommand(fitID=self.fitID, position=self.position)):
cmd = CalcRemoveImplantCommand(fitID=self.fitID, position=self.position)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -16,7 +16,8 @@ class GuiToggleImplantStateCommand(wx.Command):
self.position = position
def Do(self):
if self.internalHistory.submit(CalcToggleImplantStateCommand(fitID=self.fitID, position=self.position)):
cmd = CalcToggleImplantStateCommand(fitID=self.fitID, position=self.position)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True