Skip to content

Commit 4596c52

Browse files
committed
Fix #335 - properly represent charge modifiers
1 parent 9941b6c commit 4596c52

1 file changed

Lines changed: 28 additions & 14 deletions

File tree

gui/itemStats.py

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,10 @@ def buildAttributeView(self, root):
677677
# "attribute name": {
678678
# "Module Name": [
679679
# class of affliction,
680-
# afflictor info (afflictor, modifier, and modification amount),
681-
# whether this affliction is actually used (unlearned skills are not used)
680+
# affliction item (required due to GH issue #335)
681+
# modifier type
682+
# amount of modification
683+
# whether this affliction was projected
682684
# ]
683685
# }
684686

@@ -710,7 +712,13 @@ def buildAttributeView(self, root):
710712
if attrName not in items:
711713
items[attrName] = []
712714

713-
items[attrName].append((type(afflictor), afflictor, modifier, amount, getattr(afflictor, "projected", False)))
715+
if afflictor == self.stuff and getattr(afflictor, 'charge', None):
716+
# we are showing a charges modifications, see #335
717+
item = afflictor.charge
718+
else:
719+
item = afflictor.item
720+
721+
items[attrName].append((type(afflictor), item, modifier, amount, getattr(afflictor, "projected", False)))
714722

715723
# Make sure projected fits are on top
716724
rootOrder = container.keys()
@@ -760,17 +768,17 @@ def buildAttributeView(self, root):
760768
items = attributes[attrName]
761769
items.sort(key=lambda x: self.ORDER.index(x[0]))
762770
for itemInfo in items:
763-
afflictorType, afflictor, attrModifier, attrAmount, projected = itemInfo
771+
afflictorType, item, attrModifier, attrAmount, projected = itemInfo
764772

765773
if afflictorType == Ship:
766774
itemIcon = self.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons"))
767-
elif afflictor.item.icon:
768-
bitmap = bitmapLoader.getBitmap(afflictor.item.icon.iconFile, "pack")
775+
elif item.icon:
776+
bitmap = bitmapLoader.getBitmap(item.icon.iconFile, "pack")
769777
itemIcon = self.imageList.Add(bitmap) if bitmap else -1
770778
else:
771779
itemIcon = -1
772780

773-
displayStr = afflictor.item.name
781+
displayStr = item.name
774782

775783
if projected:
776784
displayStr += " (projected)"
@@ -795,6 +803,7 @@ def buildModuleView(self, root):
795803
# class of affliction,
796804
# set of afflictors (such as 2 of the same module),
797805
# info on affliction (attribute name, modifier, and modification amount),
806+
# item that will be used to determine icon (required due to GH issue #335)
798807
# whether this affliction is actually used (unlearned skills are not used)
799808
# ]
800809

@@ -822,11 +831,17 @@ def buildModuleView(self, root):
822831
container[self.stuff] = {}
823832
items = container[self.stuff]
824833

834+
if afflictor == self.stuff and getattr(afflictor, 'charge', None):
835+
# we are showing a charges modifications, see #335
836+
item = afflictor.charge
837+
else:
838+
item = afflictor.item
839+
825840
# items hold our module: info mappings
826-
if afflictor.item.name not in items:
827-
items[afflictor.item.name] = [type(afflictor), set(), [], getattr(afflictor, "projected", False)]
841+
if item.name not in items:
842+
items[item.name] = [type(afflictor), set(), [], item, getattr(afflictor, "projected", False)]
828843

829-
info = items[afflictor.item.name]
844+
info = items[item.name]
830845
info[1].add(afflictor)
831846
# If info[1] > 1, there are two separate modules working.
832847
# Check to make sure we only include the modifier once
@@ -856,13 +871,12 @@ def buildModuleView(self, root):
856871
for itemName in order:
857872
info = items[itemName]
858873

859-
afflictorType, afflictors, attrData, projected = info
874+
afflictorType, afflictors, attrData, item, projected = info
860875
counter = len(afflictors)
861-
baseAfflictor = afflictors.pop()
862876
if afflictorType == Ship:
863877
itemIcon = self.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons"))
864-
elif baseAfflictor.item.icon:
865-
bitmap = bitmapLoader.getBitmap(baseAfflictor.item.icon.iconFile, "pack")
878+
elif item.icon:
879+
bitmap = bitmapLoader.getBitmap(item.icon.iconFile, "pack")
866880
itemIcon = self.imageList.Add(bitmap) if bitmap else -1
867881
else:
868882
itemIcon = -1

0 commit comments

Comments
 (0)