Implement fittingMode

(cherry picked from commit 5eb2fef)
This commit is contained in:
Ebag333
2016-12-08 18:56:43 -08:00
parent ea3a374ced
commit b529a28715
4 changed files with 21 additions and 21 deletions

View File

@@ -15,7 +15,8 @@ class ItemRemove(ContextMenu):
"boosterItem", "projectedModule",
"projectedCharge", "cargoItem",
"projectedFit", "projectedDrone",
"fighterItem", "projectedFighter")
"fighterItem", "projectedFighter",
"fittingMode",)
def getText(self, itmContext, selection):
return "Remove {0}".format(itmContext if itmContext is not None else "Item")

View File

@@ -19,7 +19,8 @@ class ItemStats(ContextMenu):
"skillItem", "projectedModule",
"projectedDrone", "projectedCharge",
"itemStats", "fighterItem",
"implantItemChar", "projectedFighter")
"implantItemChar", "projectedFighter",
"fittingMode")
def getText(self, itmContext, selection):
return "{0} Stats".format(itmContext if itmContext is not None else "Item")
@@ -30,6 +31,8 @@ class ItemStats(ContextMenu):
fitID = self.mainFrame.getActiveFit()
sFit = Fit.getInstance()
stuff = sFit.getFit(fitID).ship
elif srcContext == "fittingMode":
stuff = selection[0].item
else:
stuff = selection[0]

View File

@@ -501,12 +501,19 @@ class FittingView(d.Display):
while sel != -1 and sel not in self.blanks:
mod = self.mods[self.GetItemData(sel)]
# Test if mod.isEmpty does not exist.
# Certain special module can be missing this trait
# Example: T3D modes
if not hasattr(mod, 'isEmpty'):
# Set it if missing, prevents later stack traces.
mod.isEmpty = False
# Test if this is a mode, which is a special snowflake of a Module
if hasattr(mod, "_Mode__item"):
srcContext = "fittingMode"
# Skip the normal processing
mod.isEmpty = True
itemContext = sMkt.getCategoryByItem(mod.item).name
fullContext = (srcContext, itemContext)
if not srcContext in tuple(fCtxt[0] for fCtxt in contexts):
contexts.append(fullContext)
selection.append(mod)
if not mod.isEmpty:
srcContext = "fittingModule"
@@ -515,12 +522,6 @@ class FittingView(d.Display):
if srcContext not in tuple(fCtxt[0] for fCtxt in contexts):
contexts.append(fullContext)
# Test if mod.charge exists
try:
mod.charge
except AttributeError:
# The attribute doesn't exist at all. Set to none so we don't get errors later.
mod.charge = None
if mod.charge is not None:
srcContext = "fittingCharge"

View File

@@ -72,13 +72,8 @@ class ContextMenu(object):
texts = m.getText(itemContext, selection)
# Check the selected item to see if it has special reasons for not showing the menu item
skip_menu_item = False
for sel in selection:
if hasattr(sel, "_Mode__item") and texts == "Remove Module":
# Don't show remove for modes, these are special modules that cannot be removed
skip_menu_item = True
if skip_menu_item == True:
if srcContext == "fittingMode" and texts == "Remove Module":
# Don't show remove for modes, these are special modules that cannot be removed
continue
if isinstance(texts, basestring):