Do not pass modules to charge switching commands
This commit is contained in:
@@ -35,9 +35,6 @@ class RemoveItem(ContextMenu):
|
||||
if srcContext == "fittingModule":
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveLocalModuleCommand(
|
||||
fitID=fitID, modules=[module for module in selection if module is not None]))
|
||||
elif srcContext == "fittingCharge":
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeLocalModuleChargesCommand(
|
||||
fitID=fitID, modules=selection, chargeItemID=None))
|
||||
elif srcContext == "droneItem":
|
||||
drone = selection[0]
|
||||
if drone in fit.drones:
|
||||
|
||||
@@ -221,11 +221,11 @@ class ChangeModuleAmmo(ContextMenu):
|
||||
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
sFit = Fit.getInstance()
|
||||
fit = sFit.getFit(fitID)
|
||||
mstate = wx.GetMouseState()
|
||||
# Switch in selection or all modules, depending on modifier key state and settings
|
||||
switchAll = sFit.serviceFittingOptions['ammoChangeAll'] is not (mstate.cmdDown or mstate.altDown)
|
||||
# Switch in selection or all modules, depending on ctrl key state and settings
|
||||
if switchAll:
|
||||
fit = sFit.getFit(fitID)
|
||||
if self.context == 'fittingModule':
|
||||
command = cmd.GuiChangeLocalModuleChargesCommand
|
||||
modContainer = fit.modules
|
||||
@@ -237,37 +237,43 @@ class ChangeModuleAmmo(ContextMenu):
|
||||
sMkt = Market.getInstance()
|
||||
selectedModule = self.modules[0]
|
||||
mainMktGroupID = getattr(sMkt.getMarketGroupByItem(selectedModule.item), 'ID', None)
|
||||
mods = []
|
||||
for mod in modContainer:
|
||||
positions = []
|
||||
for position, mod in enumerate(modContainer):
|
||||
# Always include selected module itself
|
||||
if mod is selectedModule:
|
||||
mods.append(mod)
|
||||
positions.append(position)
|
||||
continue
|
||||
if mod.itemID is None:
|
||||
continue
|
||||
# Modules which have the same item ID
|
||||
if mod.itemID == selectedModule.itemID:
|
||||
mods.append(mod)
|
||||
positions.append(position)
|
||||
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)
|
||||
positions.append(position)
|
||||
continue
|
||||
self.mainFrame.command.Submit(command(
|
||||
fitID=fitID,
|
||||
modules=mods,
|
||||
positions=positions,
|
||||
chargeItemID=charge.ID if charge is not None else None))
|
||||
else:
|
||||
if self.context == 'fittingModule':
|
||||
command = cmd.GuiChangeLocalModuleChargesCommand
|
||||
modContainer = fit.modules
|
||||
elif self.context == 'projectedModule':
|
||||
command = cmd.GuiChangeProjectedModuleChargesCommand
|
||||
modContainer = fit.projectedModules
|
||||
else:
|
||||
return
|
||||
positions = []
|
||||
for position, mod in enumerate(modContainer):
|
||||
if mod in self.modules:
|
||||
positions.append(position)
|
||||
self.mainFrame.command.Submit(command(
|
||||
fitID=fitID,
|
||||
modules=self.modules,
|
||||
positions=positions,
|
||||
chargeItemID=charge.ID if charge is not None else None))
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import gui.mainFrame
|
||||
from eos.utils.spoolSupport import SpoolType, SpoolOptions
|
||||
from gui.contextMenu import ContextMenu
|
||||
from service.settings import ContextMenuSettings
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class ChangeModuleSpool(ContextMenu):
|
||||
@@ -75,18 +76,18 @@ class ChangeModuleSpool(ContextMenu):
|
||||
spoolAmount = self.cycleMap[event.Id]
|
||||
else:
|
||||
return
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
fit = Fit.getInstance().getFit(fitID)
|
||||
if self.context == 'fittingModule':
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeLocalModuleSpoolCommand(
|
||||
fitID=self.mainFrame.getActiveFit(),
|
||||
position=self.mod.modPosition,
|
||||
spoolType=spoolType,
|
||||
spoolAmount=spoolAmount))
|
||||
if self.mod in fit.modules:
|
||||
position = fit.modules.index(self.mod)
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeLocalModuleSpoolCommand(
|
||||
fitID=fitID, position=position, spoolType=spoolType, spoolAmount=spoolAmount))
|
||||
elif self.context == 'projectedModule':
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeProjectedModuleSpoolCommand(
|
||||
fitID=self.mainFrame.getActiveFit(),
|
||||
position=self.mod.modPosition,
|
||||
spoolType=spoolType,
|
||||
spoolAmount=spoolAmount))
|
||||
if self.mod in fit.projectedModules:
|
||||
position = fit.projectedModules.index(self.mod)
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeProjectedModuleSpoolCommand(
|
||||
fitID=fitID, position=position, spoolType=spoolType, spoolAmount=spoolAmount))
|
||||
|
||||
|
||||
ChangeModuleSpool.register()
|
||||
|
||||
@@ -9,11 +9,11 @@ from service.fit import Fit
|
||||
|
||||
class GuiChangeLocalModuleChargesCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, modules, chargeItemID):
|
||||
def __init__(self, fitID, positions, chargeItemID):
|
||||
wx.Command.__init__(self, True, 'Change Local Module Charges')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.positions = [mod.modPosition for mod in modules]
|
||||
self.positions = positions
|
||||
self.chargeItemID = chargeItemID
|
||||
|
||||
def Do(self):
|
||||
|
||||
@@ -9,11 +9,11 @@ from service.fit import Fit
|
||||
|
||||
class GuiChangeProjectedModuleChargesCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, modules, chargeItemID):
|
||||
def __init__(self, fitID, positions, chargeItemID):
|
||||
wx.Command.__init__(self, True, 'Change Projected Module Charges')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.positions = [mod.modPosition for mod in modules]
|
||||
self.positions = positions
|
||||
self.chargeItemID = chargeItemID
|
||||
|
||||
def Do(self):
|
||||
|
||||
Reference in New Issue
Block a user