diff --git a/gui/builtinItemStatsViews/attributeSlider.py b/gui/builtinItemStatsViews/attributeSlider.py index 906b96aa5..57fce467c 100644 --- a/gui/builtinItemStatsViews/attributeSlider.py +++ b/gui/builtinItemStatsViews/attributeSlider.py @@ -72,7 +72,7 @@ class AttributeSlider(wx.Panel): self.ctrl.Bind(wx.EVT_SPINCTRLDOUBLE, self.UpdateValue) - self.slider = AttributeGauge(self, size=(-1,8)) + self.slider = AttributeGauge(self, size=(-1, 8)) b = 4 vsizer1 = wx.BoxSizer(wx.VERTICAL) diff --git a/gui/builtinItemStatsViews/itemMutator.py b/gui/builtinItemStatsViews/itemMutator.py index fd7e64dec..c66a46f3f 100644 --- a/gui/builtinItemStatsViews/itemMutator.py +++ b/gui/builtinItemStatsViews/itemMutator.py @@ -31,7 +31,7 @@ class ItemMutator(wx.Panel): self.goodColor = wx.Colour(96, 191, 0) self.badColor = wx.Colour(255, 64, 0) - for x in stuff.mutaplasmid.attributes: + 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) @@ -41,20 +41,35 @@ class ItemMutator(wx.Panel): slider.SetValue(value) headingSizer = wx.BoxSizer(wx.HORIZONTAL) - minValue = round(value*min, 3) - maxValue = round(value*max, 3) + minValue = round(value * min, 3) + maxValue = round(value * max, 3) + + # create array for the two ranges + min_t = [minValue, min, None] + max_t = [maxValue, max, 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] + + # 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]): + 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]): + worse_range = max_t + else: + worse_range = min_t - badValue = minValue if x.highIsGood else maxValue - goodValue = maxValue if x.highIsGood else minValue print("{}: \nHigh is good: {}".format(x.displayName, x.highIsGood)) - - minIsGood = badValue < value if not x.highIsGood else value < badValue - maxIsGood = goodValue < value if not x.highIsGood else value < goodValue - - print ("======") print("Value {}".format(value)) - print("Min {} ({}) (good: {})".format(minValue, min, minIsGood)) - print("Max {} ({}) (good: {})".format(maxValue, max, maxIsGood)) + + print(min_t) + print(max_t) + print(better_range) + print(worse_range) font = parent.GetFont() font.SetWeight(wx.BOLD) @@ -66,11 +81,11 @@ class ItemMutator(wx.Panel): headingSizer.Add(displayName, 3, wx.ALL | wx.EXPAND, 0) - range_low = wx.StaticText(self, wx.ID_ANY, "{} {}".format(badValue, x.unit.displayName)) - range_low.SetForegroundColour(self.goodColor if minIsGood else self.badColor) + 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_high = wx.StaticText(self, wx.ID_ANY, "{} {}".format(goodValue, x.unit.displayName)) - range_high.SetForegroundColour(self.goodColor if maxIsGood else self.badColor) + range_high = wx.StaticText(self, wx.ID_ANY, "{} {}".format(better_range[0], x.unit.displayName)) + range_high.SetForegroundColour(self.goodColor if better_range[2] else self.badColor) headingSizer.Add(range_low, 0, wx.ALL | wx.EXPAND, 0) headingSizer.Add(wx.StaticText(self, wx.ID_ANY, " ── "), 0, wx.RIGHT | wx.LEFT | wx.EXPAND, 5)