Create a new property on Module, returns if module is projected (or None if it's not attached to a fit). Fix issues with setting charges on projected modules because the command was always looking at the literal modules on the fit (instead of projected)
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user