diff --git a/gui/builtinContextMenus/itemVariationChange.py b/gui/builtinContextMenus/itemVariationChange.py index 41ae0c44b..255b5f1f7 100644 --- a/gui/builtinContextMenus/itemVariationChange.py +++ b/gui/builtinContextMenus/itemVariationChange.py @@ -239,11 +239,22 @@ class ChangeItemToVariation(ContextMenuCombined): def __handleProjectedModule(self, varItem): fitID = self.mainFrame.getActiveFit() fit = Fit.getInstance().getFit(fitID) - mod = self.mainItem - if mod in fit.projectedModules: - position = fit.projectedModules.index(mod) - self.mainFrame.command.Submit(cmd.GuiChangeProjectedModuleMetaCommand( - fitID=fitID, position=position, newItemID=varItem.ID)) + if wx.GetMouseState().GetModifiers() == wx.MOD_ALT: + positions = getSimilarModPositions(fit.projectedModules, self.mainItem) + else: + sMkt = Market.getInstance() + positions = [] + for mod in self.selection: + if mod is self.mainItem: + positions.append(fit.projectedModules.index(mod)) + continue + if mod not in fit.projectedModules: + continue + modVariations = sMkt.getVariationsByItems((mod.item,)) + if modVariations == self.mainVariations: + positions.append(fit.projectedModules.index(mod)) + self.mainFrame.command.Submit(cmd.GuiChangeProjectedModuleMetasCommand( + fitID=fitID, positions=positions, newItemID=varItem.ID)) def __handleProjectedDrone(self, varItem): fitID = self.mainFrame.getActiveFit() diff --git a/gui/fitCommands/__init__.py b/gui/fitCommands/__init__.py index 09906283c..563211e9d 100644 --- a/gui/fitCommands/__init__.py +++ b/gui/fitCommands/__init__.py @@ -59,7 +59,7 @@ from .gui.projectedFit.add import GuiAddProjectedFitCommand from .gui.projectedFit.changeAmount import GuiChangeProjectedFitAmountCommand from .gui.projectedModule.add import GuiAddProjectedModuleCommand from .gui.projectedModule.changeCharges import GuiChangeProjectedModuleChargesCommand -from .gui.projectedModule.changeMeta import GuiChangeProjectedModuleMetaCommand +from .gui.projectedModule.changeMetas import GuiChangeProjectedModuleMetasCommand from .gui.projectedModule.changeSpool import GuiChangeProjectedModuleSpoolCommand from .gui.projectedRemove import GuiRemoveProjectedItemsCommand from .gui.shipModeChange import GuiChangeShipModeCommand diff --git a/gui/fitCommands/calc/module/projectedAdd.py b/gui/fitCommands/calc/module/projectedAdd.py index 7031b3b03..59f28e6de 100644 --- a/gui/fitCommands/calc/module/projectedAdd.py +++ b/gui/fitCommands/calc/module/projectedAdd.py @@ -30,7 +30,8 @@ class CalcAddProjectedModuleCommand(wx.Command): fit = Fit.getInstance().getFit(self.fitID) if not newMod.canHaveState(newMod.state, projectedOnto=fit): newMod.state = FittingModuleState.OFFLINE - + if not newMod.isValidCharge(newMod.charge): + newMod.charge = None self.oldPosition, self.oldModInfo = fit.projectedModules.makeRoom(newMod) if self.newPosition is not None: diff --git a/gui/fitCommands/gui/cargo/remove.py b/gui/fitCommands/gui/cargo/remove.py index 26fbb3ce1..f80a537d5 100644 --- a/gui/fitCommands/gui/cargo/remove.py +++ b/gui/fitCommands/gui/cargo/remove.py @@ -18,14 +18,14 @@ class GuiRemoveCargosCommand(wx.Command): self.itemIDs = itemIDs def Do(self): - result = [] + results = [] for itemID in self.itemIDs: cmd = CalcRemoveCargoCommand( fitID=self.fitID, cargoInfo=CargoInfo(itemID=itemID, amount=math.inf), commit=False) - result.append(self.internalHistory.submit(cmd)) - success = any(result) + results.append(self.internalHistory.submit(cmd)) + success = any(results) eos.db.commit() wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return success diff --git a/gui/fitCommands/gui/localDrone/changeMetas.py b/gui/fitCommands/gui/localDrone/changeMetas.py index 4e78cb019..57b5d2010 100644 --- a/gui/fitCommands/gui/localDrone/changeMetas.py +++ b/gui/fitCommands/gui/localDrone/changeMetas.py @@ -23,7 +23,7 @@ class GuiChangeLocalDroneMetasCommand(wx.Command): def Do(self): sFit = Fit.getInstance() fit = sFit.getFit(self.fitID) - result = [] + results = [] for position in sorted(self.positions, reverse=True): drone = fit.drones[position] if drone.itemID == self.newItemID: @@ -40,8 +40,8 @@ class GuiChangeLocalDroneMetasCommand(wx.Command): droneInfo=info, forceNewStack=True, commit=False) - result.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd)) - success = any(result) + results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd)) + success = any(results) eos.db.commit() sFit.recalc(fit) wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) diff --git a/gui/fitCommands/gui/localFighter/changeMetas.py b/gui/fitCommands/gui/localFighter/changeMetas.py index 71921a550..0e264a908 100644 --- a/gui/fitCommands/gui/localFighter/changeMetas.py +++ b/gui/fitCommands/gui/localFighter/changeMetas.py @@ -21,7 +21,7 @@ class GuiChangeLocalFighterMetasCommand(wx.Command): def Do(self): sFit = Fit.getInstance() fit = sFit.getFit(self.fitID) - result = [] + results = [] for position in sorted(self.positions, reverse=True): fighter = fit.fighters[position] if fighter.itemID == self.newItemID: @@ -36,8 +36,8 @@ class GuiChangeLocalFighterMetasCommand(wx.Command): fitID=self.fitID, fighterInfo=info, commit=False) - result.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd)) - success = any(result) + results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd)) + success = any(results) eos.db.commit() sFit.recalc(fit) wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) diff --git a/gui/fitCommands/gui/localModule/changeMetas.py b/gui/fitCommands/gui/localModule/changeMetas.py index 1b7dea193..a74ce3d50 100644 --- a/gui/fitCommands/gui/localModule/changeMetas.py +++ b/gui/fitCommands/gui/localModule/changeMetas.py @@ -33,7 +33,11 @@ class GuiChangeLocalModuleMetasCommand(wx.Command): info = ModuleInfo.fromModule(module) info.itemID = self.newItemID cmd = CalcReplaceLocalModuleCommand( - fitID=self.fitID, position=position, newModInfo=info, unloadInvalidCharges=True, commit=False) + fitID=self.fitID, + position=position, + newModInfo=info, + unloadInvalidCharges=True, + commit=False) commands.append(cmd) if not commands: return False diff --git a/gui/fitCommands/gui/projectedModule/changeMeta.py b/gui/fitCommands/gui/projectedModule/changeMetas.py similarity index 54% rename from gui/fitCommands/gui/projectedModule/changeMeta.py rename to gui/fitCommands/gui/projectedModule/changeMetas.py index 8ec84bfe8..4eeb96412 100644 --- a/gui/fitCommands/gui/projectedModule/changeMeta.py +++ b/gui/fitCommands/gui/projectedModule/changeMetas.py @@ -1,5 +1,6 @@ import wx +import eos.db import gui.mainFrame from gui import globalEvents as GE from gui.fitCommands.calc.module.projectedAdd import CalcAddProjectedModuleCommand @@ -8,32 +9,37 @@ from gui.fitCommands.helpers import InternalCommandHistory, ModuleInfo from service.fit import Fit -class GuiChangeProjectedModuleMetaCommand(wx.Command): +class GuiChangeProjectedModuleMetasCommand(wx.Command): - def __init__(self, fitID, position, newItemID): - wx.Command.__init__(self, True, 'Change Projected Module Meta') + def __init__(self, fitID, positions, newItemID): + wx.Command.__init__(self, True, 'Change Projected Module Metas') self.internalHistory = InternalCommandHistory() self.fitID = fitID - self.position = position + self.positions = positions self.newItemID = newItemID def Do(self): sFit = Fit.getInstance() fit = sFit.getFit(self.fitID) - module = fit.projectedModules[self.position] - if module.itemID == self.newItemID: - return - info = ModuleInfo.fromModule(module) - info.itemID = self.newItemID - cmdRemove = CalcRemoveProjectedModuleCommand(fitID=self.fitID, position=self.position) - cmdAdd = CalcAddProjectedModuleCommand(fitID=self.fitID, modInfo=info) - success = self.internalHistory.submitBatch(cmdRemove, cmdAdd) + results = [] + for position in sorted(self.positions, reverse=True): + module = fit.projectedModules[position] + if module.itemID == self.newItemID: + continue + info = ModuleInfo.fromModule(module) + info.itemID = self.newItemID + cmdRemove = CalcRemoveProjectedModuleCommand(fitID=self.fitID, position=position, commit=False) + cmdAdd = CalcAddProjectedModuleCommand(fitID=self.fitID, modInfo=info, commit=False) + results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd)) + success = any(results) + eos.db.commit() sFit.recalc(fit) 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