From 1a127bb1a6e56fff90e7fffc9fddca6507cd3fca Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Thu, 8 Dec 2016 13:12:15 -0800 Subject: [PATCH] Add ability to look at tactical mode item info. (cherry picked from commit f5776a0) --- eos/saveddata/mode.py | 5 +++++ gui/builtinViews/fittingView.py | 23 ++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/eos/saveddata/mode.py b/eos/saveddata/mode.py index 2b3108a9d..d505807b9 100644 --- a/eos/saveddata/mode.py +++ b/eos/saveddata/mode.py @@ -53,3 +53,8 @@ class Mode(ItemAttrShortcut, HandledItem): for effect in self.item.effects.itervalues(): if effect.runTime == runTime and effect.activeByDefault: effect.handler(fit, self, context=("module",)) + + def getValidCharges(self): + # Modes don't have charges, but it is queried for so return nothing. + validCharges = set() + return validCharges diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index 7e9d09d80..f707731c6 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -344,7 +344,11 @@ class FittingView(d.Display): def removeModule(self, module): sFit = Fit.getInstance() fit = sFit.getFit(self.activeFitID) - populate = sFit.removeModule(self.activeFitID, fit.modules.index(module)) + try: + populate = sFit.removeModule(self.activeFitID, fit.modules.index(module)) + except ValueError: + # This module isn't in our list of modules, don't remove anything. Likely a special snowflake. + populate = None if populate is not None: self.slotsChanged() @@ -446,12 +450,11 @@ class FittingView(d.Display): if fit.mode: # Modes are special snowflakes and need a little manual loving # We basically append the Mode rack and Mode to the modules - # while also marking their positions in the Blanks list + # while also marking the mode header position in the Blanks list if sFit.serviceFittingOptions["rackSlots"]: self.blanks.append(len(self.mods)) self.mods.append(Rack.buildRack(Slot.MODE)) - self.blanks.append(len(self.mods)) self.mods.append(fit.mode) else: self.mods = None @@ -493,12 +496,26 @@ class FittingView(d.Display): while sel != -1 and sel not in self.blanks: mod = self.mods[self.GetItemData(sel)] + + # Test if mod.isEmpty exists. + try: + mod.isEmpty + except AttributeError: + mod.isEmpty = False + if not mod.isEmpty: srcContext = "fittingModule" itemContext = sMkt.getCategoryByItem(mod.item).name fullContext = (srcContext, itemContext) if srcContext not in tuple(fCtxt[0] for fCtxt in contexts): contexts.append(fullContext) + + # Test if mod.charge exists + try: + mod.charge + except AttributeError: + mod.charge = None + if mod.charge is not None: srcContext = "fittingCharge" itemContext = sMkt.getCategoryByItem(mod.charge).name