diff --git a/gui/fitCommands/calc/fitAddImplant.py b/gui/fitCommands/calc/fitAddImplant.py index 3ebbfab24..65294fede 100644 --- a/gui/fitCommands/calc/fitAddImplant.py +++ b/gui/fitCommands/calc/fitAddImplant.py @@ -43,8 +43,7 @@ class FitAddImplantCommand(wx.Command): if self.oldItemID: # If we had an item in the slot previously, add it back. cmd = FitAddImplantCommand(self.fitID, self.oldItemID, self.oldState) - cmd.Do() - return True + return cmd.Do() from .fitRemoveImplant import FitRemoveImplantCommand # Avoid circular import cmd = FitRemoveImplantCommand(self.fitID, self.newIndex) diff --git a/gui/fitCommands/calc/fitAddProjectedEnv.py b/gui/fitCommands/calc/fitAddProjectedEnv.py deleted file mode 100644 index 87d1bd890..000000000 --- a/gui/fitCommands/calc/fitAddProjectedEnv.py +++ /dev/null @@ -1,52 +0,0 @@ -import wx -from eos.saveddata.module import Module -from eos.const import FittingModuleState -import eos.db -from logbook import Logger -pyfalog = Logger(__name__) - - -class FitAddProjectedEnvCommand(wx.Command): - """" - from sFit.project - """ - def __init__(self, fitID, itemID): - wx.Command.__init__(self, True) - self.fitID = fitID - self.itemID = itemID - self.new_index = None - self.old_item = None - - def Do(self): - pyfalog.debug("Projecting fit ({0}) onto: {1}", self.fitID, self.itemID) - fit = eos.db.getFit(self.fitID) - item = eos.db.getItem(self.itemID, eager=("attributes", "group.category")) - - try: - module = Module(item) - except ValueError: - return False - - # todo: thing to check for existing environmental effects - - module.state = FittingModuleState.ONLINE - if module.isExclusiveSystemEffect: - # if this is an exclusive system effect, we need to cache the old one. We make room for the new one here, which returns the old one - self.old_item = fit.projectedModules.makeRoom(module) - - fit.projectedModules.append(module) - eos.db.commit() - self.new_index = fit.projectedModules.index(module) - return True - - def Undo(self): - if self.old_item: - # If we had an item in the slot previously, add it back. - cmd = FitAddProjectedEnvCommand(self.fitID, self.old_item) - cmd.Do() - return True - from gui.fitCommands.calc.fitRemoveProjectedEnv import FitRemoveProjectedEnvCommand # avoids circular import - cmd = FitRemoveProjectedEnvCommand(self.fitID, self.itemID) - cmd.Do() - - return True diff --git a/gui/fitCommands/calc/fitAddProjectedModule.py b/gui/fitCommands/calc/fitAddProjectedModule.py index d75aafc4b..159553b23 100644 --- a/gui/fitCommands/calc/fitAddProjectedModule.py +++ b/gui/fitCommands/calc/fitAddProjectedModule.py @@ -52,6 +52,17 @@ class FitAddProjectedModuleCommand(wx.Command): return True def Undo(self): + if self.oldModuleInfo is not None: + cmd = FitAddProjectedModuleCommand( + fitID=self.fitID, + newItemID=self.oldModuleInfo.itemID, + newBaseItemID=self.oldModuleInfo.baseID, + newMutaplasmidID=self.oldModuleInfo.mutaplasmidID, + newMutations=self.oldModuleInfo.mutations, + newState=self.oldModuleInfo.state, + newChargeID=self.oldModuleInfo.chargeID, + newPosition=self.oldModuleInfo.modPosition) + return cmd.Do() from gui.fitCommands.calc.fitRemoveProjectedModule import FitRemoveProjectedModuleCommand # avoids circular import cmd = FitRemoveProjectedModuleCommand(self.fitID, self.newPosition) cmd.Do() diff --git a/gui/fitCommands/calc/fitRemoveProjectedEnv.py b/gui/fitCommands/calc/fitRemoveProjectedEnv.py deleted file mode 100644 index 61b6ee939..000000000 --- a/gui/fitCommands/calc/fitRemoveProjectedEnv.py +++ /dev/null @@ -1,35 +0,0 @@ -import wx -import eos.db -from logbook import Logger -from .fitRemoveProjectedModule import FitRemoveProjectedModuleCommand -pyfalog = Logger(__name__) - - -# this has the same exact definition that regular rpojected modules, besides the undo -class FitRemoveProjectedEnvCommand(FitRemoveProjectedModuleCommand): - """" - from sFit.project - """ - - def __init__(self, fitID, itemID): - wx.Command.__init__(self, True) - self.fitID = fitID - self.itemID = itemID - self.removed_item = None - - def Do(self): - pyfalog.debug("Removing ({0}) onto: {1}", self.fitID, self.itemID) - fit = eos.db.getFit(self.fitID) - - item = next((x for x in fit.projectedModules if x.itemID == self.itemID), None) - self.removed_item = item.itemID - fit.projectedModules.remove(item) - - eos.db.commit() - return True - - def Undo(self): - from gui.fitCommands.calc.fitAddProjectedEnv import FitAddProjectedEnvCommand - cmd = FitAddProjectedEnvCommand(self.fitID, self.removed_item) - cmd.Do() - return True diff --git a/gui/fitCommands/guiAddProjected.py b/gui/fitCommands/guiAddProjected.py index 03de7e8c9..21afb7dc9 100644 --- a/gui/fitCommands/guiAddProjected.py +++ b/gui/fitCommands/guiAddProjected.py @@ -5,7 +5,6 @@ import gui.mainFrame from gui import globalEvents as GE from eos.saveddata.module import Module from .calc.fitAddProjectedModule import FitAddProjectedModuleCommand -from .calc.fitAddProjectedEnv import FitAddProjectedEnvCommand from .calc.fitAddProjectedFit import FitAddProjectedFitCommand from .calc.fitAddProjectedFighter import FitAddProjectedFighterCommand from .calc.fitAddProjectedDrone import FitAddProjectedDroneCommand @@ -35,8 +34,6 @@ class GuiAddProjectedCommand(wx.Command): result = self.internal_history.Submit(FitAddProjectedDroneCommand(self.fitID, self.id)) elif item.category.name == "Fighter": result = self.internal_history.Submit(FitAddProjectedFighterCommand(self.fitID, self.id)) - elif item.group.name in Module.SYSTEM_GROUPS: - result = self.internal_history.Submit(FitAddProjectedEnvCommand(self.fitID, self.id)) else: result = self.internal_history.Submit(FitAddProjectedModuleCommand(self.fitID, self.id, None, None, None, None, None, None)) elif self.type == 'fit': diff --git a/gui/fitCommands/guiRemoveProjected.py b/gui/fitCommands/guiRemoveProjected.py index 0a5c3bad8..262d7a88d 100644 --- a/gui/fitCommands/guiRemoveProjected.py +++ b/gui/fitCommands/guiRemoveProjected.py @@ -4,7 +4,6 @@ from service.fit import Fit import gui.mainFrame from gui import globalEvents as GE from .calc.fitRemoveProjectedModule import FitRemoveProjectedModuleCommand -from .calc.fitRemoveProjectedEnv import FitRemoveProjectedEnvCommand from .calc.fitRemoveProjectedFit import FitRemoveProjectedFitCommand from .calc.fitRemoveProjectedFighter import FitRemoveProjectedFighterCommand from logbook import Logger @@ -22,7 +21,6 @@ class GuiRemoveProjectedCommand(wx.Command): 'fit': FitRemoveProjectedFitCommand, 'module': FitRemoveProjectedModuleCommand, 'fighter': FitRemoveProjectedFighterCommand, - 'env': FitRemoveProjectedEnvCommand, 'drone': FitRemoveProjectedDroneCommand } @@ -38,13 +36,8 @@ class GuiRemoveProjectedCommand(wx.Command): self.data = fit.projectedDrones.index(thing) self.type = 'drone' elif isinstance(thing, Module): - # todo: projected stuff should be wrapped in a projected class wrapper for easier maintainence - if thing.item.group.name in Module.SYSTEM_GROUPS: - self.type = 'env' - self.data = thing.itemID - else: - self.type = 'module' - self.data = fit.projectedModules.index(thing) + self.type = 'module' + self.data = fit.projectedModules.index(thing) elif isinstance(thing, Fighter): self.data = fit.projectedFighters.index(thing) self.type = 'fighter'