From 2fb9d3479fba1ac818e1d2316588d497cad6b8ef Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Fri, 19 Apr 2019 01:02:44 +0300 Subject: [PATCH] When mass-changing charges, take not only items with the same typeID but all items from the same market group --- gui/builtinContextMenus/moduleAmmoChange.py | 56 ++++++++++++++------- gui/builtinContextMenus/shipJump.py | 2 +- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/gui/builtinContextMenus/moduleAmmoChange.py b/gui/builtinContextMenus/moduleAmmoChange.py index 9c167cb69..0ee6353f7 100644 --- a/gui/builtinContextMenus/moduleAmmoChange.py +++ b/gui/builtinContextMenus/moduleAmmoChange.py @@ -225,29 +225,49 @@ class ChangeModuleAmmo(ContextMenu): # Switch in selection or all modules, depending on ctrl key state and settings if switchAll: fit = sFit.getFit(fitID) - selectedModule = self.modules[0] if self.context == 'fittingModule': - self.mainFrame.command.Submit(cmd.GuiChangeLocalModuleChargesCommand( - fitID=fitID, - modules=[m for m in fit.modules if m.itemID is not None and m.itemID == selectedModule.itemID], - chargeItemID=charge.ID if charge is not None else None)) + command = cmd.GuiChangeLocalModuleChargesCommand + modContainer = fit.modules elif self.context == 'projectedModule': - self.mainFrame.command.Submit(cmd.GuiChangeProjectedModuleChargesCommand( - fitID=fitID, - modules=[m for m in fit.projectedModules if - m.itemID is not None and m.itemID == selectedModule.itemID], - chargeItemID=charge.ID if charge is not None else None)) + command = cmd.GuiChangeProjectedModuleChargesCommand + modContainer = fit.projectedModules + else: + return + sMkt = Market.getInstance() + selectedModule = self.modules[0] + mainMktGroupID = getattr(sMkt.getMarketGroupByItem(selectedModule.item), 'ID', None) + mods = [] + for mod in modContainer: + # Always include selected module itself + if mod is selectedModule: + mods.append(mod) + continue + if mod.itemID is None: + continue + # Modules which have the same item ID + if mod.itemID == selectedModule.itemID: + mods.append(mod) + continue + # And modules from the same market group too + modMktGroupID = getattr(sMkt.getMarketGroupByItem(mod.item), 'ID', None) + if modMktGroupID is not None and modMktGroupID == mainMktGroupID: + mods.append(mod) + continue + self.mainFrame.command.Submit(command( + fitID=fitID, + modules=mods, + chargeItemID=charge.ID if charge is not None else None)) else: if self.context == 'fittingModule': - self.mainFrame.command.Submit(cmd.GuiChangeLocalModuleChargesCommand( - fitID=fitID, - modules=self.modules, - chargeItemID=charge.ID if charge is not None else None)) + command = cmd.GuiChangeLocalModuleChargesCommand elif self.context == 'projectedModule': - self.mainFrame.command.Submit(cmd.GuiChangeProjectedModuleChargesCommand( - fitID=fitID, - modules=self.modules, - chargeItemID=charge.ID if charge is not None else None)) + command = cmd.GuiChangeProjectedModuleChargesCommand + else: + return + self.mainFrame.command.Submit(command( + fitID=fitID, + modules=self.modules, + chargeItemID=charge.ID if charge is not None else None)) ChangeModuleAmmo.register() diff --git a/gui/builtinContextMenus/shipJump.py b/gui/builtinContextMenus/shipJump.py index 8eb6cdc4d..34f3b9181 100644 --- a/gui/builtinContextMenus/shipJump.py +++ b/gui/builtinContextMenus/shipJump.py @@ -26,7 +26,7 @@ class JumpToShip(ContextMenu): groupID = stuff.item.group.ID self.mainFrame.notebookBrowsers.SetSelection(1) - wx.PostEvent(self.mainFrame.shipBrowser, Stage3Selected(shipID=stuff.item.ID, back=groupID)) + wx.PostEvent(self.mainFrame.shipBrowser, Stage3Selected(shipID=stuff.item.ID, back=True)) JumpToShip.register()