From d6b280d3ccb92453a72575ce7846e3475de99276 Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Thu, 9 Aug 2018 15:52:34 -0400 Subject: [PATCH] Working commit for adding / removing projected modules / environments --- eos/effectHandlerHelpers.py | 16 ++++++++++------ gui/builtinAdditionPanes/projectedView.py | 3 +-- gui/builtinContextMenus/itemRemove.py | 5 +++-- gui/fitCommands/__init__.py | 3 ++- gui/fitCommands/guiAddProjected.py | 6 ++---- service/fit.py | 1 + 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/eos/effectHandlerHelpers.py b/eos/effectHandlerHelpers.py index 3cba3e40f..194429d31 100644 --- a/eos/effectHandlerHelpers.py +++ b/eos/effectHandlerHelpers.py @@ -236,12 +236,7 @@ class HandledProjectedModList(HandledList): isSystemEffect = proj.item.group.name == "Effect Beacon" if isSystemEffect: - # remove other system effects - only 1 per fit plz - oldEffect = next((m for m in self if m.item.group.name == "Effect Beacon"), None) - - if oldEffect: - pyfalog.info("System effect occupied with {0}, replacing with {1}", oldEffect.item.name, proj.item.name) - self.remove(oldEffect) + self.makeRoom(proj) HandledList.append(self, proj) @@ -249,6 +244,15 @@ class HandledProjectedModList(HandledList): if not proj.item.isType("projected") and not isSystemEffect: self.remove(proj) + def makeRoom(self, proj): + # remove other system effects - only 1 per fit plz + oldEffect = next((m for m in self if m.item.group.name == "Effect Beacon"), None) + + if oldEffect: + pyfalog.info("System effect occupied with {0}, replacing with {1}", oldEffect.item.name, proj.item.name) + self.remove(oldEffect) + return oldEffect.itemID + return None class HandledProjectedDroneList(HandledDroneCargoList): def append(self, proj): diff --git a/gui/builtinAdditionPanes/projectedView.py b/gui/builtinAdditionPanes/projectedView.py index 4cb18abd8..293f34cf2 100644 --- a/gui/builtinAdditionPanes/projectedView.py +++ b/gui/builtinAdditionPanes/projectedView.py @@ -323,5 +323,4 @@ class ProjectedView(d.Display): sFit = Fit.getInstance() thing = self.get(row) if thing: # thing doesn't exist if it's the dummy value - sFit.removeProjected(fitID, thing) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) + self.mainFrame.command.Submit(cmd.GuiRemoveProjectedCommand(fitID, thing)) diff --git a/gui/builtinContextMenus/itemRemove.py b/gui/builtinContextMenus/itemRemove.py index d075eba2e..0d464461d 100644 --- a/gui/builtinContextMenus/itemRemove.py +++ b/gui/builtinContextMenus/itemRemove.py @@ -54,10 +54,11 @@ class ItemRemove(ContextMenu): self.mainFrame.command.Submit(cmd.GuiRemoveCargoCommand(fitID, selection[0].itemID)) return # the command takes care of the PostEvent elif srcContext in ("projectedFit", "projectedModule", "projectedDrone", "projectedFighter"): - sFit.removeProjected(fitID, selection[0]) + self.mainFrame.command.Submit(cmd.GuiRemoveProjectedCommand(fitID, selection[0])) + return # the command takes care of the PostEvent elif srcContext == "commandFit": self.mainFrame.command.Submit(cmd.GuiRemoveCommandCommand(fitID, selection[0].ID)) - return + return # the command takes care of the PostEvent wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) diff --git a/gui/fitCommands/__init__.py b/gui/fitCommands/__init__.py index f253af60c..692aa6589 100644 --- a/gui/fitCommands/__init__.py +++ b/gui/fitCommands/__init__.py @@ -13,4 +13,5 @@ from .guiAddCommand import GuiAddCommandCommand from .guiRemoveCommand import GuiRemoveCommandCommand from .guiSetMode import GuiSetModeCommand from .guiToggleCommand import GuiToggleCommandCommand -from .guiAddProjected import GuiAddProjectedCommand \ No newline at end of file +from .guiAddProjected import GuiAddProjectedCommand +from .guiRemoveProjected import GuiRemoveProjectedCommand \ No newline at end of file diff --git a/gui/fitCommands/guiAddProjected.py b/gui/fitCommands/guiAddProjected.py index e483fb84f..cc556f32c 100644 --- a/gui/fitCommands/guiAddProjected.py +++ b/gui/fitCommands/guiAddProjected.py @@ -5,6 +5,7 @@ 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 logbook import Logger import eos.db pyfalog = Logger(__name__) @@ -46,10 +47,7 @@ class GuiAddProjectedCommand(wx.Command): # fighter = Fighter(item) # fit.projectedFighters.append(fighter) elif item.group.name in Module.SYSTEM_GROUPS: - pyfalog.warn("WH PROJECTION NOT IMPLEMENTED") - # module = Module(item) - # module.state = State.ONLINE - # fit.projectedModules.append(module) + result = self.internal_history.Submit(FitAddProjectedEnvCommand(self.fitID, self.id)) else: # attempt a regular module projection result = self.internal_history.Submit(FitAddProjectedModuleCommand(self.fitID, self.id)) diff --git a/service/fit.py b/service/fit.py index 4916df143..d1fab9dbe 100644 --- a/service/fit.py +++ b/service/fit.py @@ -528,6 +528,7 @@ class Fit(object): eos.db.commit() self.recalc(fit) + @deprecated def removeProjected(self, fitID, thing): pyfalog.debug("Removing projection on fit ({0}) from: {1}", fitID, thing) fit = eos.db.getFit(fitID)