Do not store fit service and main frame on every command

This commit is contained in:
DarkPhoenix
2019-04-14 15:44:48 +03:00
parent a829efa7ff
commit d61d69188f
36 changed files with 272 additions and 336 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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