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