diff --git a/gui/builtinAdditionPanes/projectedView.py b/gui/builtinAdditionPanes/projectedView.py index fa3ba4b9d..bbb3ea6b2 100644 --- a/gui/builtinAdditionPanes/projectedView.py +++ b/gui/builtinAdditionPanes/projectedView.py @@ -247,25 +247,11 @@ class ProjectedView(d.Display): if col == self.getColIndex(State): fitID = self.mainFrame.getActiveFit() thing = self.get(row) - button = event.GetButton() - if isinstance(thing, es_Fit) and button != 3: - self.mainFrame.command.Submit(cmd.GuiToggleProjectedFitStateCommand( - fitID=fitID, projectedFitID=thing.ID)) - elif isinstance(thing, es_Module): - fit = Fit.getInstance().getFit(fitID) - if thing in fit.projectedModules: - position = fit.projectedModules.index(thing) - self.mainFrame.command.Submit(cmd.GuiChangeProjectedModuleStateCommand( - fitID=fitID, position=position, click='right' if button == 3 else 'left')) - elif isinstance(thing, es_Drone) and button != 3: - self.mainFrame.command.Submit(cmd.GuiToggleProjectedDroneStateCommand( - fitID=fitID, itemID=thing.itemID)) - elif isinstance(thing, es_Fighter) and button != 3: - fit = Fit.getInstance().getFit(fitID) - if thing in fit.projectedFighters: - position = fit.projectedFighters.index(thing) - self.mainFrame.command.Submit(cmd.GuiToggleProjectedFighterStatesCommand( - fitID=fitID, mainPosition=position, positions=[position])) + self.mainFrame.command.Submit(cmd.GuiChangeProjectedItemStatesCommand( + fitID=fitID, + mainItem=thing, + items=[thing], + click='right' if event.GetButton() == 3 else 'left')) def spawnMenu(self, event): fitID = self.mainFrame.getActiveFit() diff --git a/gui/fitCommands/__init__.py b/gui/fitCommands/__init__.py index 6e7950d52..09906283c 100644 --- a/gui/fitCommands/__init__.py +++ b/gui/fitCommands/__init__.py @@ -47,22 +47,19 @@ from .gui.localModule.replace import GuiReplaceLocalModuleCommand from .gui.localModule.swap import GuiSwapLocalModulesCommand from .gui.localModuleCargo.cargoToLocalModule import GuiCargoToLocalModuleCommand from .gui.localModuleCargo.localModuleToCargo import GuiLocalModuleToCargoCommand +from .gui.projectedChangeStates import GuiChangeProjectedItemStatesCommand from .gui.projectedDrone.add import GuiAddProjectedDroneCommand from .gui.projectedDrone.changeAmount import GuiChangeProjectedDroneAmountCommand from .gui.projectedDrone.changeMeta import GuiChangeProjectedDroneMetaCommand -from .gui.projectedDrone.toggleState import GuiToggleProjectedDroneStateCommand from .gui.projectedFighter.abilityToggleState import GuiToggleProjectedFighterAbilityStateCommand from .gui.projectedFighter.add import GuiAddProjectedFighterCommand from .gui.projectedFighter.changeAmount import GuiChangeProjectedFighterAmountCommand from .gui.projectedFighter.changeMeta import GuiChangeProjectedFighterMetaCommand -from .gui.projectedFighter.toggleStates import GuiToggleProjectedFighterStatesCommand from .gui.projectedFit.add import GuiAddProjectedFitCommand from .gui.projectedFit.changeAmount import GuiChangeProjectedFitAmountCommand -from .gui.projectedFit.toggleState import GuiToggleProjectedFitStateCommand from .gui.projectedModule.add import GuiAddProjectedModuleCommand from .gui.projectedModule.changeCharges import GuiChangeProjectedModuleChargesCommand from .gui.projectedModule.changeMeta import GuiChangeProjectedModuleMetaCommand from .gui.projectedModule.changeSpool import GuiChangeProjectedModuleSpoolCommand -from .gui.projectedModule.changeState import GuiChangeProjectedModuleStateCommand from .gui.projectedRemove import GuiRemoveProjectedItemsCommand from .gui.shipModeChange import GuiChangeShipModeCommand diff --git a/gui/fitCommands/calc/drone/projectedChangeState.py b/gui/fitCommands/calc/drone/projectedChangeState.py new file mode 100644 index 000000000..67433f0d8 --- /dev/null +++ b/gui/fitCommands/calc/drone/projectedChangeState.py @@ -0,0 +1,53 @@ +import wx +from logbook import Logger + +import eos.db +from service.fit import Fit + + +pyfalog = Logger(__name__) + + +class CalcChangeProjectedDroneStateCommand(wx.Command): + + def __init__(self, fitID, itemID, state, commit=True): + wx.Command.__init__(self, True, 'Change Projected Drone State') + self.fitID = fitID + self.itemID = itemID + self.state = state + self.commit = commit + self.savedState = None + + def Do(self): + pyfalog.debug('Doing changing of projected drone {} state to {} for fit {}'.format(self.itemID, self.state, self.fitID)) + fit = Fit.getInstance().getFit(self.fitID) + + drone = next((pd for pd in fit.projectedDrones if pd.itemID == self.itemID), None) + if drone is None: + pyfalog.warning('Unable to find projected drone') + return False + self.savedState = drone.amountActive > 0 + + if self.state == self.savedState: + return False + + if self.state: + if not drone.canBeApplied(fit): + pyfalog.warning('Projected drone cannot be applied') + return False + drone.amountActive = drone.amount + else: + drone.amountActive = 0 + + if self.commit: + eos.db.commit() + return True + + def Undo(self): + pyfalog.debug('Undoing changing of projected drone {} state to {} for fit {}'.format(self.itemID, self.state, self.fitID)) + cmd = CalcChangeProjectedDroneStateCommand( + fitID=self.fitID, + itemID=self.itemID, + state=self.savedState, + commit=self.commit) + return cmd.Do() diff --git a/gui/fitCommands/calc/drone/projectedToggleState.py b/gui/fitCommands/calc/drone/projectedToggleState.py deleted file mode 100644 index 0e10e08a1..000000000 --- a/gui/fitCommands/calc/drone/projectedToggleState.py +++ /dev/null @@ -1,49 +0,0 @@ -import wx -from logbook import Logger - -import eos.db -from service.fit import Fit - - -pyfalog = Logger(__name__) - - -class CalcToggleProjectedDroneStateCommand(wx.Command): - - def __init__(self, fitID, itemID, forceAmountActive=None): - wx.Command.__init__(self, True, 'Toggle Projected Drone State') - self.fitID = fitID - self.itemID = itemID - self.forceAmountActive = forceAmountActive - self.savedAmountActive = None - - def Do(self): - pyfalog.debug('Doing toggling of projected drone {} state for fit {}'.format(self.itemID, self.fitID)) - fit = Fit.getInstance().getFit(self.fitID) - drone = next((pd for pd in fit.projectedDrones if pd.itemID == self.itemID), None) - if drone is None: - pyfalog.warning('Unable to find projected drone') - return False - self.savedAmountActive = drone.amountActive - if self.forceAmountActive is not None: - if self.forceAmountActive > 0 and not drone.canBeApplied(fit): - pyfalog.warning('Projected drone cannot be applied') - return False - drone.amountActive = self.forceAmountActive - elif drone.amountActive > 0: - drone.amountActive = 0 - else: - if not drone.canBeApplied(fit): - pyfalog.warning('Projected drone cannot be applied') - return False - drone.amountActive = drone.amount - eos.db.commit() - return True - - def Undo(self): - pyfalog.debug('Undoing toggling of projected drone {} state for fit {}'.format(self.itemID, self.fitID)) - cmd = CalcToggleProjectedDroneStateCommand( - fitID=self.fitID, - itemID=self.itemID, - forceAmountActive=self.savedAmountActive) - return cmd.Do() diff --git a/gui/fitCommands/calc/fighter/toggleStates.py b/gui/fitCommands/calc/fighter/localToggleStates.py similarity index 54% rename from gui/fitCommands/calc/fighter/toggleStates.py rename to gui/fitCommands/calc/fighter/localToggleStates.py index aa7ab8f3d..57c7df996 100644 --- a/gui/fitCommands/calc/fighter/toggleStates.py +++ b/gui/fitCommands/calc/fighter/localToggleStates.py @@ -8,49 +8,48 @@ from service.fit import Fit pyfalog = Logger(__name__) -class CalcToggleFighterStatesCommand(wx.Command): +class CalcToggleLocalFighterStatesCommand(wx.Command): - def __init__(self, fitID, projected, mainPosition, positions, forceStates=None): - wx.Command.__init__(self, True, 'Toggle Fighter States') + def __init__(self, fitID, mainPosition, positions, forceStates=None): + wx.Command.__init__(self, True, 'Toggle Local Fighter States') self.fitID = fitID - self.projected = projected self.mainPosition = mainPosition self.positions = positions self.forceStates = forceStates self.savedStates = None def Do(self): - pyfalog.debug('Doing toggling of fighter state at position {}/{} for fit {}'.format(self.mainPosition, self.positions, self.fitID)) + pyfalog.debug('Doing toggling of local fighter state at position {}/{} for fit {}'.format( + self.mainPosition, self.positions, self.fitID)) fit = Fit.getInstance().getFit(self.fitID) - container = fit.projectedFighters if self.projected else fit.fighters positions = self.positions[:] if self.mainPosition not in positions: positions.append(self.mainPosition) - self.savedStates = {p: container[p].active for p in positions} + self.savedStates = {p: fit.fighters[p].active for p in positions} if self.forceStates is not None: for position, state in self.forceStates.items(): - fighter = container[position] + fighter = fit.fighters[position] fighter.active = state - elif container[self.mainPosition].active: + elif fit.fighters[self.mainPosition].active: for position in positions: - fighter = container[position] + fighter = fit.fighters[position] if fighter.active: fighter.active = False else: for position in positions: - fighter = container[position] + fighter = fit.fighters[position] if not fighter.active: fighter.active = True eos.db.commit() return True def Undo(self): - pyfalog.debug('Undoing toggling of fighter state at position {}/{} for fit {}'.format(self.mainPosition, self.positions, self.fitID)) - cmd = CalcToggleFighterStatesCommand( + pyfalog.debug('Undoing toggling of local fighter state at position {}/{} for fit {}'.format( + self.mainPosition, self.positions, self.fitID)) + cmd = CalcToggleLocalFighterStatesCommand( fitID=self.fitID, - projected=self.projected, mainPosition=self.mainPosition, positions=self.positions, forceStates=self.savedStates) diff --git a/gui/fitCommands/calc/fighter/projectedChangeState.py b/gui/fitCommands/calc/fighter/projectedChangeState.py new file mode 100644 index 000000000..65765db6d --- /dev/null +++ b/gui/fitCommands/calc/fighter/projectedChangeState.py @@ -0,0 +1,46 @@ +import wx +from logbook import Logger + +import eos.db +from service.fit import Fit + + +pyfalog = Logger(__name__) + + +class CalcChangeProjectedFighterStateCommand(wx.Command): + + def __init__(self, fitID, position, state, commit=True): + wx.Command.__init__(self, True, 'Change Projected Fighter State') + self.fitID = fitID + self.position = position + self.state = state + self.commit = commit + self.savedState = None + + def Do(self): + pyfalog.debug('Doing changing of projected fighter state to {} at position {} for fit {}'.format( + self.state, self.position, self.fitID)) + + fit = Fit.getInstance().getFit(self.fitID) + fighter = fit.projectedFighters[self.position] + self.savedState = fighter.active + + if self.state == self.savedState: + return False + + fighter.active = self.state + + if self.commit: + eos.db.commit() + return True + + def Undo(self): + pyfalog.debug('Undoing changing of projected fighter state to {} at position {} for fit {}'.format( + self.state, self.position, self.fitID)) + cmd = CalcChangeProjectedFighterStateCommand( + fitID=self.fitID, + position=self.position, + state=self.savedState, + commit=self.commit) + return cmd.Do() diff --git a/gui/fitCommands/calc/module/projectedChangeState.py b/gui/fitCommands/calc/module/projectedChangeState.py deleted file mode 100644 index a2431e3d8..000000000 --- a/gui/fitCommands/calc/module/projectedChangeState.py +++ /dev/null @@ -1,39 +0,0 @@ -import wx -from logbook import Logger - -import eos.db -from service.fit import Fit - - -pyfalog = Logger(__name__) - - -class CalcChangeProjectedModuleStateCommand(wx.Command): - - def __init__(self, fitID, position, click): - wx.Command.__init__(self, True, 'Change Projected Module State') - self.fitID = fitID - self.position = position - self.click = click - self.savedState = None - - def Do(self): - pyfalog.debug('Doing change of projected module state at position {} to click {} on fit {}'.format(self.position, self.click, self.fitID)) - fit = Fit.getInstance().getFit(self.fitID) - mod = fit.projectedModules[self.position] - self.savedState = mod.state - proposedState = mod.getProposedState(mod, self.click) - if mod.state == proposedState: - return False - if not mod.canHaveState(proposedState, fit): - return False - mod.state = proposedState - eos.db.commit() - return True - - def Undo(self): - pyfalog.debug('Undoing change of projected module state at position {} to click {} on fit {}'.format(self.position, self.click, self.fitID)) - fit = Fit.getInstance().getFit(self.fitID) - mod = fit.projectedModules[self.position] - mod.state = self.savedState - return True diff --git a/gui/fitCommands/calc/module/projectedChangeStates.py b/gui/fitCommands/calc/module/projectedChangeStates.py new file mode 100644 index 000000000..1f7a19571 --- /dev/null +++ b/gui/fitCommands/calc/module/projectedChangeStates.py @@ -0,0 +1,68 @@ +import wx +from logbook import Logger + +import eos.db +from eos.saveddata.module import Module +from gui.fitCommands.helpers import restoreCheckedStates +from eos.const import FittingModuleState +from service.fit import Fit + + +pyfalog = Logger(__name__) + + +STATE_MAP = { + 'inactive': FittingModuleState.OFFLINE, + 'active': FittingModuleState.ACTIVE, + 'overheat': FittingModuleState.OVERHEATED} + + +class CalcChangeProjectedModuleStatesCommand(wx.Command): + + def __init__(self, fitID, positions, proposedState, commit=True): + wx.Command.__init__(self, True, 'Change Projected Module States') + self.fitID = fitID + self.positions = positions + self.proposedState = STATE_MAP[proposedState] + self.commit = commit + self.savedStates = {} + self.savedStateCheckChanges = None + + def Do(self): + pyfalog.debug('Doing change of projected module state at positions {} to state {} on fit {}'.format( + self.positions, self.proposedState, self.fitID)) + sFit = Fit.getInstance() + fit = sFit.getFit(self.fitID) + self.savedStates = {pos: fit.projectedModules[pos].state for pos in self.positions} + + changed = False + for position in self.positions: + mod = fit.projectedModules[position] + proposedState = Module.getProposedState(mod, None, self.proposedState) + if proposedState != mod.state: + pyfalog.debug('Toggle projected {} state: {} for fit ID: {}'.format(mod, proposedState, self.fitID)) + mod.state = proposedState + changed = True + if not changed: + return False + # Need to flush because checkStates sometimes relies on module->fit + # relationship via .owner attribute, which is handled by SQLAlchemy + eos.db.flush() + sFit.recalc(fit) + self.savedStateCheckChanges = sFit.checkStates(fit, None) + if self.commit: + eos.db.commit() + return True + + def Undo(self): + pyfalog.debug('Undoing change of projected module state at positions {} to state {} on fit {}'.format( + self.positions, self.proposedState, self.fitID)) + fit = Fit.getInstance().getFit(self.fitID) + for position, state in self.savedStates.items(): + mod = fit.projectedModules[position] + pyfalog.debug('Reverting projected {} to state {} for fit ID {}'.format(mod, state, self.fitID)) + mod.state = state + restoreCheckedStates(fit, self.savedStateCheckChanges) + if self.commit: + eos.db.commit() + return True diff --git a/gui/fitCommands/calc/projectedFit/changeState.py b/gui/fitCommands/calc/projectedFit/changeState.py new file mode 100644 index 000000000..ae24fac78 --- /dev/null +++ b/gui/fitCommands/calc/projectedFit/changeState.py @@ -0,0 +1,52 @@ +import wx +from logbook import Logger + +import eos.db +from service.fit import Fit + + +pyfalog = Logger(__name__) + + +class CalcChangeProjectedFitStateCommand(wx.Command): + + def __init__(self, fitID, projectedFitID, state, commit=True): + wx.Command.__init__(self, True, 'Change Projected Fit State') + self.fitID = fitID + self.projectedFitID = projectedFitID + self.state = state + self.commit = commit + self.savedState = None + + def Do(self): + pyfalog.debug('Doing changing of projected fit {} state to {} for fit {}'.format( + self.projectedFitID, self.state, self.fitID)) + projectedFit = Fit.getInstance().getFit(self.projectedFitID, projected=True) + # Projected fit could have been deleted if we are redoing + if projectedFit is None: + pyfalog.debug('Projected fit is not available') + return False + projectionInfo = projectedFit.getProjectionInfo(self.fitID) + if projectionInfo is None: + pyfalog.warning('Fit projection info is not available') + return False + self.savedState = projectionInfo.active + + if self.state == self.savedState: + return False + + projectionInfo.active = self.state + + if self.commit: + eos.db.commit() + return True + + def Undo(self): + pyfalog.debug('Undoing changing of projected fit {} state to {} for fit {}'.format( + self.projectedFitID, self.state, self.fitID)) + cmd = CalcChangeProjectedFitStateCommand( + fitID=self.fitID, + projectedFitID=self.projectedFitID, + state=self.savedState, + commit=self.commit) + return cmd.Do() diff --git a/gui/fitCommands/calc/projectedFit/toggleState.py b/gui/fitCommands/calc/projectedFit/toggleState.py deleted file mode 100644 index 0eeb62d26..000000000 --- a/gui/fitCommands/calc/projectedFit/toggleState.py +++ /dev/null @@ -1,39 +0,0 @@ -import wx -from logbook import Logger - -import eos.db -from service.fit import Fit - - -pyfalog = Logger(__name__) - - -class CalcToggleProjectedFitCommand(wx.Command): - - def __init__(self, fitID, projectedFitID, forceState=None): - wx.Command.__init__(self, True, 'Toggle Projected Fit State') - self.fitID = fitID - self.projectedFitID = projectedFitID - self.forceState = forceState - self.savedState = None - - def Do(self): - pyfalog.debug('Doing toggling of projected fit {} state for fit {}'.format(self.projectedFitID, self.fitID)) - projectedFit = Fit.getInstance().getFit(self.projectedFitID, projected=True) - # Projected fit could have been deleted if we are redoing - if projectedFit is None: - pyfalog.debug('Projected fit is not available') - return False - projectionInfo = projectedFit.getProjectionInfo(self.fitID) - if projectionInfo is None: - pyfalog.warning('Fit projection info is not available') - return False - self.savedState = projectionInfo.active - projectionInfo.active = not projectionInfo.active if self.forceState is None else self.forceState - eos.db.commit() - return True - - def Undo(self): - pyfalog.debug('Undoing toggling of projected fit {} state for fit {}'.format(self.projectedFitID, self.fitID)) - cmd = CalcToggleProjectedFitCommand(fitID=self.fitID, projectedFitID=self.projectedFitID, forceState=self.savedState) - return cmd.Do() diff --git a/gui/fitCommands/gui/localFighter/toggleStates.py b/gui/fitCommands/gui/localFighter/toggleStates.py index 8bade72ee..887ecf5d6 100644 --- a/gui/fitCommands/gui/localFighter/toggleStates.py +++ b/gui/fitCommands/gui/localFighter/toggleStates.py @@ -2,7 +2,7 @@ import wx import gui.mainFrame from gui import globalEvents as GE -from gui.fitCommands.calc.fighter.toggleStates import CalcToggleFighterStatesCommand +from gui.fitCommands.calc.fighter.localToggleStates import CalcToggleLocalFighterStatesCommand from gui.fitCommands.helpers import InternalCommandHistory from service.fit import Fit @@ -17,9 +17,8 @@ class GuiToggleLocalFighterStatesCommand(wx.Command): self.positions = positions def Do(self): - cmd = CalcToggleFighterStatesCommand( + cmd = CalcToggleLocalFighterStatesCommand( fitID=self.fitID, - projected=False, mainPosition=self.mainPosition, positions=self.positions) success = self.internalHistory.submit(cmd) diff --git a/gui/fitCommands/gui/projectedChangeStates.py b/gui/fitCommands/gui/projectedChangeStates.py new file mode 100644 index 000000000..f3d2fced6 --- /dev/null +++ b/gui/fitCommands/gui/projectedChangeStates.py @@ -0,0 +1,100 @@ +import wx + +import eos.db +import gui.mainFrame +from eos.const import FittingModuleState +from eos.saveddata.drone import Drone as EosDrone +from eos.saveddata.fighter import Fighter as EosFighter +from eos.saveddata.fit import Fit as EosFit +from eos.saveddata.module import Module as EosModule +from gui import globalEvents as GE +from gui.fitCommands.calc.drone.projectedChangeState import CalcChangeProjectedDroneStateCommand +from gui.fitCommands.calc.fighter.projectedChangeState import CalcChangeProjectedFighterStateCommand +from gui.fitCommands.calc.module.projectedChangeStates import CalcChangeProjectedModuleStatesCommand +from gui.fitCommands.calc.projectedFit.changeState import CalcChangeProjectedFitStateCommand +from gui.fitCommands.helpers import InternalCommandHistory +from service.fit import Fit + + +class GuiChangeProjectedItemStatesCommand(wx.Command): + + def __init__(self, fitID, mainItem, items, click): + wx.Command.__init__(self, True, 'Change Projected Item States') + self.internalHistory = InternalCommandHistory() + self.fitID = fitID + self.pModPositions = [] + self.pDroneItemIDs = [] + self.pFighterPositions = [] + self.pFitIDs = [] + fit = Fit.getInstance().getFit(fitID) + for item in items: + if isinstance(item, EosModule): + if item in fit.projectedModules: + self.pModPositions.append(fit.projectedModules.index(item)) + elif isinstance(item, EosDrone): + self.pDroneItemIDs.append(item.itemID) + elif isinstance(item, EosFighter): + if item in fit.projectedFighters: + self.pFighterPositions.append(fit.projectedFighters.index(item)) + elif isinstance(item, EosFit): + self.pFitIDs.append(item.ID) + self.proposedState = None + if click == 'right' and isinstance(mainItem, EosModule): + self.proposedState = 'overheat' + elif click == 'left': + if isinstance(mainItem, EosModule): + modProposedState = EosModule.getProposedState(mainItem, click) + self.proposedState = 'inactive' if modProposedState == FittingModuleState.OFFLINE else 'active' + elif isinstance(mainItem, EosDrone): + self.proposedState = 'active' if mainItem.amountActive == 0 else 'inactive' + elif isinstance(mainItem, EosFighter): + self.proposedState = 'inactive' if mainItem.active else 'active' + elif isinstance(mainItem, EosFit): + projectionInfo = mainItem.getProjectionInfo(self.fitID) + if projectionInfo is not None: + self.proposedState = 'inactive' if projectionInfo.active else 'active' + + def Do(self): + if self.proposedState is None: + return False + results = [] + if self.pModPositions: + cmd = CalcChangeProjectedModuleStatesCommand( + fitID=self.fitID, + positions=self.pModPositions, + proposedState=self.proposedState, + commit=False) + results.append(self.internalHistory.submit(cmd)) + for pDroneItemID in self.pDroneItemIDs: + cmd = CalcChangeProjectedDroneStateCommand( + fitID=self.fitID, + itemID=pDroneItemID, + state=False if self.proposedState == 'inactive' else True, + commit=False) + results.append(self.internalHistory.submit(cmd)) + for pFighterPosition in self.pFighterPositions: + cmd = CalcChangeProjectedFighterStateCommand( + fitID=self.fitID, + position=pFighterPosition, + state=False if self.proposedState == 'inactive' else True, + commit=False) + results.append(self.internalHistory.submit(cmd)) + for pFitID in self.pFitIDs: + cmd = CalcChangeProjectedFitStateCommand( + fitID=self.fitID, + projectedFitID=pFitID, + state=False if self.proposedState == 'inactive' else True, + commit=False) + results.append(self.internalHistory.submit(cmd)) + success = any(results) + eos.db.commit() + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) + return success + + def Undo(self): + success = self.internalHistory.undoAll() + eos.db.commit() + Fit.getInstance().recalc(self.fitID) + wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) + return success diff --git a/gui/fitCommands/gui/projectedDrone/toggleState.py b/gui/fitCommands/gui/projectedDrone/toggleState.py deleted file mode 100644 index e6e315ffe..000000000 --- a/gui/fitCommands/gui/projectedDrone/toggleState.py +++ /dev/null @@ -1,29 +0,0 @@ -import wx - -import gui.mainFrame -from gui import globalEvents as GE -from gui.fitCommands.calc.drone.projectedToggleState import CalcToggleProjectedDroneStateCommand -from gui.fitCommands.helpers import InternalCommandHistory -from service.fit import Fit - - -class GuiToggleProjectedDroneStateCommand(wx.Command): - - def __init__(self, fitID, itemID): - wx.Command.__init__(self, True, 'Toggle Projected Drone State') - self.internalHistory = InternalCommandHistory() - self.fitID = fitID - self.itemID = itemID - - def Do(self): - cmd = CalcToggleProjectedDroneStateCommand(fitID=self.fitID, itemID=self.itemID) - success = self.internalHistory.submit(cmd) - Fit.getInstance().recalc(self.fitID) - wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) - return success - - def Undo(self): - success = self.internalHistory.undoAll() - Fit.getInstance().recalc(self.fitID) - wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) - return success diff --git a/gui/fitCommands/gui/projectedFighter/toggleStates.py b/gui/fitCommands/gui/projectedFighter/toggleStates.py deleted file mode 100644 index 440962541..000000000 --- a/gui/fitCommands/gui/projectedFighter/toggleStates.py +++ /dev/null @@ -1,34 +0,0 @@ -import wx - -import gui.mainFrame -from gui import globalEvents as GE -from gui.fitCommands.calc.fighter.toggleStates import CalcToggleFighterStatesCommand -from gui.fitCommands.helpers import InternalCommandHistory -from service.fit import Fit - - -class GuiToggleProjectedFighterStatesCommand(wx.Command): - - def __init__(self, fitID, mainPosition, positions): - wx.Command.__init__(self, True, 'Toggle Projected Fighter States') - self.internalHistory = InternalCommandHistory() - self.fitID = fitID - self.mainPosition = mainPosition - self.positions = positions - - def Do(self): - cmd = CalcToggleFighterStatesCommand( - fitID=self.fitID, - projected=True, - mainPosition=self.mainPosition, - positions=self.positions) - success = self.internalHistory.submit(cmd) - Fit.getInstance().recalc(self.fitID) - wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) - return success - - def Undo(self): - success = self.internalHistory.undoAll() - Fit.getInstance().recalc(self.fitID) - wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) - return success diff --git a/gui/fitCommands/gui/projectedFit/toggleState.py b/gui/fitCommands/gui/projectedFit/toggleState.py deleted file mode 100644 index a285ae575..000000000 --- a/gui/fitCommands/gui/projectedFit/toggleState.py +++ /dev/null @@ -1,29 +0,0 @@ -import wx - -import gui.mainFrame -from gui import globalEvents as GE -from gui.fitCommands.calc.projectedFit.toggleState import CalcToggleProjectedFitCommand -from gui.fitCommands.helpers import InternalCommandHistory -from service.fit import Fit - - -class GuiToggleProjectedFitStateCommand(wx.Command): - - def __init__(self, fitID, projectedFitID): - wx.Command.__init__(self, True, 'Toggle Projected Fit State') - self.internalHistory = InternalCommandHistory() - self.fitID = fitID - self.projectedFitID = projectedFitID - - def Do(self): - cmd = CalcToggleProjectedFitCommand(fitID=self.fitID, projectedFitID=self.projectedFitID) - success = self.internalHistory.submit(cmd) - Fit.getInstance().recalc(self.fitID) - wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) - return success - - def Undo(self): - success = self.internalHistory.undoAll() - Fit.getInstance().recalc(self.fitID) - wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) - return success diff --git a/gui/fitCommands/gui/projectedModule/changeState.py b/gui/fitCommands/gui/projectedModule/changeState.py deleted file mode 100644 index b8bf4ede3..000000000 --- a/gui/fitCommands/gui/projectedModule/changeState.py +++ /dev/null @@ -1,30 +0,0 @@ -import wx - -import gui.mainFrame -from gui import globalEvents as GE -from gui.fitCommands.calc.module.projectedChangeState import CalcChangeProjectedModuleStateCommand -from gui.fitCommands.helpers import InternalCommandHistory -from service.fit import Fit - - -class GuiChangeProjectedModuleStateCommand(wx.Command): - - def __init__(self, fitID, position, click): - wx.Command.__init__(self, True, 'Change Projected Module State') - self.internalHistory = InternalCommandHistory() - self.fitID = fitID - self.position = position - self.click = click - - def Do(self): - cmd = CalcChangeProjectedModuleStateCommand(fitID=self.fitID, position=self.position, click=self.click) - success = self.internalHistory.submit(cmd) - Fit.getInstance().recalc(self.fitID) - wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) - return success - - def Undo(self): - success = self.internalHistory.undoAll() - Fit.getInstance().recalc(self.fitID) - wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) - return success diff --git a/gui/fitCommands/gui/projectedRemove.py b/gui/fitCommands/gui/projectedRemove.py index 5476e8ad0..a0c872ffb 100644 --- a/gui/fitCommands/gui/projectedRemove.py +++ b/gui/fitCommands/gui/projectedRemove.py @@ -49,7 +49,7 @@ class GuiRemoveProjectedItemsCommand(wx.Command): for pDroneItemID in self.pDroneItemIDs: cmd = CalcRemoveProjectedDroneCommand(fitID=self.fitID, itemID=pDroneItemID, amount=self.amount, commit=False) results.append(self.internalHistory.submit(cmd)) - for pFighterPosition in self.pFighterPositions: + for pFighterPosition in sorted(self.pFighterPositions, reverse=True): cmd = CalcRemoveProjectedFighterCommand(fitID=self.fitID, position=pFighterPosition, commit=False) results.append(self.internalHistory.submit(cmd)) for pFitID in self.pFitIDs: