diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index 57aacf101..9347f1075 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -272,7 +272,13 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): @property def modPosition(self): if self.owner: - return self.owner.modules.index(self) + return self.owner.modules.index(self) if not self.isProjected else self.owner.projectedModules.index(self) + + @property + def isProjected(self): + if self.owner: + return self in self.owner.projectedModules + return None @property def isCapitalSize(self): diff --git a/gui/builtinContextMenus/moduleGlobalAmmoPicker.py b/gui/builtinContextMenus/moduleGlobalAmmoPicker.py index 70a41c351..8c7748975 100644 --- a/gui/builtinContextMenus/moduleGlobalAmmoPicker.py +++ b/gui/builtinContextMenus/moduleGlobalAmmoPicker.py @@ -30,8 +30,9 @@ class ModuleGlobalAmmoPicker(ModuleAmmoPicker): fit = db_getFit(fitID) selectedModule = self.modules[0] + source = fit.modules if not selectedModule.isProjected else fit.projectedModules allModules = [] - for mod in fit.modules: + for mod in source: if mod.itemID is None: continue if mod.itemID == selectedModule.itemID: diff --git a/gui/fitCommands/calc/fitSetCharge.py b/gui/fitCommands/calc/fitSetCharge.py index 93a6da4ae..91a4abe8d 100644 --- a/gui/fitCommands/calc/fitSetCharge.py +++ b/gui/fitCommands/calc/fitSetCharge.py @@ -9,7 +9,7 @@ pyfalog = Logger(__name__) class FitSetChargeCommand(wx.Command): - def __init__(self, fitID, positions, chargeID=None): + def __init__(self, fitID, positions, chargeID=None, projected=False): # todo: determine if this command really should be used with a group of modules, or a simple per module basis wx.Command.__init__(self, True, "Module Charge Add") self.mainFrame = gui.mainFrame.MainFrame.getInstance() @@ -17,6 +17,7 @@ class FitSetChargeCommand(wx.Command): self.fitID = fitID self.chargeID = chargeID self.positions = positions + self.projected = projected self.cache = None def Do(self): @@ -29,7 +30,8 @@ class FitSetChargeCommand(wx.Command): def __setAmmo(self, positions, chargeID): fit = eos.db.getFit(self.fitID) - self.cache = {fit.modules[i].modPosition: fit.modules[i].chargeID for i in positions} + source = fit.modules if not self.projected else fit.projectedModules + self.cache = {source[i].modPosition: source[i].chargeID for i in positions} ammo = eos.db.getItem(chargeID) if chargeID else None if ammo is not None and not ammo.isCharge: @@ -37,7 +39,7 @@ class FitSetChargeCommand(wx.Command): result = False for pos in positions: - mod = fit.modules[pos] + mod = source[pos] if not mod.isEmpty and mod.isValidCharge(ammo): pyfalog.debug("Set ammo {} for {} on fit {}", ammo, mod, self.fitID) result = True diff --git a/gui/fitCommands/guiAddCharge.py b/gui/fitCommands/guiAddCharge.py index ad6c5a2f2..ae2af59aa 100644 --- a/gui/fitCommands/guiAddCharge.py +++ b/gui/fitCommands/guiAddCharge.py @@ -15,9 +15,10 @@ class GuiModuleAddChargeCommand(wx.Command): self.fitID = fitID self.itemID = itemID self.positions = [mod.modPosition for mod in modules] + self.projected = modules[0].isProjected def Do(self): - if self.internal_history.Submit(FitSetChargeCommand(self.fitID, self.positions, self.itemID)): + if self.internal_history.Submit(FitSetChargeCommand(self.fitID, self.positions, self.itemID, self.projected)): self.sFit.recalc(self.fitID) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) return True