Merge branch 'mutaplasmids'
# Conflicts: # eve.db
This commit is contained in:
@@ -6,9 +6,15 @@ from .attributeSlider import AttributeSlider, EVT_VALUE_CHANGED
|
||||
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from .itemAttributes import ItemParams
|
||||
from gui.bitmap_loader import BitmapLoader
|
||||
import gui.globalEvents as GE
|
||||
import gui.mainFrame
|
||||
import random
|
||||
|
||||
from logbook import Logger
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
class ItemMutator(wx.Panel):
|
||||
|
||||
@@ -26,8 +32,10 @@ class ItemMutator(wx.Panel):
|
||||
self.event_mapping = {}
|
||||
|
||||
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, False)
|
||||
baseValueFormated = m.attribute.unit.TranslateValue(m.baseValue)[0]
|
||||
valueFormated = m.attribute.unit.TranslateValue(m.value)[0]
|
||||
slider = AttributeSlider(self, baseValueFormated, m.minMod, m.maxMod, not m.highIsGood)
|
||||
slider.SetValue(valueFormated, False)
|
||||
slider.Bind(EVT_VALUE_CHANGED, self.changeMutatedValue)
|
||||
self.event_mapping[slider] = m
|
||||
headingSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
@@ -50,14 +58,14 @@ class ItemMutator(wx.Panel):
|
||||
worse_range = max_t
|
||||
else:
|
||||
worse_range = min_t
|
||||
|
||||
print("{}: \nHigh is good: {}".format(m.attribute.displayName, m.attribute.highIsGood))
|
||||
print("Value {}".format(m.baseValue))
|
||||
|
||||
print(min_t)
|
||||
print(max_t)
|
||||
print(better_range)
|
||||
print(worse_range)
|
||||
#
|
||||
# print("{}: \nHigh is good: {}".format(m.attribute.displayName, m.attribute.highIsGood))
|
||||
# print("Value {}".format(m.baseValue))
|
||||
#
|
||||
# print(min_t)
|
||||
# print(max_t)
|
||||
# print(better_range)
|
||||
# print(worse_range)
|
||||
|
||||
font = parent.GetFont()
|
||||
font.SetWeight(wx.BOLD)
|
||||
@@ -69,14 +77,15 @@ class ItemMutator(wx.Panel):
|
||||
|
||||
headingSizer.Add(displayName, 3, wx.ALL | wx.EXPAND, 0)
|
||||
|
||||
range_low = wx.StaticText(self, wx.ID_ANY, "{} {}".format(worse_range[0], m.attribute.unit.displayName))
|
||||
|
||||
range_low = wx.StaticText(self, wx.ID_ANY, ItemParams.FormatValue(*m.attribute.unit.TranslateValue(worse_range[0])))
|
||||
range_low.SetForegroundColour(self.goodColor if worse_range[2] else self.badColor)
|
||||
|
||||
range_high = wx.StaticText(self, wx.ID_ANY, "{} {}".format(better_range[0], m.attribute.unit.displayName))
|
||||
range_high = wx.StaticText(self, wx.ID_ANY, ItemParams.FormatValue(*m.attribute.unit.TranslateValue(better_range[0])))
|
||||
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)
|
||||
headingSizer.Add(wx.StaticText(self, wx.ID_ANY, " ─ "), 0, wx.RIGHT | wx.LEFT | wx.EXPAND, 5)
|
||||
headingSizer.Add(range_high, 0, wx.RIGHT | wx.EXPAND, 10)
|
||||
|
||||
mainSizer.Add(headingSizer, 0, wx.ALL | wx.EXPAND, 5)
|
||||
@@ -91,8 +100,13 @@ class ItemMutator(wx.Panel):
|
||||
|
||||
bSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
self.saveBtn = wx.Button(self, wx.ID_ANY, "Save Attributes", wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
bSizer.Add(self.saveBtn, 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
self.refreshBtn = wx.Button(self, wx.ID_ANY, "Reset defaults", wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
bSizer.Add(self.refreshBtn, 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
self.refreshBtn.Bind(wx.EVT_BUTTON, self.resetMutatedValues)
|
||||
|
||||
self.randomBtn = wx.Button(self, wx.ID_ANY, "Random stats", wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
bSizer.Add(self.randomBtn, 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
self.randomBtn.Bind(wx.EVT_BUTTON, self.randomMutatedValues)
|
||||
|
||||
mainSizer.Add(bSizer, 0, wx.RIGHT | wx.LEFT | wx.EXPAND, 0)
|
||||
|
||||
@@ -102,19 +116,56 @@ class ItemMutator(wx.Panel):
|
||||
def changeMutatedValue(self, evt):
|
||||
m = self.event_mapping[evt.Object]
|
||||
value = evt.Value
|
||||
value = m.attribute.unit.ComplicateValue(value)
|
||||
sFit = Fit.getInstance()
|
||||
|
||||
sFit.changeMutatedValue(m, value)
|
||||
if self.timer:
|
||||
self.timer.Stop()
|
||||
self.timer = None
|
||||
|
||||
for x in self.Parent.Children:
|
||||
if isinstance(x, ItemParams):
|
||||
x.RefreshValues(None)
|
||||
break
|
||||
self.timer = wx.CallLater(1000, self.callLater)
|
||||
|
||||
def resetMutatedValues(self, evt):
|
||||
sFit = Fit.getInstance()
|
||||
|
||||
for slider, m in self.event_mapping.items():
|
||||
value = sFit.changeMutatedValue(m, m.baseValue)
|
||||
value = m.attribute.unit.TranslateValue(value)[0]
|
||||
slider.SetValue(value)
|
||||
|
||||
evt.Skip()
|
||||
|
||||
def randomMutatedValues(self, evt):
|
||||
sFit = Fit.getInstance()
|
||||
|
||||
for slider, m in self.event_mapping.items():
|
||||
value = random.uniform(m.minValue, m.maxValue)
|
||||
value = sFit.changeMutatedValue(m, value)
|
||||
value = m.attribute.unit.TranslateValue(value)[0]
|
||||
slider.SetValue(value)
|
||||
|
||||
evt.Skip()
|
||||
|
||||
def callLater(self):
|
||||
self.timer = None
|
||||
print("recalc fit")
|
||||
sFit = Fit.getInstance()
|
||||
sFit.refreshFit(self.activeFit)
|
||||
# todo BUG: if fit is not currently active, this causes the changed fit to show...?
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.activeFit))
|
||||
|
||||
# recalc the fit that this module affects. This is not necessarily the currently active fit
|
||||
sFit.refreshFit(self.activeFit)
|
||||
|
||||
mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
activeFit = mainFrame.getActiveFit()
|
||||
|
||||
if activeFit != self.activeFit:
|
||||
# if we're no longer on the fit this module is affecting, simulate a "switch fit" so that the active fit
|
||||
# can be recalculated (if needed)
|
||||
sFit.switchFit(activeFit)
|
||||
|
||||
# Send signal to GUI to update stats with current active fit
|
||||
wx.PostEvent(mainFrame, GE.FitChanged(fitID=activeFit))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user