From d61d69188fdb8e85b8f055f64387de19a2cb20ae Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sun, 14 Apr 2019 15:44:48 +0300 Subject: [PATCH] Do not store fit service and main frame on every command --- gui/fitCommands/guiAddCargo.py | 14 ++++------ gui/fitCommands/guiAddCharge.py | 18 ++++++------ gui/fitCommands/guiAddCommand.py | 18 ++++++------ gui/fitCommands/guiAddDrone.py | 16 +++++------ gui/fitCommands/guiAddFighter.py | 8 +++--- gui/fitCommands/guiAddProjected.py | 24 ++++++++-------- gui/fitCommands/guiCargoToModule.py | 24 ++++++++-------- gui/fitCommands/guiChangeCargoQty.py | 18 ++++++------ gui/fitCommands/guiChangeDroneQty.py | 18 ++++++------ gui/fitCommands/guiChangeFighterQty.py | 18 ++++++------ gui/fitCommands/guiChangeProjectedDroneQty.py | 18 ++++++------ .../guiChangeProjectedFighterAmount.py | 18 ++++++------ gui/fitCommands/guiChangeProjectedFitQty.py | 18 ++++++------ gui/fitCommands/guiFillWithModule.py | 18 ++++++------ gui/fitCommands/guiFitRename.py | 14 ++++------ gui/fitCommands/guiMetaSwap.py | 20 ++++++------- gui/fitCommands/guiModuleToCargo.py | 28 +++++++++---------- gui/fitCommands/guiMutaConvert.py | 13 ++++----- gui/fitCommands/guiMutaRevert.py | 13 ++++----- gui/fitCommands/guiRebaseItems.py | 5 ++-- gui/fitCommands/guiRemoveCargo.py | 14 ++++------ gui/fitCommands/guiRemoveCommand.py | 18 ++++++------ gui/fitCommands/guiRemoveDrone.py | 18 ++++++------ gui/fitCommands/guiRemoveFighter.py | 18 ++++++------ gui/fitCommands/guiRemoveModule.py | 18 ++++++------ gui/fitCommands/guiRemoveProjected.py | 20 ++++++------- gui/fitCommands/guiSetMode.py | 18 ++++++------ gui/fitCommands/guiSetSpoolup.py | 18 ++++++------ gui/fitCommands/guiSwapCloneModule.py | 22 +++++++-------- gui/fitCommands/guiToggleCommand.py | 18 ++++++------ gui/fitCommands/guiToggleDrone.py | 18 ++++++------ gui/fitCommands/guiToggleFighter.py | 18 ++++++------ gui/fitCommands/guiToggleFighterAbility.py | 13 ++++----- gui/fitCommands/guiToggleModuleState.py | 18 ++++++------ gui/fitCommands/guiToggleProjected.py | 13 ++++----- gui/fitCommands/implant/remove.py | 5 ++-- 36 files changed, 272 insertions(+), 336 deletions(-) diff --git a/gui/fitCommands/guiAddCargo.py b/gui/fitCommands/guiAddCargo.py index 40acf14b6..52400dd71 100644 --- a/gui/fitCommands/guiAddCargo.py +++ b/gui/fitCommands/guiAddCargo.py @@ -11,21 +11,19 @@ class GuiAddCargoCommand(wx.Command): def __init__(self, fitID, itemID, amount=1): wx.Command.__init__(self, True, "Cargo Add") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.itemID = itemID self.amount = amount def Do(self): - if self.internal_history.Submit(CalcAddCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=self.amount))): - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + if self.internalHistory.Submit(CalcAddCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=self.amount))): + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True return False def Undo(self): - for _ in self.internal_history.Commands: - self.internal_history.Undo() - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + for _ in self.internalHistory.Commands: + self.internalHistory.Undo() + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True diff --git a/gui/fitCommands/guiAddCharge.py b/gui/fitCommands/guiAddCharge.py index 701e46a25..6da789f96 100644 --- a/gui/fitCommands/guiAddCharge.py +++ b/gui/fitCommands/guiAddCharge.py @@ -9,24 +9,22 @@ from .calcCommands.module.changeCharges import CalcChangeModuleChargesCommand class GuiModuleAddChargeCommand(wx.Command): def __init__(self, fitID, itemID, modules): wx.Command.__init__(self, True, "Module Charge Add") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.itemID = itemID self.positions = [mod.modPosition for mod in modules] self.projected = modules[0].isProjected def Do(self): - if self.internal_history.Submit(CalcChangeModuleChargesCommand(self.fitID, {p: self.itemID for p in self.positions}, self.projected)): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + if self.internalHistory.Submit(CalcChangeModuleChargesCommand(self.fitID, {p: self.itemID for p in self.positions}, self.projected)): + 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.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiAddCommand.py b/gui/fitCommands/guiAddCommand.py index c1a0513a0..872c43cd9 100644 --- a/gui/fitCommands/guiAddCommand.py +++ b/gui/fitCommands/guiAddCommand.py @@ -9,22 +9,20 @@ from .calcCommands.commandFit.add import CalcAddCommandCommand class GuiAddCommandCommand(wx.Command): def __init__(self, fitID, commandFitID): wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.commandFitID = commandFitID def Do(self): - if self.internal_history.Submit(CalcAddCommandCommand(self.fitID, self.commandFitID, None)): - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) - self.sFit.recalc(self.fitID) + if self.internalHistory.Submit(CalcAddCommandCommand(self.fitID, self.commandFitID, None)): + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) + Fit.getInstance().recalc(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)) + 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 diff --git a/gui/fitCommands/guiAddDrone.py b/gui/fitCommands/guiAddDrone.py index 4a4be5c5c..87fe44371 100644 --- a/gui/fitCommands/guiAddDrone.py +++ b/gui/fitCommands/guiAddDrone.py @@ -10,22 +10,20 @@ from .calcCommands.drone.localAdd import CalcAddLocalDroneCommand class GuiAddDroneCommand(wx.Command): def __init__(self, fitID, itemID): wx.Command.__init__(self, True, "Drone Add") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.itemID = itemID def Do(self): cmd = CalcAddLocalDroneCommand(fitID=self.fitID, droneInfo=DroneInfo(itemID=self.itemID, amount=1, amountActive=0)) - if self.internal_history.Submit(cmd): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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.internal_history.Commands: - self.internal_history.Undo() - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + for _ in self.internalHistory.Commands: + self.internalHistory.Undo() + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True diff --git a/gui/fitCommands/guiAddFighter.py b/gui/fitCommands/guiAddFighter.py index d66df4aa1..cfaeab719 100644 --- a/gui/fitCommands/guiAddFighter.py +++ b/gui/fitCommands/guiAddFighter.py @@ -10,20 +10,20 @@ from .calcCommands.fighter.localAdd import CalcAddLocalFighterCommand class GuiAddFighterCommand(wx.Command): def __init__(self, fitID, itemID): wx.Command.__init__(self, True, "Fighter Add") - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.itemID = itemID def Do(self): - if self.internal_history.Submit(CalcAddLocalFighterCommand(fitID=self.fitID, fighterInfo=FighterInfo(itemID=self.itemID))): + if self.internalHistory.Submit(CalcAddLocalFighterCommand(fitID=self.fitID, fighterInfo=FighterInfo(itemID=self.itemID))): 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.internal_history.Commands: - self.internal_history.Undo() + 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 diff --git a/gui/fitCommands/guiAddProjected.py b/gui/fitCommands/guiAddProjected.py index 5da233395..0558e9035 100644 --- a/gui/fitCommands/guiAddProjected.py +++ b/gui/fitCommands/guiAddProjected.py @@ -16,9 +16,7 @@ pyfalog = Logger(__name__) class GuiAddProjectedCommand(wx.Command): def __init__(self, fitID, id, type='item'): wx.Command.__init__(self, True, "Projected Add") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.id = id self.type = type @@ -31,27 +29,27 @@ class GuiAddProjectedCommand(wx.Command): item = eos.db.getItem(self.id, eager=("attributes", "group.category")) if item.category.name == "Drone": - result = self.internal_history.Submit(CalcAddProjectedDroneCommand( + result = self.internalHistory.Submit(CalcAddProjectedDroneCommand( fitID=self.fitID, droneInfo=DroneInfo(itemID=self.id, amount=1, amountActive=1))) elif item.category.name == "Fighter": - result = self.internal_history.Submit(CalcAddProjectedFighterCommand(self.fitID, fighterInfo=FighterInfo(itemID=self.id))) + result = self.internalHistory.Submit(CalcAddProjectedFighterCommand(self.fitID, fighterInfo=FighterInfo(itemID=self.id))) else: - result = self.internal_history.Submit(CalcAddProjectedModuleCommand( + result = self.internalHistory.Submit(CalcAddProjectedModuleCommand( fitID=self.fitID, modInfo=ModuleInfo(itemID=self.id))) elif self.type == 'fit': - result = self.internal_history.Submit(CalcAddProjectedFitCommand(self.fitID, self.id, None)) + result = self.internalHistory.Submit(CalcAddProjectedFitCommand(self.fitID, self.id, None)) if result: - 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): - for _ in self.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiCargoToModule.py b/gui/fitCommands/guiCargoToModule.py index 14d18b0d2..37b0e112e 100644 --- a/gui/fitCommands/guiCargoToModule.py +++ b/gui/fitCommands/guiCargoToModule.py @@ -23,13 +23,11 @@ class GuiCargoToModuleCommand(wx.Command): def __init__(self, fitID, moduleIdx, cargoIdx, copy=False): wx.Command.__init__(self, True, "Cargo to Module") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.moduleIdx = moduleIdx self.cargoIdx = cargoIdx self.copy = copy - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): sFit = Fit.getInstance() @@ -40,7 +38,7 @@ class GuiCargoToModuleCommand(wx.Command): # We're trying to move a charge from cargo to a slot. Use SetCharge command (don't respect move vs copy) if sFit.isAmmo(cargo.itemID): - result = self.internal_history.Submit(CalcChangeModuleChargesCommand(self.fitID, {module.modPosition: cargo.itemID})) + result = self.internalHistory.Submit(CalcChangeModuleChargesCommand(self.fitID, {module.modPosition: cargo.itemID})) else: pyfalog.debug("Moving cargo item to module for fit ID: {0}", self.fitID) @@ -50,7 +48,7 @@ class GuiCargoToModuleCommand(wx.Command): position=module.modPosition, newModInfo=ModuleInfo(itemID=cargo.itemID)) - result = self.internal_history.Submit(self.addCmd) + result = self.internalHistory.Submit(self.addCmd) if not result: # creating module failed for whatever reason @@ -59,23 +57,23 @@ class GuiCargoToModuleCommand(wx.Command): if self.addCmd.old_module is not None: # we're swapping with an existing module, so remove cargo and add module self.removeCmd = CalcRemoveCargoCommand(self.fitID, cargo.itemID) - result = self.internal_history.Submit(self.removeCmd) + result = self.internalHistory.Submit(self.removeCmd) self.addCargoCmd = CalcAddCargoCommand(self.fitID, self.addCmd.old_module.itemID) - result = self.internal_history.Submit(self.addCargoCmd) + result = self.internalHistory.Submit(self.addCargoCmd) elif not self.copy: # move, not copying, so remove cargo self.removeCmd = CalcRemoveCargoCommand(self.fitID, cargo.itemID) - result = self.internal_history.Submit(self.removeCmd) + result = self.internalHistory.Submit(self.removeCmd) if result: sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return result 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)) + 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 diff --git a/gui/fitCommands/guiChangeCargoQty.py b/gui/fitCommands/guiChangeCargoQty.py index 13c5b5ced..4be9db1ac 100644 --- a/gui/fitCommands/guiChangeCargoQty.py +++ b/gui/fitCommands/guiChangeCargoQty.py @@ -12,24 +12,22 @@ class GuiChangeCargoQty(wx.Command): def __init__(self, fitID, itemID, amount): wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.itemID = itemID self.amount = amount - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): cmd = CalcChangeCargoAmountCommand(self.fitID, CargoInfo(itemID=self.itemID, amount=self.amount)) - if self.internal_history.Submit(cmd): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiChangeDroneQty.py b/gui/fitCommands/guiChangeDroneQty.py index f8c929b1a..8f72ef638 100644 --- a/gui/fitCommands/guiChangeDroneQty.py +++ b/gui/fitCommands/guiChangeDroneQty.py @@ -10,24 +10,22 @@ pyfalog = Logger(__name__) class GuiChangeDroneQty(wx.Command): def __init__(self, fitID, position, amount=1): wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.position = position self.amount = amount - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): cmd = CalcChangeLocalDroneAmountCommand(self.fitID, self.position, self.amount) - if self.internal_history.Submit(cmd): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiChangeFighterQty.py b/gui/fitCommands/guiChangeFighterQty.py index a6186ae3e..7a28e353a 100644 --- a/gui/fitCommands/guiChangeFighterQty.py +++ b/gui/fitCommands/guiChangeFighterQty.py @@ -10,25 +10,23 @@ pyfalog = Logger(__name__) class GuiChangeFighterQty(wx.Command): def __init__(self, fitID, position, amount=1): wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.position = position self.amount = amount - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): cmd = CalcChangeFighterAmountCommand(self.fitID, False, self.position, self.amount) - if self.internal_history.Submit(cmd): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiChangeProjectedDroneQty.py b/gui/fitCommands/guiChangeProjectedDroneQty.py index 422b9a98e..348d75a9b 100644 --- a/gui/fitCommands/guiChangeProjectedDroneQty.py +++ b/gui/fitCommands/guiChangeProjectedDroneQty.py @@ -10,25 +10,23 @@ pyfalog = Logger(__name__) class GuiChangeProjectedDroneQty(wx.Command): def __init__(self, fitID, itemID, amount=1): wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.itemID = itemID self.amount = amount - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): cmd = CalcChangeProjectedDroneAmountCommand(self.fitID, self.itemID, self.amount) - if self.internal_history.Submit(cmd): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiChangeProjectedFighterAmount.py b/gui/fitCommands/guiChangeProjectedFighterAmount.py index 74071ebb0..86c12c7b6 100644 --- a/gui/fitCommands/guiChangeProjectedFighterAmount.py +++ b/gui/fitCommands/guiChangeProjectedFighterAmount.py @@ -11,25 +11,23 @@ class GuiChangeProjectedFighterAmount(wx.Command): def __init__(self, fitID, position, amount): wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.position = position self.amount = amount - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): cmd = CalcChangeFighterAmountCommand(self.fitID, True, self.position, self.amount) - if self.internal_history.Submit(cmd): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiChangeProjectedFitQty.py b/gui/fitCommands/guiChangeProjectedFitQty.py index 77b6760ac..0d1e96e65 100644 --- a/gui/fitCommands/guiChangeProjectedFitQty.py +++ b/gui/fitCommands/guiChangeProjectedFitQty.py @@ -10,25 +10,23 @@ pyfalog = Logger(__name__) class GuiChangeProjectedFitQty(wx.Command): def __init__(self, fitID, pfitID, amount=1): wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.pfitID = pfitID self.amount = amount - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): cmd = CalcChangeProjectedFitAmountCommand(self.fitID, self.pfitID, self.amount) - if self.internal_history.Submit(cmd): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiFillWithModule.py b/gui/fitCommands/guiFillWithModule.py index 0b714b20c..88efdb1ed 100644 --- a/gui/fitCommands/guiFillWithModule.py +++ b/gui/fitCommands/guiFillWithModule.py @@ -22,11 +22,9 @@ class GuiFillWithModuleCommand(wx.Command): :param position: Optional. The position in fit.modules that we are attempting to set the item to """ wx.Command.__init__(self, True, "Module Fill: {}".format(itemID)) - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.itemID = itemID - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.position = position self.old_mod = None @@ -34,19 +32,19 @@ class GuiFillWithModuleCommand(wx.Command): pyfalog.debug("{} Do()".format(self)) pyfalog.debug("Trying to append a module") added_modules = 0 - while self.internal_history.Submit(CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=ModuleInfo(itemID=self.itemID))): + while self.internalHistory.Submit(CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=ModuleInfo(itemID=self.itemID))): added_modules += 1 if added_modules > 0: - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID, action="modadd", typeID=self.itemID)) + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID, action="modadd", typeID=self.itemID)) return True return False def Undo(self): pyfalog.debug("{} Undo()".format(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, action="moddel", typeID=self.itemID)) + for _ in self.internalHistory.Commands: + self.internalHistory.Undo() + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID, action="moddel", typeID=self.itemID)) return True diff --git a/gui/fitCommands/guiFitRename.py b/gui/fitCommands/guiFitRename.py index 99c6cc772..201c85ce9 100644 --- a/gui/fitCommands/guiFitRename.py +++ b/gui/fitCommands/guiFitRename.py @@ -10,21 +10,19 @@ pyfalog = Logger(__name__) class GuiFitRenameCommand(wx.Command): def __init__(self, fitID, newName): wx.Command.__init__(self, True) - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.newName = newName - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): - if self.internal_history.Submit(CalcFitRenameCommand(self.fitID, self.newName)): - wx.PostEvent(self.mainFrame, FitRenamed(fitID=self.fitID)) + if self.internalHistory.Submit(CalcFitRenameCommand(self.fitID, self.newName)): + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), FitRenamed(fitID=self.fitID)) return True return False def Undo(self): pyfalog.debug("{} Undo()".format(self)) - for _ in self.internal_history.Commands: - self.internal_history.Undo() - wx.PostEvent(self.mainFrame, FitRenamed(fitID=self.fitID)) + for _ in self.internalHistory.Commands: + self.internalHistory.Undo() + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), FitRenamed(fitID=self.fitID)) return True diff --git a/gui/fitCommands/guiMetaSwap.py b/gui/fitCommands/guiMetaSwap.py index 73a8864ef..a4f77a814 100644 --- a/gui/fitCommands/guiMetaSwap.py +++ b/gui/fitCommands/guiMetaSwap.py @@ -18,14 +18,12 @@ from .calcCommands.itemRebase import CalcRebaseItemCommand class GuiMetaSwapCommand(wx.Command): def __init__(self, fitID, context, itemID, selection: list): wx.Command.__init__(self, True, "Meta Swap") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.itemID = itemID self.context = context self.data = [] - fit = self.sFit.getFit(fitID) + fit = Fit.getInstance().getFit(fitID) if context == 'fittingModule': for x in selection: @@ -56,15 +54,15 @@ class GuiMetaSwapCommand(wx.Command): def Do(self): for cmds in self.data: for cmd in cmds: - self.internal_history.Submit(cmd[0](*cmd[1:])) + self.internalHistory.Submit(cmd[0](*cmd[1:])) - 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 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)) + 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 diff --git a/gui/fitCommands/guiModuleToCargo.py b/gui/fitCommands/guiModuleToCargo.py index d53fea0ca..4dbb50285 100644 --- a/gui/fitCommands/guiModuleToCargo.py +++ b/gui/fitCommands/guiModuleToCargo.py @@ -17,13 +17,11 @@ class GuiModuleToCargoCommand(wx.Command): def __init__(self, fitID, moduleIdx, cargoIdx, copy=False): wx.Command.__init__(self, True, "Module to Cargo") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.moduleIdx = moduleIdx self.cargoIdx = cargoIdx self.copy = copy - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): sFit = Fit.getInstance() @@ -33,8 +31,8 @@ class GuiModuleToCargoCommand(wx.Command): if self.cargoIdx: # we're swapping with cargo if self.copy: # if copying, simply add item to cargo - result = self.internal_history.Submit(CalcAddCargoCommand( - self.mainFrame.getActiveFit(), module.item.ID if not module.item.isAbyssal else module.baseItemID)) + result = self.internalHistory.Submit(CalcAddCargoCommand( + gui.mainFrame.MainFrame.getInstance().getActiveFit(), module.item.ID if not module.item.isAbyssal else module.baseItemID)) else: # otherwise, try to swap by replacing module with cargo item. If successful, remove old cargo and add new cargo cargo = fit.cargo[self.cargoIdx] @@ -43,7 +41,7 @@ class GuiModuleToCargoCommand(wx.Command): position=module.modPosition, newModInfo=ModuleInfo(itemID=cargo.itemID)) - result = self.internal_history.Submit(self.modReplaceCmd) + result = self.internalHistory.Submit(self.modReplaceCmd) if not result: # creating module failed for whatever reason @@ -52,27 +50,27 @@ class GuiModuleToCargoCommand(wx.Command): if self.modReplaceCmd.old_module is not None: # we're swapping with an existing module, so remove cargo and add module self.removeCmd = CalcRemoveCargoCommand(self.fitID, cargo.itemID) - result = self.internal_history.Submit(self.removeCmd) + result = self.internalHistory.Submit(self.removeCmd) self.addCargoCmd = CalcAddCargoCommand(self.fitID, self.modReplaceCmd.old_module.itemID) - result = self.internal_history.Submit(self.addCargoCmd) + result = self.internalHistory.Submit(self.addCargoCmd) else: # dragging to blank spot, append - result = self.internal_history.Submit(CalcAddCargoCommand(self.mainFrame.getActiveFit(), + result = self.internalHistory.Submit(CalcAddCargoCommand(gui.mainFrame.MainFrame.getInstance().getActiveFit(), module.item.ID if not module.item.isAbyssal else module.baseItemID)) if not self.copy: # if not copying, remove module - self.internal_history.Submit(CalcRemoveLocalModuleCommand(self.mainFrame.getActiveFit(), [self.moduleIdx])) + self.internalHistory.Submit(CalcRemoveLocalModuleCommand(gui.mainFrame.MainFrame.getInstance().getActiveFit(), [self.moduleIdx])) if result: sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID, action="moddel", typeID=module.item.ID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID, action="moddel", typeID=module.item.ID)) return result 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)) + 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 diff --git a/gui/fitCommands/guiMutaConvert.py b/gui/fitCommands/guiMutaConvert.py index f9419a9ba..167dcb502 100644 --- a/gui/fitCommands/guiMutaConvert.py +++ b/gui/fitCommands/guiMutaConvert.py @@ -11,8 +11,7 @@ class GuiMutaConvertCommand(wx.Command): def __init__(self, fitID, position, mutaplasmid): wx.Command.__init__(self, True, "Convert Item to Mutated") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.position = position self.mutaplasmid = mutaplasmid @@ -26,7 +25,7 @@ class GuiMutaConvertCommand(wx.Command): if oldMod.isMutated: return False - success = self.internal_history.Submit(CalcReplaceLocalModuleCommand( + success = self.internalHistory.Submit(CalcReplaceLocalModuleCommand( fitID=self.fitID, position=self.position, newModInfo=ModuleInfo( @@ -42,12 +41,12 @@ class GuiMutaConvertCommand(wx.Command): return False sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True def Undo(self): - for _ in self.internal_history.Commands: - self.internal_history.Undo() + for _ in self.internalHistory.Commands: + self.internalHistory.Undo() Fit.getInstance().recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True diff --git a/gui/fitCommands/guiMutaRevert.py b/gui/fitCommands/guiMutaRevert.py index c0a88680c..511202d7a 100644 --- a/gui/fitCommands/guiMutaRevert.py +++ b/gui/fitCommands/guiMutaRevert.py @@ -11,8 +11,7 @@ class GuiMutaRevertCommand(wx.Command): def __init__(self, fitID, position): wx.Command.__init__(self, True, "Convert Item to Normal") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.position = position @@ -25,7 +24,7 @@ class GuiMutaRevertCommand(wx.Command): if not oldMod.isMutated: return False - success = self.internal_history.Submit(CalcReplaceLocalModuleCommand( + success = self.internalHistory.Submit(CalcReplaceLocalModuleCommand( fitID=self.fitID, position=self.position, newModInfo=ModuleInfo( @@ -38,12 +37,12 @@ class GuiMutaRevertCommand(wx.Command): return False sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True def Undo(self): - for _ in self.internal_history.Commands: - self.internal_history.Undo() + for _ in self.internalHistory.Commands: + self.internalHistory.Undo() Fit.getInstance().recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True diff --git a/gui/fitCommands/guiRebaseItems.py b/gui/fitCommands/guiRebaseItems.py index a5130b825..7087869b6 100644 --- a/gui/fitCommands/guiRebaseItems.py +++ b/gui/fitCommands/guiRebaseItems.py @@ -17,7 +17,6 @@ class GuiRebaseItemsCommand(wx.Command): def __init__(self, fitID, rebaseMap): wx.Command.__init__(self, True, "Mass Rebase Item") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() self.fitID = fitID self.rebaseMap = rebaseMap self.internalHistory = InternalCommandHistory() @@ -44,7 +43,7 @@ class GuiRebaseItemsCommand(wx.Command): if self.internalHistory: eos.db.commit() Fit.getInstance().recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True else: return False @@ -53,5 +52,5 @@ class GuiRebaseItemsCommand(wx.Command): self.internalHistory.undoAll() eos.db.commit() Fit.getInstance().recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True diff --git a/gui/fitCommands/guiRemoveCargo.py b/gui/fitCommands/guiRemoveCargo.py index ad0a60f16..f5c401b3c 100644 --- a/gui/fitCommands/guiRemoveCargo.py +++ b/gui/fitCommands/guiRemoveCargo.py @@ -12,20 +12,18 @@ from .calcCommands.cargo.remove import CalcRemoveCargoCommand class GuiRemoveCargoCommand(wx.Command): def __init__(self, fitID, itemID): wx.Command.__init__(self, True, "Cargo Remove") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.itemID = itemID def Do(self): - if self.internal_history.Submit(CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))): - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + if self.internalHistory.Submit(CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))): + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True return False def Undo(self): - for _ in self.internal_history.GetCommands(): - self.internal_history.Undo() - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + for _ in self.internalHistory.GetCommands(): + self.internalHistory.Undo() + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True diff --git a/gui/fitCommands/guiRemoveCommand.py b/gui/fitCommands/guiRemoveCommand.py index 65a5b1584..90f43f19b 100644 --- a/gui/fitCommands/guiRemoveCommand.py +++ b/gui/fitCommands/guiRemoveCommand.py @@ -9,22 +9,20 @@ from .calcCommands.commandFit.remove import CalcRemoveCommandCommand class GuiRemoveCommandCommand(wx.Command): def __init__(self, fitID, commandFitID): wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.commandFitID = commandFitID def Do(self): - if self.internal_history.Submit(CalcRemoveCommandCommand(self.fitID, self.commandFitID)): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + if self.internalHistory.Submit(CalcRemoveCommandCommand(self.fitID, self.commandFitID)): + 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.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiRemoveDrone.py b/gui/fitCommands/guiRemoveDrone.py index fcbd53a7c..f18847e51 100644 --- a/gui/fitCommands/guiRemoveDrone.py +++ b/gui/fitCommands/guiRemoveDrone.py @@ -9,24 +9,22 @@ from .calcCommands.drone.localRemove import CalcRemoveLocalDroneCommand class GuiRemoveDroneCommand(wx.Command): def __init__(self, fitID, position, amount=1): wx.Command.__init__(self, True, "Drone Remove") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.position = position self.amount = amount def Do(self): cmd = CalcRemoveLocalDroneCommand(self.fitID, self.position, self.amount) - if self.internal_history.Submit(cmd): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiRemoveFighter.py b/gui/fitCommands/guiRemoveFighter.py index 3b57af0fe..c03393652 100644 --- a/gui/fitCommands/guiRemoveFighter.py +++ b/gui/fitCommands/guiRemoveFighter.py @@ -9,23 +9,21 @@ from .calcCommands.fighter.localRemove import CalcRemoveLocalFighterCommand class GuiRemoveFighterCommand(wx.Command): def __init__(self, fitID, position): wx.Command.__init__(self, True, "Fighter Remove") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.position = position - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): - success = self.internal_history.Submit(CalcRemoveLocalFighterCommand(self.fitID, self.position)) + success = self.internalHistory.Submit(CalcRemoveLocalFighterCommand(self.fitID, self.position)) if success: - 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): - for _ in self.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiRemoveModule.py b/gui/fitCommands/guiRemoveModule.py index 2223300a3..a6cabdb31 100644 --- a/gui/fitCommands/guiRemoveModule.py +++ b/gui/fitCommands/guiRemoveModule.py @@ -16,24 +16,22 @@ class GuiModuleRemoveCommand(wx.Command): :param modules: A list of Module objects that we are attempting to remove. """ wx.Command.__init__(self, True, "Module Remove") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.modCache = {mod.modPosition: ModuleInfo.fromModule(mod) for mod in modules if not mod.isEmpty} - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): - success = self.internal_history.Submit(CalcRemoveLocalModuleCommand(self.fitID, [pos for pos in self.modCache])) + success = self.internalHistory.Submit(CalcRemoveLocalModuleCommand(self.fitID, [pos for pos in self.modCache])) if success: - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID, action="moddel", typeID=set([mod.itemID for mod in self.modCache.values()]))) + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID, action="moddel", typeID=set([mod.itemID for mod in self.modCache.values()]))) 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, action="modadd", typeID=set([mod.itemID for mod in self.modCache.values()]))) + for _ in self.internalHistory.Commands: + self.internalHistory.Undo() + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID, action="modadd", typeID=set([mod.itemID for mod in self.modCache.values()]))) return True diff --git a/gui/fitCommands/guiRemoveProjected.py b/gui/fitCommands/guiRemoveProjected.py index 7b6f9c54c..697ae8b3d 100644 --- a/gui/fitCommands/guiRemoveProjected.py +++ b/gui/fitCommands/guiRemoveProjected.py @@ -27,11 +27,9 @@ class GuiRemoveProjectedCommand(wx.Command): def __init__(self, fitID, thing): wx.Command.__init__(self, True, "Projected Remove") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID - fit = self.sFit.getFit(fitID) + fit = Fit.getInstance().getFit(fitID) if isinstance(thing, Drone): self.data = DroneInfo(itemID=thing.itemID, amount=1, amountActive=1) @@ -55,17 +53,17 @@ class GuiRemoveProjectedCommand(wx.Command): cls = self.mapping.get(self.type, None) if cls: cmd = cls(self.fitID, self.data) - result = self.internal_history.Submit(cmd) + result = self.internalHistory.Submit(cmd) if result: - 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): - for _ in self.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiSetMode.py b/gui/fitCommands/guiSetMode.py index 3be21d626..d361776e6 100644 --- a/gui/fitCommands/guiSetMode.py +++ b/gui/fitCommands/guiSetMode.py @@ -9,22 +9,20 @@ from .calcCommands.shipModeChange import CalcChangeShipModeCommand class GuiSetModeCommand(wx.Command): def __init__(self, fitID, itemID): wx.Command.__init__(self, True, "Mode Set") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.itemID = itemID def Do(self): - if self.internal_history.Submit(CalcChangeShipModeCommand(self.fitID, self.itemID)): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + if self.internalHistory.Submit(CalcChangeShipModeCommand(self.fitID, self.itemID)): + 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.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiSetSpoolup.py b/gui/fitCommands/guiSetSpoolup.py index 843b846a3..157a19b17 100644 --- a/gui/fitCommands/guiSetSpoolup.py +++ b/gui/fitCommands/guiSetSpoolup.py @@ -10,9 +10,7 @@ class GuiSetSpoolup(wx.Command): def __init__(self, fitID, position, spoolType, spoolAmount, context): wx.Command.__init__(self, True, "Booster Add") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.position = position self.spoolType = spoolType @@ -20,21 +18,21 @@ class GuiSetSpoolup(wx.Command): self.context = context def Do(self): - if self.internal_history.Submit(CalcChangeModuleSpoolCommand( + if self.internalHistory.Submit(CalcChangeModuleSpoolCommand( fitID=self.fitID, position=self.position, spoolType=self.spoolType, spoolAmount=self.spoolupAmount, projected=True if self.context == 'projectedModule' else False )): - 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): - for _ in self.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiSwapCloneModule.py b/gui/fitCommands/guiSwapCloneModule.py index 185e585dc..2bff84711 100644 --- a/gui/fitCommands/guiSwapCloneModule.py +++ b/gui/fitCommands/guiSwapCloneModule.py @@ -13,38 +13,36 @@ class GuiModuleSwapOrCloneCommand(wx.Command): def __init__(self, fitID, srcPosition, dstPosition, clone=False): wx.Command.__init__(self, True, "Module State Change") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.srcPosition = srcPosition self.dstPosition = dstPosition self.clone = clone - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): pyfalog.debug("{} Do()".format(self)) if self.clone: pyfalog.debug("Trying to clone module") - if self.internal_history.Submit(CalcCloneLocalModuleCommand(self.fitID, self.srcPosition, self.dstPosition)): - self.sFit.recalc(self.fitID) # clone needs a recalc - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + if self.internalHistory.Submit(CalcCloneLocalModuleCommand(self.fitID, self.srcPosition, self.dstPosition)): + Fit.getInstance().recalc(self.fitID) # clone needs a recalc + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True else: pyfalog.debug("Trying to Swap module") - if self.internal_history.Submit(CalcSwapLocalModuleCommand(self.fitID, self.srcPosition, self.dstPosition)): - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + if self.internalHistory.Submit(CalcSwapLocalModuleCommand(self.fitID, self.srcPosition, self.dstPosition)): + 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.internal_history.Commands: - self.internal_history.Undo() + for _ in self.internalHistory.Commands: + self.internalHistory.Undo() if self.clone: - self.sFit.recalc(self.fitID) + Fit.getInstance().recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True diff --git a/gui/fitCommands/guiToggleCommand.py b/gui/fitCommands/guiToggleCommand.py index 964b3ddda..1013f6506 100644 --- a/gui/fitCommands/guiToggleCommand.py +++ b/gui/fitCommands/guiToggleCommand.py @@ -9,22 +9,20 @@ from .calcCommands.commandFit.toggleState import CalcToggleCommandFitStateComman class GuiToggleCommandCommand(wx.Command): def __init__(self, fitID, commandFitID): wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.commandFitID = commandFitID def Do(self): - if self.internal_history.Submit(CalcToggleCommandFitStateCommand(self.fitID, self.commandFitID)): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + if self.internalHistory.Submit(CalcToggleCommandFitStateCommand(self.fitID, self.commandFitID)): + 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.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiToggleDrone.py b/gui/fitCommands/guiToggleDrone.py index f055a12e2..a86b8d4fe 100644 --- a/gui/fitCommands/guiToggleDrone.py +++ b/gui/fitCommands/guiToggleDrone.py @@ -9,22 +9,20 @@ from .calcCommands.drone.localToggleState import CalcToggleLocalDroneStateComman class GuiToggleDroneCommand(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.internalHistory = wx.CommandProcessor() self.fitID = fitID self.position = position def Do(self): - if self.internal_history.Submit(CalcToggleLocalDroneStateCommand(self.fitID, self.position)): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + if self.internalHistory.Submit(CalcToggleLocalDroneStateCommand(self.fitID, 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): - for _ in self.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiToggleFighter.py b/gui/fitCommands/guiToggleFighter.py index 0aa32d83b..7c7061dc3 100644 --- a/gui/fitCommands/guiToggleFighter.py +++ b/gui/fitCommands/guiToggleFighter.py @@ -9,22 +9,20 @@ from .calcCommands.fighter.toggleState import CalcToggleFighterStateCommand class GuiToggleFighterCommand(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.internalHistory = wx.CommandProcessor() self.fitID = fitID self.position = position def Do(self): - if self.internal_history.Submit(CalcToggleFighterStateCommand(self.fitID, False, self.position)): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + if self.internalHistory.Submit(CalcToggleFighterStateCommand(self.fitID, False, 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): - for _ in self.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiToggleFighterAbility.py b/gui/fitCommands/guiToggleFighterAbility.py index f9419d755..d0c52220b 100644 --- a/gui/fitCommands/guiToggleFighterAbility.py +++ b/gui/fitCommands/guiToggleFighterAbility.py @@ -10,23 +10,22 @@ class GuiToggleFighterAbilityCommand(wx.Command): def __init__(self, fitID, position, effectID, isProjected): wx.Command.__init__(self, True, "") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.position = position self.effectID = effectID self.isProjected = isProjected def Do(self): - if self.internal_history.Submit(CalcToggleFighterAbilityStateCommand(self.fitID, self.isProjected, self.position, self.effectID)): + if self.internalHistory.Submit(CalcToggleFighterAbilityStateCommand(self.fitID, self.isProjected, self.position, self.effectID)): Fit.getInstance().recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True return False def Undo(self): - for _ in self.internal_history.Commands: - self.internal_history.Undo() + for _ in self.internalHistory.Commands: + self.internalHistory.Undo() Fit.getInstance().recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True diff --git a/gui/fitCommands/guiToggleModuleState.py b/gui/fitCommands/guiToggleModuleState.py index c4524205a..14dbfd49f 100644 --- a/gui/fitCommands/guiToggleModuleState.py +++ b/gui/fitCommands/guiToggleModuleState.py @@ -10,24 +10,22 @@ class GuiModuleStateChangeCommand(wx.Command): def __init__(self, fitID, baseMod, modules, click): # todo: instead of modules, needs to be positions. Dead objects are a thing wx.Command.__init__(self, True, "Module State Change") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.sFit = Fit.getInstance() self.fitID = fitID self.baseMod = baseMod self.modules = modules self.click = click - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() def Do(self): - if self.internal_history.Submit(CalcChangeLocalModuleStatesCommand(self.fitID, self.baseMod, self.modules, self.click)): - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + if self.internalHistory.Submit(CalcChangeLocalModuleStatesCommand(self.fitID, self.baseMod, self.modules, self.click)): + 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.internal_history.Commands: - self.internal_history.Undo() - self.sFit.recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + 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 diff --git a/gui/fitCommands/guiToggleProjected.py b/gui/fitCommands/guiToggleProjected.py index 013d78ae8..e4bbc14fd 100644 --- a/gui/fitCommands/guiToggleProjected.py +++ b/gui/fitCommands/guiToggleProjected.py @@ -17,8 +17,7 @@ class GuiToggleProjectedCommand(wx.Command): def __init__(self, fitID, thing, click): wx.Command.__init__(self, True, "Toggle Projected Item") - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.internal_history = wx.CommandProcessor() + self.internalHistory = wx.CommandProcessor() self.fitID = fitID fit = Fit.getInstance().getFit(self.fitID) if isinstance(thing, FitType): @@ -42,15 +41,15 @@ class GuiToggleProjectedCommand(wx.Command): def Do(self): if self.commandType is None: return False - if not self.internal_history.Submit(self.commandType(*self.args)): + if not self.internalHistory.Submit(self.commandType(*self.args)): return False Fit.getInstance().recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True def Undo(self): - for _ in self.internal_history.Commands: - self.internal_history.Undo() + for _ in self.internalHistory.Commands: + self.internalHistory.Undo() Fit.getInstance().recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True diff --git a/gui/fitCommands/implant/remove.py b/gui/fitCommands/implant/remove.py index abc1e33f9..e8b5a35ad 100644 --- a/gui/fitCommands/implant/remove.py +++ b/gui/fitCommands/implant/remove.py @@ -11,7 +11,6 @@ class GuiRemoveImplantCommand(wx.Command): def __init__(self, fitID, position): wx.Command.__init__(self, True, 'Remove Implant') - self.mainFrame = gui.mainFrame.MainFrame.getInstance() self.internalHistory = InternalCommandHistory() self.fitID = fitID self.position = position @@ -19,12 +18,12 @@ class GuiRemoveImplantCommand(wx.Command): def Do(self): if self.internalHistory.submit(CalcRemoveImplantCommand(fitID=self.fitID, position=self.position)): Fit.getInstance().recalc(self.fitID) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=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(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return success