Rely on clicked item instead of selection where it makes sense
This commit is contained in:
@@ -19,9 +19,8 @@ class AmmoToDmgPattern(ContextMenu):
|
||||
if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None:
|
||||
return False
|
||||
|
||||
item = selection[0]
|
||||
for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"):
|
||||
if item.getAttribute(attr) is not None:
|
||||
if mainItem.getAttribute(attr) is not None:
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -30,10 +29,9 @@ class AmmoToDmgPattern(ContextMenu):
|
||||
return "Set {0} as Damage Pattern".format(itmContext if itmContext is not None else "Item")
|
||||
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
item = selection[0]
|
||||
fit = self.mainFrame.getActiveFit()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.setAsPattern(fit, item)
|
||||
sFit.setAsPattern(fit, mainItem)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fit))
|
||||
|
||||
def getBitmap(self, context, mainItem, selection):
|
||||
|
||||
@@ -21,7 +21,7 @@ class BoosterSideEffect(ContextMenu):
|
||||
if self.mainFrame.getActiveFit() is None or srcContext not in "boosterItem":
|
||||
return False
|
||||
|
||||
self.booster = selection[0]
|
||||
self.booster = mainItem
|
||||
|
||||
for effect in self.booster.sideEffects:
|
||||
if effect.effect.isImplemented:
|
||||
|
||||
@@ -29,7 +29,7 @@ class AddToCargo(ContextMenu):
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
typeID = int(selection[0].ID)
|
||||
typeID = int(mainItem.ID)
|
||||
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCargoCommand(
|
||||
fitID=fitID, itemID=typeID, amount=1))
|
||||
|
||||
@@ -24,7 +24,7 @@ class AddToCargoAmmo(ContextMenu):
|
||||
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
typeID = int(selection[0].ID)
|
||||
typeID = int(mainItem.ID)
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCargoCommand(
|
||||
fitID=fitID, itemID=typeID, amount=1000))
|
||||
self.mainFrame.additionsPane.select("Cargo")
|
||||
|
||||
@@ -19,13 +19,12 @@ class DroneAddStack(ContextMenu):
|
||||
if self.mainFrame.getActiveFit() is None:
|
||||
return False
|
||||
|
||||
item = selection[0]
|
||||
if item.category.name != 'Drone':
|
||||
if mainItem.category.name != 'Drone':
|
||||
return False
|
||||
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
fit = Fit.getInstance().getFit(fitID)
|
||||
amount = droneStackLimit(fit, item)
|
||||
amount = droneStackLimit(fit, mainItem)
|
||||
if amount < 1:
|
||||
return False
|
||||
|
||||
@@ -39,7 +38,7 @@ class DroneAddStack(ContextMenu):
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
self.mainFrame.command.Submit(cmd.GuiAddLocalDroneCommand(
|
||||
fitID=self.mainFrame.getActiveFit(),
|
||||
itemID=int(selection[0].ID),
|
||||
itemID=int(mainItem.ID),
|
||||
amount=self.amount))
|
||||
self.mainFrame.additionsPane.select('Drones')
|
||||
|
||||
|
||||
@@ -16,14 +16,13 @@ class DroneSplitStack(ContextMenu):
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem, selection):
|
||||
return srcContext == "droneItem" and selection[0].amount > 1
|
||||
return srcContext == "droneItem" and mainItem.amount > 1
|
||||
|
||||
def getText(self, itmContext, mainItem, selection):
|
||||
return "Split {0} Stack".format(itmContext)
|
||||
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
drone = selection[0]
|
||||
dlg = DroneStackSplit(self.mainFrame, drone.amount)
|
||||
dlg = DroneStackSplit(self.mainFrame, mainItem.amount)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
|
||||
@@ -34,8 +33,8 @@ class DroneSplitStack(ContextMenu):
|
||||
fit = Fit.getInstance().getFit(fitID)
|
||||
cleanInput = re.sub(r'[^0-9.]', '', dlg.input.GetLineText(0).strip())
|
||||
|
||||
if drone in fit.drones:
|
||||
position = fit.drones.index(drone)
|
||||
if mainItem in fit.drones:
|
||||
position = fit.drones.index(mainItem)
|
||||
self.mainFrame.command.Submit(cmd.GuiSplitLocalDroneStackCommand(
|
||||
fitID=fitID, position=position, amount=int(cleanInput)))
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class FighterAbilities(ContextMenu):
|
||||
if self.mainFrame.getActiveFit() is None or srcContext not in ("fighterItem", "projectedFighter"):
|
||||
return False
|
||||
|
||||
self.fighter = selection[0]
|
||||
self.fighter = mainItem
|
||||
self.isProjected = True if srcContext == "projectedFighter" else False
|
||||
return True
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class OpenFitInNewTab(ContextMenu):
|
||||
if srcContext not in ("projectedFit", "commandFit"):
|
||||
return False
|
||||
currentFitID = self.mainFrame.getActiveFit()
|
||||
selectedFitID = selection[0].ID
|
||||
selectedFitID = mainItem.ID
|
||||
if currentFitID == selectedFitID:
|
||||
return False
|
||||
return True
|
||||
@@ -25,8 +25,7 @@ class OpenFitInNewTab(ContextMenu):
|
||||
return "Open Fit in New Tab"
|
||||
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
fit = selection[0]
|
||||
wx.PostEvent(self.mainFrame, FitSelected(fitID=fit.ID, startup=2))
|
||||
wx.PostEvent(self.mainFrame, FitSelected(fitID=mainItem.ID, startup=2))
|
||||
|
||||
|
||||
OpenFitInNewTab.register()
|
||||
|
||||
@@ -50,7 +50,7 @@ class addImplantSet(ContextMenu):
|
||||
|
||||
self.context = context
|
||||
if len(selection) == 1:
|
||||
self.selection = selection[0] # dirty hack here
|
||||
self.selection = mainItem # dirty hack here
|
||||
|
||||
self.idmap = {}
|
||||
|
||||
|
||||
@@ -26,21 +26,20 @@ class ChangeItemAmount(ContextMenu):
|
||||
return "Change {0} Quantity".format(itmContext)
|
||||
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
thing = selection[0]
|
||||
mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
fitID = mainFrame.getActiveFit()
|
||||
srcContext = fullContext[0]
|
||||
if isinstance(thing, es_Fit):
|
||||
if isinstance(mainItem, es_Fit):
|
||||
try:
|
||||
value = thing.getProjectionInfo(fitID).amount
|
||||
value = mainItem.getProjectionInfo(fitID).amount
|
||||
except AttributeError:
|
||||
return
|
||||
elif isinstance(thing, es_Fighter):
|
||||
value = thing.amountActive
|
||||
elif isinstance(mainItem, es_Fighter):
|
||||
value = mainItem.amountActive
|
||||
else:
|
||||
value = thing.amount
|
||||
value = mainItem.amount
|
||||
|
||||
dlg = AmountChanger(self.mainFrame, value, (0, 20)) if isinstance(thing, es_Fit) else AmountChanger(self.mainFrame, value)
|
||||
dlg = AmountChanger(self.mainFrame, value, (0, 20)) if isinstance(mainItem, es_Fit) else AmountChanger(self.mainFrame, value)
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
|
||||
if dlg.input.GetLineText(0).strip() == '':
|
||||
@@ -50,30 +49,30 @@ class ChangeItemAmount(ContextMenu):
|
||||
fit = sFit.getFit(fitID)
|
||||
cleanInput = int(float(re.sub(r'[^0-9.]', '', dlg.input.GetLineText(0).strip())))
|
||||
|
||||
if isinstance(thing, es_Cargo):
|
||||
if isinstance(mainItem, es_Cargo):
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeCargoAmountCommand(
|
||||
fitID=fitID, itemID=thing.itemID, amount=cleanInput))
|
||||
elif isinstance(thing, Drone):
|
||||
fitID=fitID, itemID=mainItem.itemID, amount=cleanInput))
|
||||
elif isinstance(mainItem, Drone):
|
||||
if srcContext == "projectedDrone":
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeProjectedDroneAmountCommand(
|
||||
fitID=fitID, itemID=thing.itemID, amount=cleanInput))
|
||||
fitID=fitID, itemID=mainItem.itemID, amount=cleanInput))
|
||||
else:
|
||||
if thing in fit.drones:
|
||||
position = fit.drones.index(thing)
|
||||
if mainItem in fit.drones:
|
||||
position = fit.drones.index(mainItem)
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeLocalDroneAmountCommand(
|
||||
fitID=fitID, position=position, amount=cleanInput))
|
||||
elif isinstance(thing, es_Fit):
|
||||
elif isinstance(mainItem, es_Fit):
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeProjectedFitAmountCommand(
|
||||
fitID=fitID, projectedFitID=thing.ID, amount=cleanInput))
|
||||
elif isinstance(thing, es_Fighter):
|
||||
fitID=fitID, projectedFitID=mainItem.ID, amount=cleanInput))
|
||||
elif isinstance(mainItem, es_Fighter):
|
||||
if srcContext == "projectedFighter":
|
||||
if thing in fit.projectedFighters:
|
||||
position = fit.projectedFighters.index(thing)
|
||||
if mainItem in fit.projectedFighters:
|
||||
position = fit.projectedFighters.index(mainItem)
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeProjectedFighterAmountCommand(
|
||||
fitID=fitID, position=position, amount=cleanInput))
|
||||
else:
|
||||
if thing in fit.fighters:
|
||||
position = fit.fighters.index(thing)
|
||||
if mainItem in fit.fighters:
|
||||
position = fit.fighters.index(mainItem)
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeLocalFighterAmountCommand(
|
||||
fitID=fitID, position=position, amount=cleanInput))
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@ class FillWithItem(ContextMenu):
|
||||
return False
|
||||
if self.mainFrame.getActiveFit() is None:
|
||||
return False
|
||||
item = selection[0]
|
||||
if item.category.name != 'Module':
|
||||
if mainItem.category.name != 'Module':
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -28,7 +27,7 @@ class FillWithItem(ContextMenu):
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
self.mainFrame.command.Submit(cmd.GuiFillWithNewLocalModulesCommand(
|
||||
fitID=self.mainFrame.getActiveFit(),
|
||||
itemID=int(selection[0].ID)))
|
||||
itemID=int(mainItem.ID)))
|
||||
self.mainFrame.additionsPane.select('Drones')
|
||||
|
||||
|
||||
|
||||
@@ -18,21 +18,21 @@ class JumpToMarketItem(ContextMenu):
|
||||
"implantItemChar", "fighterItem",
|
||||
"projectedFighter")
|
||||
|
||||
if srcContext not in validContexts or selection is None or len(selection) < 1:
|
||||
if srcContext not in validContexts or mainItem is None:
|
||||
return False
|
||||
|
||||
sMkt = Market.getInstance()
|
||||
item = getattr(selection[0], "item", selection[0])
|
||||
isMutated = getattr(selection[0], "isMutated", False)
|
||||
item = getattr(mainItem, "item", mainItem)
|
||||
isMutated = getattr(mainItem, "isMutated", False)
|
||||
mktGrp = sMkt.getMarketGroupByItem(item)
|
||||
if mktGrp is None and isMutated:
|
||||
mktGrp = sMkt.getMarketGroupByItem(selection[0].baseItem)
|
||||
mktGrp = sMkt.getMarketGroupByItem(mainItem.baseItem)
|
||||
|
||||
# 1663 is Special Edition Festival Assets, we don't have root group for it
|
||||
if mktGrp is None or mktGrp.ID == 1663:
|
||||
return False
|
||||
|
||||
doit = not selection[0].isEmpty if srcContext == "fittingModule" else True
|
||||
doit = not mainItem.isEmpty if srcContext == "fittingModule" else True
|
||||
return doit
|
||||
|
||||
def getText(self, itmContext, mainItem, selection):
|
||||
@@ -41,14 +41,14 @@ class JumpToMarketItem(ContextMenu):
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
srcContext = fullContext[0]
|
||||
if srcContext in ("fittingCharge", "projectedCharge"):
|
||||
item = selection[0].charge
|
||||
elif hasattr(selection[0], "item"):
|
||||
if getattr(selection[0], "isMutated", False):
|
||||
item = selection[0].baseItem
|
||||
item = mainItem.charge
|
||||
elif hasattr(mainItem, "item"):
|
||||
if getattr(mainItem, "isMutated", False):
|
||||
item = mainItem.baseItem
|
||||
else:
|
||||
item = selection[0].item
|
||||
item = mainItem.item
|
||||
else:
|
||||
item = selection[0]
|
||||
item = mainItem
|
||||
|
||||
self.mainFrame.notebookBrowsers.SetSelection(0)
|
||||
self.mainFrame.marketBrowser.jump(item)
|
||||
|
||||
@@ -24,21 +24,20 @@ class ProjectItem(ContextMenu):
|
||||
if fit.isStructure:
|
||||
return False
|
||||
|
||||
item = selection[0]
|
||||
return item.isType("projected")
|
||||
return mainItem.isType("projected")
|
||||
|
||||
def getText(self, itmContext, mainItem, selection):
|
||||
return "Project {0} onto Fit".format(itmContext)
|
||||
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
category = selection[0].category.name
|
||||
category = mainItem.category.name
|
||||
if category == 'Module':
|
||||
success = self.mainFrame.command.Submit(cmd.GuiAddProjectedModuleCommand(fitID=fitID, itemID=selection[0].ID))
|
||||
success = self.mainFrame.command.Submit(cmd.GuiAddProjectedModuleCommand(fitID=fitID, itemID=mainItem.ID))
|
||||
elif category == 'Drone':
|
||||
success = self.mainFrame.command.Submit(cmd.GuiAddProjectedDroneCommand(fitID=fitID, itemID=selection[0].ID))
|
||||
success = self.mainFrame.command.Submit(cmd.GuiAddProjectedDroneCommand(fitID=fitID, itemID=mainItem.ID))
|
||||
elif category == 'Fighter':
|
||||
success = self.mainFrame.command.Submit(cmd.GuiAddProjectedFighterCommand(fitID=fitID, itemID=selection[0].ID))
|
||||
success = self.mainFrame.command.Submit(cmd.GuiAddProjectedFighterCommand(fitID=fitID, itemID=mainItem.ID))
|
||||
else:
|
||||
success = False
|
||||
if success:
|
||||
|
||||
@@ -40,57 +40,47 @@ class RemoveItem(ContextMenu):
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveLocalModuleCommand(
|
||||
fitID=fitID, positions=positions))
|
||||
elif srcContext == "droneItem":
|
||||
drone = selection[0]
|
||||
if drone in fit.drones:
|
||||
position = fit.drones.index(drone)
|
||||
if mainItem in fit.drones:
|
||||
position = fit.drones.index(mainItem)
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveLocalDroneCommand(
|
||||
fitID=fitID, position=position, amount=math.inf))
|
||||
elif srcContext == "fighterItem":
|
||||
fighter = selection[0]
|
||||
if fighter in fit.fighters:
|
||||
position = fit.fighters.index(fighter)
|
||||
if mainItem in fit.fighters:
|
||||
position = fit.fighters.index(mainItem)
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveLocalFighterCommand(
|
||||
fitID=fitID, position=position))
|
||||
elif srcContext == "implantItem":
|
||||
implant = selection[0]
|
||||
if implant in fit.implants:
|
||||
position = fit.implants.index(implant)
|
||||
if mainItem in fit.implants:
|
||||
position = fit.implants.index(mainItem)
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveImplantCommand(
|
||||
fitID=fitID, position=position))
|
||||
elif srcContext == "boosterItem":
|
||||
booster = selection[0]
|
||||
if booster in fit.boosters:
|
||||
position = fit.boosters.index(booster)
|
||||
if mainItem in fit.boosters:
|
||||
position = fit.boosters.index(mainItem)
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveBoosterCommand(
|
||||
fitID=fitID, position=position))
|
||||
elif srcContext == "cargoItem":
|
||||
cargo = selection[0]
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCargoCommand(
|
||||
fitID=fitID, itemID=cargo.itemID))
|
||||
fitID=fitID, itemID=mainItem.itemID))
|
||||
elif srcContext == "projectedFit":
|
||||
projectedFit = selection[0]
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveProjectedFitCommand(
|
||||
fitID=fitID, projectedFitID=projectedFit.ID, amount=math.inf))
|
||||
fitID=fitID, projectedFitID=mainItem.ID, amount=math.inf))
|
||||
elif srcContext == "projectedModule":
|
||||
mod = selection[0]
|
||||
if mod in fit.projectedModules:
|
||||
position = fit.projectedModules.index(mod)
|
||||
if mainItem in fit.projectedModules:
|
||||
position = fit.projectedModules.index(mainItem)
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveProjectedModuleCommand(
|
||||
fitID=fitID, position=position))
|
||||
elif srcContext == "projectedDrone":
|
||||
drone = selection[0]
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveProjectedDroneCommand(
|
||||
fitID=fitID, itemID=drone.itemID, amount=math.inf))
|
||||
fitID=fitID, itemID=mainItem.itemID, amount=math.inf))
|
||||
elif srcContext == "projectedFighter":
|
||||
fighter = selection[0]
|
||||
if fighter in fit.projectedFighters:
|
||||
position = fit.projectedFighters.index(fighter)
|
||||
if mainItem in fit.projectedFighters:
|
||||
position = fit.projectedFighters.index(mainItem)
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveProjectedFighterCommand(
|
||||
fitID=fitID, position=position))
|
||||
elif srcContext == "commandFit":
|
||||
commandFit = selection[0]
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCommandFitCommand(
|
||||
fitID=fitID, commandFitID=commandFit.ID))
|
||||
fitID=fitID, commandFitID=mainItem.ID))
|
||||
|
||||
|
||||
RemoveItem.register()
|
||||
|
||||
@@ -35,9 +35,9 @@ class ItemStats(ContextMenu):
|
||||
sFit = Fit.getInstance()
|
||||
stuff = sFit.getFit(fitID).ship
|
||||
elif srcContext == "fittingMode":
|
||||
stuff = selection[0].item
|
||||
stuff = mainItem.item
|
||||
else:
|
||||
stuff = selection[0]
|
||||
stuff = mainItem
|
||||
|
||||
if srcContext == "fittingModule" and stuff.isEmpty:
|
||||
return
|
||||
|
||||
@@ -43,6 +43,7 @@ class ChangeItemToVariation(ContextMenu):
|
||||
if variations != self.variations:
|
||||
return False
|
||||
|
||||
self.mainItem = mainItem
|
||||
self.selection = selection
|
||||
|
||||
if len(self.variations) == 1:
|
||||
@@ -145,45 +146,45 @@ class ChangeItemToVariation(ContextMenu):
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeLocalModuleMetasCommand(
|
||||
fitID=fitID, positions=positions, newItemID=item.ID))
|
||||
elif context == 'droneItem':
|
||||
drone = self.selection[0]
|
||||
drone = self.mainItem
|
||||
if drone in fit.drones:
|
||||
position = fit.drones.index(drone)
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeLocalDroneMetaCommand(
|
||||
fitID=fitID, position=position, newItemID=item.ID))
|
||||
elif context == 'fighterItem':
|
||||
fighter = self.selection[0]
|
||||
fighter = self.mainItem
|
||||
if fighter in fit.fighters:
|
||||
position = fit.fighters.index(fighter)
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeLocalFighterMetaCommand(
|
||||
fitID=fitID, position=position, newItemID=item.ID))
|
||||
elif context == 'implantItem':
|
||||
implant = self.selection[0]
|
||||
implant = self.mainItem
|
||||
if implant in fit.implants:
|
||||
position = fit.implants.index(implant)
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeImplantMetaCommand(
|
||||
fitID=fitID, position=position, newItemID=item.ID))
|
||||
elif context == 'boosterItem':
|
||||
booster = self.selection[0]
|
||||
booster = self.mainItem
|
||||
if booster in fit.boosters:
|
||||
position = fit.boosters.index(booster)
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeBoosterMetaCommand(
|
||||
fitID=fitID, position=position, newItemID=item.ID))
|
||||
elif context == 'cargoItem':
|
||||
cargo = self.selection[0]
|
||||
cargo = self.mainItem
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeCargoMetaCommand(
|
||||
fitID=fitID, itemID=cargo.itemID, newItemID=item.ID))
|
||||
elif context == 'projectedModule':
|
||||
mod = self.selection[0]
|
||||
mod = self.mainItem
|
||||
if mod in fit.projectedModules:
|
||||
position = fit.projectedModules.index(mod)
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeProjectedModuleMetaCommand(
|
||||
fitID=fitID, position=position, newItemID=item.ID))
|
||||
elif context == 'projectedDrone':
|
||||
drone = self.selection[0]
|
||||
drone = self.mainItem
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeProjectedDroneMetaCommand(
|
||||
fitID=fitID, itemID=drone.itemID, newItemID=item.ID))
|
||||
elif context == 'projectedFighter':
|
||||
fighter = self.selection[0]
|
||||
fighter = self.mainItem
|
||||
if fighter in fit.projectedFighters:
|
||||
position = fit.projectedFighters.index(fighter)
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeProjectedFighterMetaCommand(
|
||||
|
||||
@@ -25,7 +25,7 @@ class ChangeModuleAmmo(ContextMenu):
|
||||
if self.mainFrame.getActiveFit() is None or srcContext not in ("fittingModule", "projectedModule"):
|
||||
return False
|
||||
|
||||
modules = selection if srcContext == "fittingModule" else (selection[0],)
|
||||
modules = selection if srcContext == "fittingModule" else (mainItem,)
|
||||
|
||||
validCharges = None
|
||||
checkedTypes = set()
|
||||
|
||||
@@ -25,9 +25,8 @@ class FillWithModule(ContextMenu):
|
||||
|
||||
if srcContext == "fittingModule":
|
||||
fit = Fit.getInstance().getFit(fitID)
|
||||
mod = selection[0]
|
||||
if mod in fit.modules:
|
||||
position = fit.modules.index(mod)
|
||||
if mainItem in fit.modules:
|
||||
position = fit.modules.index(mainItem)
|
||||
self.mainFrame.command.Submit(cmd.GuiFillWithClonedLocalModulesCommand(
|
||||
fitID=fitID, position=position))
|
||||
|
||||
|
||||
@@ -22,32 +22,28 @@ class ChangeModuleMutation(ContextMenu):
|
||||
if srcContext != "fittingModule" or self.mainFrame.getActiveFit() is None:
|
||||
return False
|
||||
|
||||
mod = selection[0]
|
||||
if len(mod.item.mutaplasmids) == 0 and not mod.isMutated:
|
||||
if len(mainItem.item.mutaplasmids) == 0 and not mainItem.isMutated:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem, selection):
|
||||
mod = selection[0]
|
||||
return "Apply Mutaplasmid" if not mod.isMutated else "Revert to {}".format(mod.baseItem.name)
|
||||
return "Apply Mutaplasmid" if not mainItem.isMutated else "Revert to {}".format(mainItem.baseItem.name)
|
||||
|
||||
def getSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
if selection[0].isMutated:
|
||||
if mainItem.isMutated:
|
||||
return None
|
||||
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
self.skillIds = {}
|
||||
sub = wx.Menu()
|
||||
|
||||
mod = selection[0]
|
||||
|
||||
menu = rootMenu if msw else sub
|
||||
|
||||
for item in mod.item.mutaplasmids:
|
||||
for item in mainItem.item.mutaplasmids:
|
||||
label = item.item.name
|
||||
id = ContextMenu.nextID()
|
||||
self.eventIDs[id] = (item, mod)
|
||||
self.eventIDs[id] = (item, mainItem)
|
||||
skillItem = wx.MenuItem(menu, id, label)
|
||||
menu.Bind(wx.EVT_MENU, self.handleMenu, skillItem)
|
||||
sub.Append(skillItem)
|
||||
@@ -64,11 +60,10 @@ class ChangeModuleMutation(ContextMenu):
|
||||
fitID=fitID, position=position, mutaplasmid=mutaplasmid))
|
||||
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
mod = selection[0]
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
fit = Fit.getInstance().getFit(fitID)
|
||||
if mod in fit.modules:
|
||||
position = fit.modules.index(mod)
|
||||
if mainItem in fit.modules:
|
||||
position = fit.modules.index(mainItem)
|
||||
self.mainFrame.command.Submit(GuiRevertMutatedLocalModuleCommand(
|
||||
fitID=fitID, position=position))
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class ChangeModuleSpool(ContextMenu):
|
||||
if srcContext not in ('fittingModule', 'projectedModule') or self.mainFrame.getActiveFit() is None:
|
||||
return False
|
||||
|
||||
self.mod = selection[0]
|
||||
self.mod = mainItem
|
||||
self.context = srcContext
|
||||
|
||||
return self.mod.item.group.name in ("Precursor Weapon", "Mutadaptive Remote Armor Repairer")
|
||||
|
||||
@@ -39,9 +39,9 @@ class ChangeAffectingSkills(ContextMenu):
|
||||
self.stuff = sFit.getFit(fitID).ship
|
||||
cont = sFit.getFit(fitID).ship.itemModifiedAttributes
|
||||
elif srcContext == "fittingCharge":
|
||||
cont = selection[0].chargeModifiedAttributes
|
||||
cont = mainItem.chargeModifiedAttributes
|
||||
else:
|
||||
cont = selection[0].itemModifiedAttributes
|
||||
cont = mainItem.itemModifiedAttributes
|
||||
|
||||
skills = set()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user