Implement fittingMode

This commit is contained in:
Ebag333
2016-12-08 18:56:43 -08:00
parent 9403a1fce9
commit 5eb2fef89c
4 changed files with 21 additions and 21 deletions

View File

@@ -14,7 +14,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

@@ -18,7 +18,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")
@@ -29,6 +30,8 @@ class ItemStats(ContextMenu):
fitID = self.mainFrame.getActiveFit()
sFit = service.Fit.getInstance()
stuff = sFit.getFit(fitID).ship
elif srcContext == "fittingMode":
stuff = selection[0].item
else:
stuff = selection[0]

View File

@@ -496,12 +496,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"
@@ -510,12 +517,6 @@ class FittingView(d.Display):
if not srcContext 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

@@ -71,13 +71,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):