Skip to content

Commit

Permalink
Fix #335 - properly represent charge modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
blitzmann committed Jul 19, 2015
1 parent 9941b6c commit 4596c52
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions gui/itemStats.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,10 @@ def buildAttributeView(self, root):
# "attribute name": {
# "Module Name": [
# class of affliction,
# afflictor info (afflictor, modifier, and modification amount),
# whether this affliction is actually used (unlearned skills are not used)
# affliction item (required due to GH issue #335)
# modifier type
# amount of modification
# whether this affliction was projected
# ]
# }

Expand Down Expand Up @@ -710,7 +712,13 @@ def buildAttributeView(self, root):
if attrName not in items:
items[attrName] = []

items[attrName].append((type(afflictor), afflictor, modifier, amount, getattr(afflictor, "projected", False)))
if afflictor == self.stuff and getattr(afflictor, 'charge', None):
# we are showing a charges modifications, see #335
item = afflictor.charge
else:
item = afflictor.item

items[attrName].append((type(afflictor), item, modifier, amount, getattr(afflictor, "projected", False)))

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

if afflictorType == Ship:
itemIcon = self.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons"))
elif afflictor.item.icon:
bitmap = bitmapLoader.getBitmap(afflictor.item.icon.iconFile, "pack")
elif item.icon:
bitmap = bitmapLoader.getBitmap(item.icon.iconFile, "pack")
itemIcon = self.imageList.Add(bitmap) if bitmap else -1
else:
itemIcon = -1

displayStr = afflictor.item.name
displayStr = item.name

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

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

if afflictor == self.stuff and getattr(afflictor, 'charge', None):
# we are showing a charges modifications, see #335
item = afflictor.charge
else:
item = afflictor.item

# items hold our module: info mappings
if afflictor.item.name not in items:
items[afflictor.item.name] = [type(afflictor), set(), [], getattr(afflictor, "projected", False)]
if item.name not in items:
items[item.name] = [type(afflictor), set(), [], item, getattr(afflictor, "projected", False)]

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

afflictorType, afflictors, attrData, projected = info
afflictorType, afflictors, attrData, item, projected = info
counter = len(afflictors)
baseAfflictor = afflictors.pop()
if afflictorType == Ship:
itemIcon = self.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons"))
elif baseAfflictor.item.icon:
bitmap = bitmapLoader.getBitmap(baseAfflictor.item.icon.iconFile, "pack")
elif item.icon:
bitmap = bitmapLoader.getBitmap(item.icon.iconFile, "pack")
itemIcon = self.imageList.Add(bitmap) if bitmap else -1
else:
itemIcon = -1
Expand Down

0 comments on commit 4596c52

Please sign in to comment.