Fix attr tab original value column fetching module attributes for charges

This commit is contained in:
DarkPhoenix
2019-03-29 01:09:52 +03:00
parent 9c5fe56981
commit 6a2bdade80
2 changed files with 14 additions and 3 deletions

View File

@@ -33,13 +33,20 @@ class ItemAttrShortcut(object):
return return_value or default
def getBaseAttrValue(self, key, default=0):
def getItemBaseAttrValue(self, key, default=0):
"""
Gets base value in this order:
Mutated value > override value > attribute value
"""
return_value = self.itemModifiedAttributes.getOriginal(key)
return return_value or default
def getChargeBaseAttrValue(self, key, default=0):
"""
Gets base value in this order:
Mutated value > override value > attribute value
"""
return_value = self.chargeModifiedAttributes.getOriginal(key)
return return_value or default

View File

@@ -266,12 +266,16 @@ class ItemParams(wx.Panel):
info = self.attrInfo.get(attr)
att = self.attrValues[attr]
# If we're working with a stuff object, we should get the original value from our getBaseAttrValue function,
# If we're working with a stuff object, we should get the original value from our getItemBaseAttrValue function,
# which will return the value with respect to the effective base (with mutators / overrides in place)
valDefault = getattr(info, "value", None) # Get default value from attribute
if self.stuff is not None:
# if it's a stuff, overwrite default (with fallback to current value)
valDefault = self.stuff.getBaseAttrValue(attr, valDefault)
if self.stuff.item == self.item:
valDefault = self.stuff.getItemBaseAttrValue(attr, valDefault)
elif self.stuff.charge == self.item:
valDefault = self.stuff.getChargeBaseAttrValue(attr, valDefault)
valueDefault = valDefault if valDefault is not None else att
val = getattr(att, "value", None)