From a3dfa3b5ba15f035e3bf9e76e434215dc0e8a53e Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Wed, 9 Nov 2016 00:46:19 -0800 Subject: [PATCH 1/4] Make Effects Togglable --- eos/db/saveddata/booster.py | 1 + eos/effects/boosterarmorhppenalty.py | 1 + .../boosterarmorrepairamountpenalty.py | 1 + .../boostercapacitorcapacitypenalty.py | 1 + eos/effects/boostermaxvelocitypenalty.py | 1 + ...oostermissileexplosioncloudpenaltyfixed.py | 1 + .../boostermissileexplosionvelocitypenalty.py | 1 + eos/effects/boostermissilevelocitypenalty.py | 1 + eos/effects/boostershieldcapacitypenalty.py | 1 + eos/effects/boosterturretfalloffpenalty.py | 1 + .../boosterturretoptimalrangepenalty.py | 1 + eos/effects/boosterturrettrackingpenalty.py | 1 + eos/gamedata.py | 28 ++++++ eos/saveddata/booster.py | 73 ++++++++------ eos/saveddata/character.py | 5 +- eos/saveddata/drone.py | 7 +- eos/saveddata/fighter.py | 1 + eos/saveddata/fit.py | 2 +- eos/saveddata/implant.py | 2 +- eos/saveddata/mode.py | 2 +- eos/saveddata/module.py | 10 +- eos/saveddata/ship.py | 4 +- eos/types.py | 3 +- gui/itemStats.py | 95 +++++++++++++++---- 24 files changed, 184 insertions(+), 60 deletions(-) diff --git a/eos/db/saveddata/booster.py b/eos/db/saveddata/booster.py index a31904b12..30afa0589 100644 --- a/eos/db/saveddata/booster.py +++ b/eos/db/saveddata/booster.py @@ -31,6 +31,7 @@ boosters_table = Table("boosters", saveddata_meta, Column("active", Boolean), ) +# Legacy booster side effect code, should disable but a mapper relies on it. activeSideEffects_table = Table("boostersActiveSideEffects", saveddata_meta, Column("boosterID", ForeignKey("boosters.ID"), primary_key = True), Column("effectID", Integer, primary_key = True)) diff --git a/eos/effects/boosterarmorhppenalty.py b/eos/effects/boosterarmorhppenalty.py index 247ecae3e..c92185997 100644 --- a/eos/effects/boosterarmorhppenalty.py +++ b/eos/effects/boosterarmorhppenalty.py @@ -3,5 +3,6 @@ # Used by: # Implants from group: Booster (12 of 45) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): fit.ship.boostItemAttr("armorHP", booster.getModifiedItemAttr("boosterArmorHPPenalty")) diff --git a/eos/effects/boosterarmorrepairamountpenalty.py b/eos/effects/boosterarmorrepairamountpenalty.py index eaf28ae3e..800e8b421 100644 --- a/eos/effects/boosterarmorrepairamountpenalty.py +++ b/eos/effects/boosterarmorrepairamountpenalty.py @@ -5,6 +5,7 @@ # Implants named like: Mindflood Booster (3 of 4) # Implants named like: Sooth Sayer Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): fit.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Armor Repair Unit", "armorDamageAmount", booster.getModifiedItemAttr("boosterArmorRepairAmountPenalty")) diff --git a/eos/effects/boostercapacitorcapacitypenalty.py b/eos/effects/boostercapacitorcapacitypenalty.py index f48bce938..59f0c4de4 100644 --- a/eos/effects/boostercapacitorcapacitypenalty.py +++ b/eos/effects/boostercapacitorcapacitypenalty.py @@ -4,5 +4,6 @@ # Implants named like: Blue Pill Booster (3 of 5) # Implants named like: Exile Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): fit.ship.boostItemAttr("capacitorCapacity", booster.getModifiedItemAttr("boosterCapacitorCapacityPenalty")) diff --git a/eos/effects/boostermaxvelocitypenalty.py b/eos/effects/boostermaxvelocitypenalty.py index 410f89c53..1300eb5c2 100644 --- a/eos/effects/boostermaxvelocitypenalty.py +++ b/eos/effects/boostermaxvelocitypenalty.py @@ -3,5 +3,6 @@ # Used by: # Implants from group: Booster (12 of 45) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): fit.ship.boostItemAttr("maxVelocity", booster.getModifiedItemAttr("boosterMaxVelocityPenalty")) diff --git a/eos/effects/boostermissileexplosioncloudpenaltyfixed.py b/eos/effects/boostermissileexplosioncloudpenaltyfixed.py index be70ee93d..cd5a3ee90 100644 --- a/eos/effects/boostermissileexplosioncloudpenaltyfixed.py +++ b/eos/effects/boostermissileexplosioncloudpenaltyfixed.py @@ -4,6 +4,7 @@ # Implants named like: Exile Booster (3 of 4) # Implants named like: Mindflood Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"), "aoeCloudSize", booster.getModifiedItemAttr("boosterMissileAOECloudPenalty")) diff --git a/eos/effects/boostermissileexplosionvelocitypenalty.py b/eos/effects/boostermissileexplosionvelocitypenalty.py index d61092b1a..655927499 100644 --- a/eos/effects/boostermissileexplosionvelocitypenalty.py +++ b/eos/effects/boostermissileexplosionvelocitypenalty.py @@ -3,6 +3,7 @@ # Used by: # Implants named like: Blue Pill Booster (3 of 5) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"), "aoeVelocity", booster.getModifiedItemAttr("boosterAOEVelocityPenalty")) diff --git a/eos/effects/boostermissilevelocitypenalty.py b/eos/effects/boostermissilevelocitypenalty.py index c3fc28fe7..9a13ac5ed 100644 --- a/eos/effects/boostermissilevelocitypenalty.py +++ b/eos/effects/boostermissilevelocitypenalty.py @@ -4,6 +4,7 @@ # Implants named like: Crash Booster (3 of 4) # Implants named like: X Instinct Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"), "maxVelocity", "boosterMissileVelocityPenalty") diff --git a/eos/effects/boostershieldcapacitypenalty.py b/eos/effects/boostershieldcapacitypenalty.py index 690ec5b82..3d4139640 100644 --- a/eos/effects/boostershieldcapacitypenalty.py +++ b/eos/effects/boostershieldcapacitypenalty.py @@ -3,5 +3,6 @@ # Used by: # Implants from group: Booster (12 of 45) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): fit.ship.boostItemAttr("shieldCapacity", booster.getModifiedItemAttr("boosterShieldCapacityPenalty")) diff --git a/eos/effects/boosterturretfalloffpenalty.py b/eos/effects/boosterturretfalloffpenalty.py index 3a57f1f6e..9377f8783 100644 --- a/eos/effects/boosterturretfalloffpenalty.py +++ b/eos/effects/boosterturretfalloffpenalty.py @@ -4,6 +4,7 @@ # Implants named like: Drop Booster (3 of 4) # Implants named like: X Instinct Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"), "falloff", booster.getModifiedItemAttr("boosterTurretFalloffPenalty")) diff --git a/eos/effects/boosterturretoptimalrangepenalty.py b/eos/effects/boosterturretoptimalrangepenalty.py index cc9fd9224..1134cd15e 100644 --- a/eos/effects/boosterturretoptimalrangepenalty.py +++ b/eos/effects/boosterturretoptimalrangepenalty.py @@ -5,6 +5,7 @@ # Implants named like: Mindflood Booster (3 of 4) # Implants named like: Sooth Sayer Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"), "maxRange", booster.getModifiedItemAttr("boosterTurretOptimalRange")) diff --git a/eos/effects/boosterturrettrackingpenalty.py b/eos/effects/boosterturrettrackingpenalty.py index dc7b852b3..bc04a4a02 100644 --- a/eos/effects/boosterturrettrackingpenalty.py +++ b/eos/effects/boosterturrettrackingpenalty.py @@ -4,6 +4,7 @@ # Implants named like: Exile Booster (3 of 4) # Implants named like: Frentix Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"), "trackingSpeed", booster.getModifiedItemAttr("boosterTurretTrackingPenalty")) diff --git a/eos/gamedata.py b/eos/gamedata.py index 5f3f62bb3..0bba448ec 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -83,6 +83,28 @@ class Effect(EqBase): return self.__runTime + @property + def activeByDefault(self): + ''' + The runTime that this effect should be run at. + This property is also automaticly fetched from effects/.py if the file exists. + the possible values are: + None, True, False + None and False are equivalent. True is the default if the effect is also implemented. + + effects that are not active will not be calculated. + ''' + if not self.__generated: + self.__generateHandler() + + return self.__activeByDefault + + @activeByDefault.setter + def activeByDefault(self, value): + # Just assign the input values to the ``numbers`` attribute. + # You *could* do something more interesting here if you wanted. + self.__activeByDefault = value + @property def type(self): ''' @@ -133,6 +155,11 @@ class Effect(EqBase): except AttributeError: self.__runTime = "normal" + try: + self.__activeByDefault = getattr(effectModule, "activeByDefault") + except AttributeError: + self.__activeByDefault = True + try: t = getattr(effectModule, "type") except AttributeError: @@ -143,6 +170,7 @@ class Effect(EqBase): except (ImportError, AttributeError) as e: self.__handler = effectDummy self.__runTime = "normal" + self.__activeByDefault = True self.__type = None except Exception as e: traceback.print_exc(e) diff --git a/eos/saveddata/booster.py b/eos/saveddata/booster.py index 9d0e98ae0..934321363 100644 --- a/eos/saveddata/booster.py +++ b/eos/saveddata/booster.py @@ -61,13 +61,18 @@ class Booster(HandledItem, ItemAttrShortcut): self.__itemModifiedAttributes.overrides = self.__item.overrides self.__slot = self.__calculateSlot(self.__item) + # Legacy booster side effect code, disabling as not currently implemented + ''' for effect in self.__item.effects.itervalues(): if effect.isType("boosterSideEffect"): s = SideEffect(self) s.effect = effect s.active = effect.ID in self.__activeSideEffectIDs self.__sideEffects.append(s) + ''' + # Legacy booster side effect code, disabling as not currently implemented + ''' def iterSideEffects(self): return self.__sideEffects.__iter__() @@ -77,6 +82,7 @@ class Booster(HandledItem, ItemAttrShortcut): return sideEffect raise KeyError("SideEffect with %s as name not found" % name) + ''' @property def itemModifiedAttributes(self): @@ -107,12 +113,17 @@ class Booster(HandledItem, ItemAttrShortcut): if forceProjected: return if self.active == False: return for effect in self.item.effects.itervalues(): - if effect.runTime == runTime and effect.isType("passive"): + if effect.runTime == runTime and \ + (effect.isType("passive") or effect.isType("boosterSideEffect")) and \ + effect.activeByDefault: effect.handler(fit, self, ("booster",)) + # Legacy booster code, not fully implemented + ''' for sideEffect in self.iterSideEffects(): if sideEffect.active and sideEffect.effect.runTime == runTime: sideEffect.effect.handler(fit, self, ("boosterSideEffect",)) + ''' @validates("ID", "itemID", "ammoID", "active") def validator(self, key, val): @@ -128,46 +139,52 @@ class Booster(HandledItem, ItemAttrShortcut): def __deepcopy__(self, memo): copy = Booster(self.item) copy.active = self.active + + # Legacy booster side effect code, disabling as not currently implemented + ''' origSideEffects = list(self.iterSideEffects()) copySideEffects = list(copy.iterSideEffects()) i = 0 while i < len(origSideEffects): copySideEffects[i].active = origSideEffects[i].active i += 1 + ''' return copy +# Legacy booster side effect code, disabling as not currently implemented +''' + class SideEffect(object): + def __init__(self, owner): + self.__owner = owner + self.__active = False + self.__effect = None -class SideEffect(object): - def __init__(self, owner): - self.__owner = owner - self.__active = False - self.__effect = None + @property + def active(self): + return self.__active - @property - def active(self): - return self.__active + @active.setter + def active(self, active): + if not isinstance(active, bool): + raise TypeError("Expecting a bool, not a " + type(active)) - @active.setter - def active(self, active): - if not isinstance(active, bool): - raise TypeError("Expecting a bool, not a " + type(active)) + if active != self.__active: + if active: + self.__owner._Booster__activeSideEffectIDs.append(self.effect.ID) + else: + self.__owner._Booster__activeSideEffectIDs.remove(self.effect.ID) - if active != self.__active: - if active: - self.__owner._Booster__activeSideEffectIDs.append(self.effect.ID) - else: - self.__owner._Booster__activeSideEffectIDs.remove(self.effect.ID) + self.__active = active - self.__active = active + @property + def effect(self): + return self.__effect - @property - def effect(self): - return self.__effect + @effect.setter + def effect(self, effect): + if not hasattr(effect, "handler"): + raise TypeError("Need an effect with a handler") - @effect.setter - def effect(self, effect): - if not hasattr(effect, "handler"): - raise TypeError("Need an effect with a handler") - - self.__effect = effect + self.__effect = effect +''' \ No newline at end of file diff --git a/eos/saveddata/character.py b/eos/saveddata/character.py index 1f5832ea2..ac6a199a9 100644 --- a/eos/saveddata/character.py +++ b/eos/saveddata/character.py @@ -330,7 +330,10 @@ class Skill(HandledItem): return for effect in item.effects.itervalues(): - if effect.runTime == runTime and effect.isType("passive") and (not fit.isStructure or effect.isType("structure")): + if effect.runTime == runTime and \ + effect.isType("passive") and \ + (not fit.isStructure or effect.isType("structure")) and \ + effect.activeByDefault: try: effect.handler(fit, self, ("skill",)) except AttributeError: diff --git a/eos/saveddata/drone.py b/eos/saveddata/drone.py index 8033384ab..a2e868887 100644 --- a/eos/saveddata/drone.py +++ b/eos/saveddata/drone.py @@ -220,8 +220,9 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): for effect in self.item.effects.itervalues(): if effect.runTime == runTime and \ - ((projected == True and effect.isType("projected")) or \ - projected == False and effect.isType("passive")): + effect.activeByDefault and \ + ((projected == True and effect.isType("projected")) or \ + projected == False and effect.isType("passive")): # See GH issue #765 if effect.getattr('grouped'): effect.handler(fit, self, context) @@ -233,7 +234,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): if self.charge: for effect in self.charge.effects.itervalues(): - if effect.runTime == runTime: + if effect.runTime == runTime and effect.activeByDefault: effect.handler(fit, self, ("droneCharge",)) def __deepcopy__(self, memo): diff --git a/eos/saveddata/fighter.py b/eos/saveddata/fighter.py index bc96c5f10..5647e75e9 100644 --- a/eos/saveddata/fighter.py +++ b/eos/saveddata/fighter.py @@ -260,6 +260,7 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): if ability.active: effect = ability.effect if effect.runTime == runTime and \ + effect.activeByDefault and \ ((projected and effect.isType("projected")) or not projected): if ability.grouped: effect.handler(fit, self, context) diff --git a/eos/saveddata/fit.py b/eos/saveddata/fit.py index a3000267f..ff731031c 100644 --- a/eos/saveddata/fit.py +++ b/eos/saveddata/fit.py @@ -435,7 +435,7 @@ class Fit(object): for name, info in self.gangBoosts.iteritems(): # Unpack all data required to run effect properly effect, thing = info[1] - if effect.runTime == runTime: + if effect.runTime == runTime and effect.activeByDefault: context = ("gang", thing.__class__.__name__.lower()) if isinstance(thing, Module): if effect.isType("offline") or (effect.isType("passive") and thing.state >= State.ONLINE) or \ diff --git a/eos/saveddata/implant.py b/eos/saveddata/implant.py index a4a6de74d..4ab8dd85e 100644 --- a/eos/saveddata/implant.py +++ b/eos/saveddata/implant.py @@ -88,7 +88,7 @@ class Implant(HandledItem, ItemAttrShortcut): if forceProjected: return if self.active == False: return for effect in self.item.effects.itervalues(): - if effect.runTime == runTime and effect.isType("passive"): + if effect.runTime == runTime and effect.isType("passive") and effect.activeByDefault: effect.handler(fit, self, ("implant",)) @validates("fitID", "itemID", "active") diff --git a/eos/saveddata/mode.py b/eos/saveddata/mode.py index 91fbaf6eb..593bb761f 100644 --- a/eos/saveddata/mode.py +++ b/eos/saveddata/mode.py @@ -50,5 +50,5 @@ class Mode(ItemAttrShortcut, HandledItem): def calculateModifiedAttributes(self, fit, runTime, forceProjected = False): if self.item: for effect in self.item.effects.itervalues(): - if effect.runTime == runTime: + if effect.runTime == runTime and effect.activeByDefault: effect.handler(fit, self, context = ("module",)) diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index 049e98939..f9ff8cc3e 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -594,15 +594,16 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): # fix for #82 and it's regression #106 if not projected or (self.projected and not forceProjected): for effect in self.charge.effects.itervalues(): - if effect.runTime == runTime: + if effect.runTime == runTime and effect.activeByDefault: effect.handler(fit, self, ("moduleCharge",)) if self.item: if self.state >= State.OVERHEATED: for effect in self.item.effects.itervalues(): if effect.runTime == runTime and \ - effect.isType("overheat") and \ - not forceProjected: + effect.isType("overheat") and \ + not forceProjected and \ + effect.activeByDefault: effect.handler(fit, self, context) for effect in self.item.effects.itervalues(): @@ -610,7 +611,8 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): (effect.isType("offline") or (effect.isType("passive") and self.state >= State.ONLINE) or \ (effect.isType("active") and self.state >= State.ACTIVE)) and \ - ((projected and effect.isType("projected")) or not projected): + ((projected and effect.isType("projected")) or not projected) and \ + effect.activeByDefault: effect.handler(fit, self, context) @property diff --git a/eos/saveddata/ship.py b/eos/saveddata/ship.py index 4094534e6..6a2bc2861 100644 --- a/eos/saveddata/ship.py +++ b/eos/saveddata/ship.py @@ -78,7 +78,9 @@ class Ship(ItemAttrShortcut, HandledItem): def calculateModifiedAttributes(self, fit, runTime, forceProjected = False): if forceProjected: return for effect in self.item.effects.itervalues(): - if effect.runTime == runTime and effect.isType("passive"): + if effect.runTime == runTime and \ + effect.isType("passive") and \ + effect.activeByDefault: # Ships have effects that utilize the level of a skill as an # additional operator to the modifier. These are defined in # the effect itself, and these skillbooks are registered when diff --git a/eos/types.py b/eos/types.py index 12e7eb281..457e11ad7 100644 --- a/eos/types.py +++ b/eos/types.py @@ -34,7 +34,8 @@ from eos.saveddata.fighter import Fighter from eos.saveddata.cargo import Cargo from eos.saveddata.implant import Implant from eos.saveddata.implantSet import ImplantSet -from eos.saveddata.booster import SideEffect +# Legacy booster side effect code, disabling as not currently implemented +# from eos.saveddata.booster import SideEffect from eos.saveddata.booster import Booster from eos.saveddata.fit import Fit, ImplantLocation from eos.saveddata.mode import Mode diff --git a/gui/itemStats.py b/gui/itemStats.py index 5223a0b07..63e4ce67d 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -740,31 +740,44 @@ class ItemRequirements ( wx.Panel ): class ItemEffects (wx.Panel): def __init__(self, parent, stuff, item): - wx.Panel.__init__ (self, parent) - mainSizer = wx.BoxSizer( wx.VERTICAL ) + wx.Panel.__init__(self, parent) + self.item = item + + mainSizer = wx.BoxSizer(wx.VERTICAL) self.effectList = AutoListCtrl(self, wx.ID_ANY, - style = - #wx.LC_HRULES | - #wx.LC_NO_HEADER | - wx.LC_REPORT |wx.LC_SINGLE_SEL |wx.LC_VRULES |wx.NO_BORDER) - mainSizer.Add( self.effectList, 1, wx.ALL|wx.EXPAND, 0 ) - self.SetSizer( mainSizer ) + style= + # wx.LC_HRULES | + # wx.LC_NO_HEADER | + wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES | wx.NO_BORDER) + mainSizer.Add(self.effectList, 1, wx.ALL | wx.EXPAND, 0) + self.SetSizer(mainSizer) + self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnClick, self.effectList) if config.debug: - self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnClick, self.effectList) + self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick, self.effectList) + + self.PopulateList() + + def PopulateList(self): self.effectList.InsertColumn(0,"Name") - self.effectList.InsertColumn(1,"Implemented") + self.effectList.InsertColumn(1,"Active") + self.effectList.InsertColumn(2, "Type") if config.debug: - self.effectList.InsertColumn(2,"ID") + self.effectList.InsertColumn(3, "Run Time") + self.effectList.InsertColumn(4,"ID") #self.effectList.SetColumnWidth(0,385) self.effectList.setResizeColumn(0) + self.effectList.SetColumnWidth(1,50) + self.effectList.SetColumnWidth(2, 80) + if config.debug: + self.effectList.SetColumnWidth(3, 65) + self.effectList.SetColumnWidth(4, 40) - self.effectList.SetColumnWidth(1,100) - + item = self.item effects = item.effects names = list(effects.iterkeys()) names.sort() @@ -772,19 +785,55 @@ class ItemEffects (wx.Panel): for name in names: index = self.effectList.InsertStringItem(sys.maxint, name) - try: - implemented = "Yes" if effects[name].isImplemented else "No" - except: - implemented = "Erroneous" + if effects[name].isImplemented: + if effects[name].activeByDefault: + activeByDefault = "Yes" + else: + activeByDefault = "No" + else: + activeByDefault = "" - self.effectList.SetStringItem(index, 1, implemented) + effectTypeText = "" + if effects[name].type: + for effectType in effects[name].type: + effectTypeText += effectType + " " + pass + + if effects[name].runTime and effects[name].isImplemented: + effectRunTime = str(effects[name].runTime) + else: + effectRunTime = "" + + self.effectList.SetStringItem(index, 1, activeByDefault) + self.effectList.SetStringItem(index, 2, effectTypeText) if config.debug: - self.effectList.SetStringItem(index, 2, str(effects[name].ID)) + self.effectList.SetStringItem(index, 3, effectRunTime) + self.effectList.SetStringItem(index, 4, str(effects[name].ID)) self.effectList.RefreshRows() self.Layout() def OnClick(self, event): + """ + Debug use: toggle effects on/off. + Affects *ALL* items that use that effect. + Is not stateful. Will reset if Pyfa is closed and reopened. + """ + + try: + activeByDefault = getattr(self.item.effects[event.GetText()], "activeByDefault") + if activeByDefault: + setattr(self.item.effects[event.GetText()], "activeByDefault", False) + else: + setattr(self.item.effects[event.GetText()], "activeByDefault", True) + + except AttributeError: + # Attribute doesn't exist, do nothing + pass + + self.RefreshValues(event) + + def OnRightClick(self, event): """ Debug use: open effect file with default application. If effect file does not exist, create it @@ -804,6 +853,14 @@ class ItemEffects (wx.Panel): import subprocess subprocess.call(["xdg-open", file]) + def RefreshValues(self, event): + self.Freeze() + self.effectList.ClearAll() + self.PopulateList() + self.effectList.RefreshRows() + self.Layout() + self.Thaw() + event.Skip() ########################################################################### ## Class ItemAffectedBy From fe9917e62052f942585d4bd7d3f96dddc8a7fb20 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Wed, 9 Nov 2016 07:21:27 -0800 Subject: [PATCH 2/4] Updated docstring with more information --- eos/gamedata.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/eos/gamedata.py b/eos/gamedata.py index 0bba448ec..986e447b5 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -85,15 +85,25 @@ class Effect(EqBase): @property def activeByDefault(self): - ''' - The runTime that this effect should be run at. + """ + The state that this effect should be be in. This property is also automaticly fetched from effects/.py if the file exists. the possible values are: None, True, False - None and False are equivalent. True is the default if the effect is also implemented. - effects that are not active will not be calculated. - ''' + If this is not set: + We simply assume that missing/none = True, and set it accordingly + (much as we set runTime to Normalif not otherwise set). + Nearly all effect files will fall under this category. + + If this is set to True: + We would enable it anyway, but hey, it's double enabled. + No effect files are currently configured this way (and probably will never be). + + If this is set to False: + Basically we simply skip adding the effect to the effect handler when the effect is called, + much as if the run time didn't match or other criteria failed. + """ if not self.__generated: self.__generateHandler() @@ -101,8 +111,10 @@ class Effect(EqBase): @activeByDefault.setter def activeByDefault(self, value): - # Just assign the input values to the ``numbers`` attribute. - # You *could* do something more interesting here if you wanted. + """ + Just assign the input values to the activeByDefault attribute. + You *could* do something more interesting here if you wanted. + """ self.__activeByDefault = value @property From 3aa60ac66903ef21a454b34a3021d470e6b6e497 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Wed, 9 Nov 2016 00:46:19 -0800 Subject: [PATCH 3/4] Make Effects Togglable --- eos/db/saveddata/booster.py | 1 + eos/effects/boosterarmorhppenalty.py | 1 + .../boosterarmorrepairamountpenalty.py | 1 + .../boostercapacitorcapacitypenalty.py | 1 + eos/effects/boostermaxvelocitypenalty.py | 1 + ...oostermissileexplosioncloudpenaltyfixed.py | 1 + .../boostermissileexplosionvelocitypenalty.py | 1 + eos/effects/boostermissilevelocitypenalty.py | 1 + eos/effects/boostershieldcapacitypenalty.py | 1 + eos/effects/boosterturretfalloffpenalty.py | 1 + .../boosterturretoptimalrangepenalty.py | 1 + eos/effects/boosterturrettrackingpenalty.py | 1 + eos/gamedata.py | 28 ++++++ eos/saveddata/booster.py | 73 ++++++++------ eos/saveddata/character.py | 3 +- eos/saveddata/drone.py | 3 +- eos/saveddata/fighter.py | 1 + eos/saveddata/fit.py | 2 +- eos/saveddata/implant.py | 2 +- eos/saveddata/mode.py | 2 +- eos/saveddata/module.py | 8 +- eos/saveddata/ship.py | 4 +- eos/types.py | 3 +- gui/itemStats.py | 95 +++++++++++++++---- 24 files changed, 179 insertions(+), 57 deletions(-) diff --git a/eos/db/saveddata/booster.py b/eos/db/saveddata/booster.py index 3a6334985..9b8272540 100644 --- a/eos/db/saveddata/booster.py +++ b/eos/db/saveddata/booster.py @@ -31,6 +31,7 @@ boosters_table = Table("boosters", saveddata_meta, Column("active", Boolean), ) +# Legacy booster side effect code, should disable but a mapper relies on it. activeSideEffects_table = Table("boostersActiveSideEffects", saveddata_meta, Column("boosterID", ForeignKey("boosters.ID"), primary_key=True), Column("effectID", Integer, primary_key=True)) diff --git a/eos/effects/boosterarmorhppenalty.py b/eos/effects/boosterarmorhppenalty.py index a77a9991d..006ea04a9 100644 --- a/eos/effects/boosterarmorhppenalty.py +++ b/eos/effects/boosterarmorhppenalty.py @@ -3,6 +3,7 @@ # Used by: # Implants from group: Booster (12 of 45) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): diff --git a/eos/effects/boosterarmorrepairamountpenalty.py b/eos/effects/boosterarmorrepairamountpenalty.py index fc7efa1ee..ac06a9c22 100644 --- a/eos/effects/boosterarmorrepairamountpenalty.py +++ b/eos/effects/boosterarmorrepairamountpenalty.py @@ -5,6 +5,7 @@ # Implants named like: Mindflood Booster (3 of 4) # Implants named like: Sooth Sayer Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): diff --git a/eos/effects/boostercapacitorcapacitypenalty.py b/eos/effects/boostercapacitorcapacitypenalty.py index a14324482..3a8351ac4 100644 --- a/eos/effects/boostercapacitorcapacitypenalty.py +++ b/eos/effects/boostercapacitorcapacitypenalty.py @@ -4,6 +4,7 @@ # Implants named like: Blue Pill Booster (3 of 5) # Implants named like: Exile Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): diff --git a/eos/effects/boostermaxvelocitypenalty.py b/eos/effects/boostermaxvelocitypenalty.py index 8de23ee0f..6dd139cb1 100644 --- a/eos/effects/boostermaxvelocitypenalty.py +++ b/eos/effects/boostermaxvelocitypenalty.py @@ -3,6 +3,7 @@ # Used by: # Implants from group: Booster (12 of 45) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): diff --git a/eos/effects/boostermissileexplosioncloudpenaltyfixed.py b/eos/effects/boostermissileexplosioncloudpenaltyfixed.py index 5c3758ccf..778e4b28c 100644 --- a/eos/effects/boostermissileexplosioncloudpenaltyfixed.py +++ b/eos/effects/boostermissileexplosioncloudpenaltyfixed.py @@ -4,6 +4,7 @@ # Implants named like: Exile Booster (3 of 4) # Implants named like: Mindflood Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): diff --git a/eos/effects/boostermissileexplosionvelocitypenalty.py b/eos/effects/boostermissileexplosionvelocitypenalty.py index 62a5d9d0a..e81a9fc96 100644 --- a/eos/effects/boostermissileexplosionvelocitypenalty.py +++ b/eos/effects/boostermissileexplosionvelocitypenalty.py @@ -3,6 +3,7 @@ # Used by: # Implants named like: Blue Pill Booster (3 of 5) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): diff --git a/eos/effects/boostermissilevelocitypenalty.py b/eos/effects/boostermissilevelocitypenalty.py index 0fbb3ec22..a4f2d1205 100644 --- a/eos/effects/boostermissilevelocitypenalty.py +++ b/eos/effects/boostermissilevelocitypenalty.py @@ -4,6 +4,7 @@ # Implants named like: Crash Booster (3 of 4) # Implants named like: X Instinct Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): diff --git a/eos/effects/boostershieldcapacitypenalty.py b/eos/effects/boostershieldcapacitypenalty.py index 2e6f05731..55d8a9d35 100644 --- a/eos/effects/boostershieldcapacitypenalty.py +++ b/eos/effects/boostershieldcapacitypenalty.py @@ -3,6 +3,7 @@ # Used by: # Implants from group: Booster (12 of 45) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): diff --git a/eos/effects/boosterturretfalloffpenalty.py b/eos/effects/boosterturretfalloffpenalty.py index 44576795b..84f2e2145 100644 --- a/eos/effects/boosterturretfalloffpenalty.py +++ b/eos/effects/boosterturretfalloffpenalty.py @@ -4,6 +4,7 @@ # Implants named like: Drop Booster (3 of 4) # Implants named like: X Instinct Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): diff --git a/eos/effects/boosterturretoptimalrangepenalty.py b/eos/effects/boosterturretoptimalrangepenalty.py index 216f2d44f..d70275c29 100644 --- a/eos/effects/boosterturretoptimalrangepenalty.py +++ b/eos/effects/boosterturretoptimalrangepenalty.py @@ -5,6 +5,7 @@ # Implants named like: Mindflood Booster (3 of 4) # Implants named like: Sooth Sayer Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): diff --git a/eos/effects/boosterturrettrackingpenalty.py b/eos/effects/boosterturrettrackingpenalty.py index 71f0627ff..6f268fdc4 100644 --- a/eos/effects/boosterturrettrackingpenalty.py +++ b/eos/effects/boosterturrettrackingpenalty.py @@ -4,6 +4,7 @@ # Implants named like: Exile Booster (3 of 4) # Implants named like: Frentix Booster (3 of 4) type = "boosterSideEffect" +activeByDefault = False def handler(fit, booster, context): diff --git a/eos/gamedata.py b/eos/gamedata.py index febc59ac8..c3fe8d5b9 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -83,6 +83,28 @@ class Effect(EqBase): return self.__runTime + @property + def activeByDefault(self): + ''' + The runTime that this effect should be run at. + This property is also automaticly fetched from effects/.py if the file exists. + the possible values are: + None, True, False + None and False are equivalent. True is the default if the effect is also implemented. + + effects that are not active will not be calculated. + ''' + if not self.__generated: + self.__generateHandler() + + return self.__activeByDefault + + @activeByDefault.setter + def activeByDefault(self, value): + # Just assign the input values to the ``numbers`` attribute. + # You *could* do something more interesting here if you wanted. + self.__activeByDefault = value + @property def type(self): """ @@ -133,6 +155,11 @@ class Effect(EqBase): except AttributeError: self.__runTime = "normal" + try: + self.__activeByDefault = getattr(effectModule, "activeByDefault") + except AttributeError: + self.__activeByDefault = True + try: t = getattr(effectModule, "type") except AttributeError: @@ -143,6 +170,7 @@ class Effect(EqBase): except (ImportError, AttributeError) as e: self.__handler = effectDummy self.__runTime = "normal" + self.__activeByDefault = True self.__type = None except Exception as e: traceback.print_exc(e) diff --git a/eos/saveddata/booster.py b/eos/saveddata/booster.py index 0a46d662c..3be3845d0 100644 --- a/eos/saveddata/booster.py +++ b/eos/saveddata/booster.py @@ -64,13 +64,18 @@ class Booster(HandledItem, ItemAttrShortcut): self.__itemModifiedAttributes.overrides = self.__item.overrides self.__slot = self.__calculateSlot(self.__item) + # Legacy booster side effect code, disabling as not currently implemented + ''' for effect in self.__item.effects.itervalues(): if effect.isType("boosterSideEffect"): s = SideEffect(self) s.effect = effect s.active = effect.ID in self.__activeSideEffectIDs self.__sideEffects.append(s) + ''' + # Legacy booster side effect code, disabling as not currently implemented + ''' def iterSideEffects(self): return self.__sideEffects.__iter__() @@ -80,6 +85,7 @@ class Booster(HandledItem, ItemAttrShortcut): return sideEffect raise KeyError("SideEffect with %s as name not found" % name) + ''' @property def itemModifiedAttributes(self): @@ -112,12 +118,17 @@ class Booster(HandledItem, ItemAttrShortcut): if not self.active: return for effect in self.item.effects.itervalues(): - if effect.runTime == runTime and effect.isType("passive"): + if effect.runTime == runTime and \ + (effect.isType("passive") or effect.isType("boosterSideEffect")) and \ + effect.activeByDefault: effect.handler(fit, self, ("booster",)) + # Legacy booster code, not fully implemented + ''' for sideEffect in self.iterSideEffects(): if sideEffect.active and sideEffect.effect.runTime == runTime: sideEffect.effect.handler(fit, self, ("boosterSideEffect",)) + ''' @validates("ID", "itemID", "ammoID", "active") def validator(self, key, val): @@ -135,46 +146,52 @@ class Booster(HandledItem, ItemAttrShortcut): def __deepcopy__(self, memo): copy = Booster(self.item) copy.active = self.active + + # Legacy booster side effect code, disabling as not currently implemented + ''' origSideEffects = list(self.iterSideEffects()) copySideEffects = list(copy.iterSideEffects()) i = 0 while i < len(origSideEffects): copySideEffects[i].active = origSideEffects[i].active i += 1 + ''' return copy +# Legacy booster side effect code, disabling as not currently implemented +''' + class SideEffect(object): + def __init__(self, owner): + self.__owner = owner + self.__active = False + self.__effect = None -class SideEffect(object): - def __init__(self, owner): - self.__owner = owner - self.__active = False - self.__effect = None + @property + def active(self): + return self.__active - @property - def active(self): - return self.__active + @active.setter + def active(self, active): + if not isinstance(active, bool): + raise TypeError("Expecting a bool, not a " + type(active)) - @active.setter - def active(self, active): - if not isinstance(active, bool): - raise TypeError("Expecting a bool, not a " + type(active)) + if active != self.__active: + if active: + self.__owner._Booster__activeSideEffectIDs.append(self.effect.ID) + else: + self.__owner._Booster__activeSideEffectIDs.remove(self.effect.ID) - if active != self.__active: - if active: - self.__owner._Booster__activeSideEffectIDs.append(self.effect.ID) - else: - self.__owner._Booster__activeSideEffectIDs.remove(self.effect.ID) + self.__active = active - self.__active = active + @property + def effect(self): + return self.__effect - @property - def effect(self): - return self.__effect + @effect.setter + def effect(self, effect): + if not hasattr(effect, "handler"): + raise TypeError("Need an effect with a handler") - @effect.setter - def effect(self, effect): - if not hasattr(effect, "handler"): - raise TypeError("Need an effect with a handler") - - self.__effect = effect + self.__effect = effect +''' \ No newline at end of file diff --git a/eos/saveddata/character.py b/eos/saveddata/character.py index 3cf3e70eb..c4412763c 100644 --- a/eos/saveddata/character.py +++ b/eos/saveddata/character.py @@ -336,7 +336,8 @@ class Skill(HandledItem): for effect in item.effects.itervalues(): if effect.runTime == runTime and effect.isType("passive") and \ - (not fit.isStructure or effect.isType("structure")): + (not fit.isStructure or effect.isType("structure")) and \ + effect.activeByDefault: try: effect.handler(fit, self, ("skill",)) except AttributeError: diff --git a/eos/saveddata/drone.py b/eos/saveddata/drone.py index f847c1764..d0e8511f5 100644 --- a/eos/saveddata/drone.py +++ b/eos/saveddata/drone.py @@ -232,6 +232,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): for effect in self.item.effects.itervalues(): if effect.runTime == runTime and \ + effect.activeByDefault and \ ((projected is True and effect.isType("projected")) or projected is False and effect.isType("passive")): # See GH issue #765 @@ -245,7 +246,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): if self.charge: for effect in self.charge.effects.itervalues(): - if effect.runTime == runTime: + if effect.runTime == runTime and effect.activeByDefault: effect.handler(fit, self, ("droneCharge",)) def __deepcopy__(self, memo): diff --git a/eos/saveddata/fighter.py b/eos/saveddata/fighter.py index 29015f5f6..23218ef02 100644 --- a/eos/saveddata/fighter.py +++ b/eos/saveddata/fighter.py @@ -270,6 +270,7 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): if ability.active: effect = ability.effect if effect.runTime == runTime and \ + effect.activeByDefault and \ ((projected and effect.isType("projected")) or not projected): if ability.grouped: effect.handler(fit, self, context) diff --git a/eos/saveddata/fit.py b/eos/saveddata/fit.py index 104b0d06b..cc81865ff 100644 --- a/eos/saveddata/fit.py +++ b/eos/saveddata/fit.py @@ -440,7 +440,7 @@ class Fit(object): for name, info in self.gangBoosts.iteritems(): # Unpack all data required to run effect properly effect, thing = info[1] - if effect.runTime == runTime: + if effect.runTime == runTime and effect.activeByDefault: context = ("gang", thing.__class__.__name__.lower()) if isinstance(thing, Module): if effect.isType("offline") or (effect.isType("passive") and thing.state >= State.ONLINE) or \ diff --git a/eos/saveddata/implant.py b/eos/saveddata/implant.py index ef6852c2c..a77190bc4 100644 --- a/eos/saveddata/implant.py +++ b/eos/saveddata/implant.py @@ -93,7 +93,7 @@ class Implant(HandledItem, ItemAttrShortcut): if not self.active: return for effect in self.item.effects.itervalues(): - if effect.runTime == runTime and effect.isType("passive"): + if effect.runTime == runTime and effect.isType("passive") and effect.activeByDefault: effect.handler(fit, self, ("implant",)) @validates("fitID", "itemID", "active") diff --git a/eos/saveddata/mode.py b/eos/saveddata/mode.py index f494d8d9f..2b3108a9d 100644 --- a/eos/saveddata/mode.py +++ b/eos/saveddata/mode.py @@ -51,5 +51,5 @@ class Mode(ItemAttrShortcut, HandledItem): def calculateModifiedAttributes(self, fit, runTime, forceProjected=False): if self.item: for effect in self.item.effects.itervalues(): - if effect.runTime == runTime: + if effect.runTime == runTime and effect.activeByDefault: effect.handler(fit, self, context=("module",)) diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index ec19cc19b..cec668248 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -621,7 +621,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): # fix for #82 and it's regression #106 if not projected or (self.projected and not forceProjected): for effect in self.charge.effects.itervalues(): - if effect.runTime == runTime: + if effect.runTime == runTime and effect.activeByDefault: effect.handler(fit, self, ("moduleCharge",)) if self.item: @@ -629,7 +629,8 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): for effect in self.item.effects.itervalues(): if effect.runTime == runTime and \ effect.isType("overheat") and \ - not forceProjected: + not forceProjected and \ + effect.activeByDefault: effect.handler(fit, self, context) for effect in self.item.effects.itervalues(): @@ -637,7 +638,8 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): (effect.isType("offline") or (effect.isType("passive") and self.state >= State.ONLINE) or (effect.isType("active") and self.state >= State.ACTIVE)) and \ - ((projected and effect.isType("projected")) or not projected): + ((projected and effect.isType("projected")) or not projected) and \ + effect.activeByDefault: effect.handler(fit, self, context) @property diff --git a/eos/saveddata/ship.py b/eos/saveddata/ship.py index 80f961331..4e4020cc7 100644 --- a/eos/saveddata/ship.py +++ b/eos/saveddata/ship.py @@ -82,7 +82,9 @@ class Ship(ItemAttrShortcut, HandledItem): if forceProjected: return for effect in self.item.effects.itervalues(): - if effect.runTime == runTime and effect.isType("passive"): + if effect.runTime == runTime and \ + effect.isType("passive") and \ + effect.activeByDefault: # Ships have effects that utilize the level of a skill as an # additional operator to the modifier. These are defined in # the effect itself, and these skillbooks are registered when diff --git a/eos/types.py b/eos/types.py index cc32f4fa9..d42cd0fe8 100644 --- a/eos/types.py +++ b/eos/types.py @@ -34,7 +34,8 @@ from eos.saveddata.fighter import Fighter from eos.saveddata.cargo import Cargo from eos.saveddata.implant import Implant from eos.saveddata.implantSet import ImplantSet -from eos.saveddata.booster import SideEffect +# Legacy booster side effect code, disabling as not currently implemented +# from eos.saveddata.booster import SideEffect from eos.saveddata.booster import Booster from eos.saveddata.fit import Fit, ImplantLocation from eos.saveddata.mode import Mode diff --git a/gui/itemStats.py b/gui/itemStats.py index 5223a0b07..63e4ce67d 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -740,31 +740,44 @@ class ItemRequirements ( wx.Panel ): class ItemEffects (wx.Panel): def __init__(self, parent, stuff, item): - wx.Panel.__init__ (self, parent) - mainSizer = wx.BoxSizer( wx.VERTICAL ) + wx.Panel.__init__(self, parent) + self.item = item + + mainSizer = wx.BoxSizer(wx.VERTICAL) self.effectList = AutoListCtrl(self, wx.ID_ANY, - style = - #wx.LC_HRULES | - #wx.LC_NO_HEADER | - wx.LC_REPORT |wx.LC_SINGLE_SEL |wx.LC_VRULES |wx.NO_BORDER) - mainSizer.Add( self.effectList, 1, wx.ALL|wx.EXPAND, 0 ) - self.SetSizer( mainSizer ) + style= + # wx.LC_HRULES | + # wx.LC_NO_HEADER | + wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES | wx.NO_BORDER) + mainSizer.Add(self.effectList, 1, wx.ALL | wx.EXPAND, 0) + self.SetSizer(mainSizer) + self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnClick, self.effectList) if config.debug: - self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnClick, self.effectList) + self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick, self.effectList) + + self.PopulateList() + + def PopulateList(self): self.effectList.InsertColumn(0,"Name") - self.effectList.InsertColumn(1,"Implemented") + self.effectList.InsertColumn(1,"Active") + self.effectList.InsertColumn(2, "Type") if config.debug: - self.effectList.InsertColumn(2,"ID") + self.effectList.InsertColumn(3, "Run Time") + self.effectList.InsertColumn(4,"ID") #self.effectList.SetColumnWidth(0,385) self.effectList.setResizeColumn(0) + self.effectList.SetColumnWidth(1,50) + self.effectList.SetColumnWidth(2, 80) + if config.debug: + self.effectList.SetColumnWidth(3, 65) + self.effectList.SetColumnWidth(4, 40) - self.effectList.SetColumnWidth(1,100) - + item = self.item effects = item.effects names = list(effects.iterkeys()) names.sort() @@ -772,19 +785,55 @@ class ItemEffects (wx.Panel): for name in names: index = self.effectList.InsertStringItem(sys.maxint, name) - try: - implemented = "Yes" if effects[name].isImplemented else "No" - except: - implemented = "Erroneous" + if effects[name].isImplemented: + if effects[name].activeByDefault: + activeByDefault = "Yes" + else: + activeByDefault = "No" + else: + activeByDefault = "" - self.effectList.SetStringItem(index, 1, implemented) + effectTypeText = "" + if effects[name].type: + for effectType in effects[name].type: + effectTypeText += effectType + " " + pass + + if effects[name].runTime and effects[name].isImplemented: + effectRunTime = str(effects[name].runTime) + else: + effectRunTime = "" + + self.effectList.SetStringItem(index, 1, activeByDefault) + self.effectList.SetStringItem(index, 2, effectTypeText) if config.debug: - self.effectList.SetStringItem(index, 2, str(effects[name].ID)) + self.effectList.SetStringItem(index, 3, effectRunTime) + self.effectList.SetStringItem(index, 4, str(effects[name].ID)) self.effectList.RefreshRows() self.Layout() def OnClick(self, event): + """ + Debug use: toggle effects on/off. + Affects *ALL* items that use that effect. + Is not stateful. Will reset if Pyfa is closed and reopened. + """ + + try: + activeByDefault = getattr(self.item.effects[event.GetText()], "activeByDefault") + if activeByDefault: + setattr(self.item.effects[event.GetText()], "activeByDefault", False) + else: + setattr(self.item.effects[event.GetText()], "activeByDefault", True) + + except AttributeError: + # Attribute doesn't exist, do nothing + pass + + self.RefreshValues(event) + + def OnRightClick(self, event): """ Debug use: open effect file with default application. If effect file does not exist, create it @@ -804,6 +853,14 @@ class ItemEffects (wx.Panel): import subprocess subprocess.call(["xdg-open", file]) + def RefreshValues(self, event): + self.Freeze() + self.effectList.ClearAll() + self.PopulateList() + self.effectList.RefreshRows() + self.Layout() + self.Thaw() + event.Skip() ########################################################################### ## Class ItemAffectedBy From 7ea3103c2582ad6546241d5ee7663d22c40c72db Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Wed, 9 Nov 2016 07:21:27 -0800 Subject: [PATCH 4/4] Updated docstring with more information --- eos/gamedata.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/eos/gamedata.py b/eos/gamedata.py index c3fe8d5b9..c4b58b235 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -85,15 +85,25 @@ class Effect(EqBase): @property def activeByDefault(self): - ''' - The runTime that this effect should be run at. + """ + The state that this effect should be be in. This property is also automaticly fetched from effects/.py if the file exists. the possible values are: None, True, False - None and False are equivalent. True is the default if the effect is also implemented. - effects that are not active will not be calculated. - ''' + If this is not set: + We simply assume that missing/none = True, and set it accordingly + (much as we set runTime to Normalif not otherwise set). + Nearly all effect files will fall under this category. + + If this is set to True: + We would enable it anyway, but hey, it's double enabled. + No effect files are currently configured this way (and probably will never be). + + If this is set to False: + Basically we simply skip adding the effect to the effect handler when the effect is called, + much as if the run time didn't match or other criteria failed. + """ if not self.__generated: self.__generateHandler() @@ -101,8 +111,10 @@ class Effect(EqBase): @activeByDefault.setter def activeByDefault(self, value): - # Just assign the input values to the ``numbers`` attribute. - # You *could* do something more interesting here if you wanted. + """ + Just assign the input values to the activeByDefault attribute. + You *could* do something more interesting here if you wanted. + """ self.__activeByDefault = value @property