Move some functionality tot he mutator object, and clean some stuff up
This commit is contained in:
@@ -5,7 +5,7 @@ from gui.attribute_gauge import AttributeGauge
|
||||
import eos
|
||||
import eos.db
|
||||
|
||||
_ValueChanged, EVT_NOTEBOOK_PAGE_CHANGED = wx.lib.newevent.NewEvent()
|
||||
_ValueChanged, EVT_VALUE_CHANGED = wx.lib.newevent.NewEvent()
|
||||
|
||||
|
||||
class AttributeSliderChangeEvent:
|
||||
@@ -115,7 +115,7 @@ class TestAttributeSlider(wx.Frame):
|
||||
wx.Frame.__init__(self, parent, id, title, pos, size, sty)
|
||||
|
||||
self.panel = AttributeSlider(self, -50, 0.8, 1.5, False)
|
||||
self.panel.Bind(EVT_NOTEBOOK_PAGE_CHANGED, self.thing)
|
||||
self.panel.Bind(EVT_VALUE_CHANGED, self.thing)
|
||||
self.panel.SetValue(-55)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
|
||||
|
||||
@@ -31,43 +31,32 @@ class ItemMutator(wx.Panel):
|
||||
self.goodColor = wx.Colour(96, 191, 0)
|
||||
self.badColor = wx.Colour(255, 64, 0)
|
||||
|
||||
for x in sorted(stuff.mutaplasmid.attributes, key=lambda a: a.displayName):
|
||||
# JFC this is ugly as sin
|
||||
min = round(x.min, 2)
|
||||
max = round(x.max, 2)
|
||||
|
||||
base_value = stuff.item.attributes[x.name].value
|
||||
|
||||
mutator = stuff.mutators[x.attributeID]
|
||||
|
||||
slider = AttributeSlider(self, base_value, min, max, not x.highIsGood)
|
||||
slider.SetValue(mutator.value)
|
||||
for m in sorted(stuff.mutators.values(), key=lambda x: x.attribute.displayName):
|
||||
slider = AttributeSlider(self, m.baseValue, m.minMod, m.maxMod, not m.highIsGood)
|
||||
slider.SetValue(m.value)
|
||||
headingSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
minValue = round(base_value * min, 3)
|
||||
maxValue = round(base_value * max, 3)
|
||||
|
||||
# create array for the two ranges
|
||||
min_t = [minValue, min, None]
|
||||
max_t = [maxValue, max, None]
|
||||
min_t = [round(m.minValue, 3), m.minMod, None]
|
||||
max_t = [round(m.maxValue, 3), m.maxMod, None]
|
||||
|
||||
# Then we need to determine if it's better than original, which will be the color
|
||||
min_t[2] = min_t[1] < 1 if not x.highIsGood else 1 < min_t[1]
|
||||
max_t[2] = max_t[1] < 1 if not x.highIsGood else 1 < max_t[1]
|
||||
min_t[2] = min_t[1] < 1 if not m.highIsGood else 1 < min_t[1]
|
||||
max_t[2] = max_t[1] < 1 if not m.highIsGood else 1 < max_t[1]
|
||||
|
||||
# Lastly, we need to determine which range value is "worse" (left side) or "better" (right side)
|
||||
if (x.highIsGood and min_t[1] > max_t[1]) or (not x.highIsGood and min_t[1] < max_t[1]):
|
||||
if (m.highIsGood and min_t[1] > max_t[1]) or (not m.highIsGood and min_t[1] < max_t[1]):
|
||||
better_range = min_t
|
||||
else:
|
||||
better_range = max_t
|
||||
|
||||
if (x.highIsGood and max_t[1] < min_t[1]) or (not x.highIsGood and max_t[1] > min_t[1]):
|
||||
if (m.highIsGood and max_t[1] < min_t[1]) or (not m.highIsGood and max_t[1] > min_t[1]):
|
||||
worse_range = max_t
|
||||
else:
|
||||
worse_range = min_t
|
||||
|
||||
print("{}: \nHigh is good: {}".format(x.displayName, x.highIsGood))
|
||||
print("Value {}".format(base_value))
|
||||
print("{}: \nHigh is good: {}".format(m.attribute.displayName, m.attribute.highIsGood))
|
||||
print("Value {}".format(m.baseValue))
|
||||
|
||||
print(min_t)
|
||||
print(max_t)
|
||||
@@ -77,17 +66,17 @@ class ItemMutator(wx.Panel):
|
||||
font = parent.GetFont()
|
||||
font.SetWeight(wx.BOLD)
|
||||
|
||||
headingSizer.Add(BitmapLoader.getStaticBitmap(x.info.icon.iconFile, self, "icons"), 0, wx.RIGHT, 10)
|
||||
headingSizer.Add(BitmapLoader.getStaticBitmap(m.attribute.icon.iconFile, self, "icons"), 0, wx.RIGHT, 10)
|
||||
|
||||
displayName = wx.StaticText(self, wx.ID_ANY, x.displayName)
|
||||
displayName = wx.StaticText(self, wx.ID_ANY, m.attribute.displayName)
|
||||
displayName.SetFont(font)
|
||||
|
||||
headingSizer.Add(displayName, 3, wx.ALL | wx.EXPAND, 0)
|
||||
|
||||
range_low = wx.StaticText(self, wx.ID_ANY, "{} {}".format(worse_range[0], x.unit.displayName))
|
||||
range_low.SetForegroundColour(self.goodColor if worse_range[2] else self.badColor)
|
||||
range_low = wx.StaticText(self, wx.ID_ANY, "{} {}".format(worse_range[0], m.attribute.unit.displayName))
|
||||
range_low.SetForegroundColour(self.goodColor if worse_range[2] else self.badColor)
|
||||
|
||||
range_high = wx.StaticText(self, wx.ID_ANY, "{} {}".format(better_range[0], x.unit.displayName))
|
||||
range_high = wx.StaticText(self, wx.ID_ANY, "{} {}".format(better_range[0], m.attribute.unit.displayName))
|
||||
range_high.SetForegroundColour(self.goodColor if better_range[2] else self.badColor)
|
||||
|
||||
headingSizer.Add(range_low, 0, wx.ALL | wx.EXPAND, 0)
|
||||
|
||||
Reference in New Issue
Block a user