From 7ef79eaa79c53a87b8ab38bad002907f22a9341c Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Wed, 26 Jun 2019 21:39:12 +0300 Subject: [PATCH] Stop using units as part of input key, they are not going to be different anyway --- gui/builtinGraphs/base.py | 2 +- gui/builtinGraphs/fitDamageStats.py | 4 +-- gui/graphFrame/panel.py | 41 +++++++++++++---------------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/gui/builtinGraphs/base.py b/gui/builtinGraphs/base.py index c3cd36cdb..20dbc982a 100644 --- a/gui/builtinGraphs/base.py +++ b/gui/builtinGraphs/base.py @@ -117,7 +117,7 @@ class Graph(metaclass=ABCMeta): YDef = namedtuple('YDef', ('handle', 'unit', 'label', 'eosGraph')) XDef = namedtuple('XDef', ('handle', 'unit', 'label', 'mainInput')) Input = namedtuple('Input', ('handle', 'unit', 'label', 'iconID', 'defaultValue', 'defaultRange', 'mainOnly')) -VectorDef = namedtuple('VectorDef', ('lengthHandle', 'lengthUnit', 'angleHandle', 'angleUnit', 'label')) +VectorDef = namedtuple('VectorDef', ('lengthHandle', 'angleHandle', 'label')) # noinspection PyUnresolvedReferences diff --git a/gui/builtinGraphs/fitDamageStats.py b/gui/builtinGraphs/fitDamageStats.py index fcceff5b9..113ec266b 100644 --- a/gui/builtinGraphs/fitDamageStats.py +++ b/gui/builtinGraphs/fitDamageStats.py @@ -59,11 +59,11 @@ class FitDamageStatsGraph(Graph): @property def srcVectorDef(self): - return VectorDef(lengthHandle='atkSpeed', lengthUnit='%', angleHandle='atkAngle', angleUnit='degrees', label='Attacker') + return VectorDef(lengthHandle='atkSpeed', angleHandle='atkAngle', label='Attacker') @property def tgtVectorDef(self): - return VectorDef(lengthHandle='tgtSpeed', lengthUnit='%', angleHandle='tgtAngle', angleUnit='degrees', label='Target') + return VectorDef(lengthHandle='tgtSpeed', angleHandle='tgtAngle', label='Target') @property def hasTargets(self): diff --git a/gui/graphFrame/panel.py b/gui/graphFrame/panel.py index b905da97f..937e36722 100644 --- a/gui/graphFrame/panel.py +++ b/gui/graphFrame/panel.py @@ -33,7 +33,7 @@ class GraphControlPanel(wx.Panel): def __init__(self, graphFrame, parent): super().__init__(parent) self.graphFrame = graphFrame - self.inputs = {} + self._inputs = {} self._storedRanges = {} self._storedConsts = {} @@ -145,25 +145,25 @@ class GraphControlPanel(wx.Panel): def _updateInputs(self): self._storeCurrentValues() # Clean up old inputs - for children in self.inputs.values(): + for children in self._inputs.values(): for child in children: if child is not None: child.Destroy() self.inputsSizer.Clear() - self.inputs.clear() + self._inputs.clear() # Update vectors def handleVector(vectorDef, vector, handledHandles, mainInputHandle): handledHandles.add(vectorDef.lengthHandle) handledHandles.add(vectorDef.angleHandle) try: - storedLength = self._storedConsts[(vectorDef.lengthHandle, vectorDef.lengthUnit)] + storedLength = self._storedConsts[vectorDef.lengthHandle] except KeyError: pass else: vector.SetLength(storedLength / 100) try: - storedAngle = self._storedConsts[(vectorDef.angleHandle, vectorDef.angleUnit)] + storedAngle = self._storedConsts[vectorDef.angleHandle] except KeyError: pass else: @@ -183,9 +183,9 @@ class GraphControlPanel(wx.Panel): handledHandles.add(inputDef.handle) fieldSizer = wx.BoxSizer(wx.HORIZONTAL) if mainInput: - fieldTextBox = RangeBox(self, self._storedRanges.get((inputDef.handle, inputDef.unit), inputDef.defaultRange)) + fieldTextBox = RangeBox(self, self._storedRanges.get(inputDef.handle, inputDef.defaultRange)) else: - fieldTextBox = ConstantBox(self, self._storedConsts.get((inputDef.handle, inputDef.unit), inputDef.defaultValue)) + fieldTextBox = ConstantBox(self, self._storedConsts.get(inputDef.handle, inputDef.defaultValue)) fieldTextBox.Bind(wx.EVT_TEXT, self.OnFieldChanged) fieldSizer.Add(fieldTextBox, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 5) fieldIcon = None @@ -197,7 +197,7 @@ class GraphControlPanel(wx.Panel): fieldSizer.Add(fieldIcon, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 3) fieldLabel = wx.StaticText(self, wx.ID_ANY, self._formatLabel(inputDef)) fieldSizer.Add(fieldLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0) - self.inputs[(inputDef.handle, inputDef.unit)] = (fieldTextBox, fieldIcon, fieldLabel) + self._inputs[inputDef.handle] = (fieldTextBox, fieldIcon, fieldLabel) self.inputsSizer.Add(fieldSizer, 0, wx.EXPAND | wx.BOTTOM, 5) addInputField(view.inputMap[selectedX.mainInput], handledHandles, mainInput=True) @@ -240,21 +240,20 @@ class GraphControlPanel(wx.Panel): srcVectorDef = view.srcVectorDef if srcVectorDef is not None: if not self.srcVector.IsDirectionOnly: - values[srcVectorDef.lengthHandle] = (self.srcVector.GetLength() * 100, srcVectorDef.lengthUnit) - values[srcVectorDef.angleHandle] = (self.srcVector.GetAngle(), srcVectorDef.angleUnit) + values[srcVectorDef.lengthHandle] = self.srcVector.GetLength() * 100 + values[srcVectorDef.angleHandle] = self.srcVector.GetAngle() tgtVectorDef = view.tgtVectorDef if tgtVectorDef is not None: if not self.tgtVector.IsDirectionOnly: - values[tgtVectorDef.lengthHandle] = (self.tgtVector.GetLength() * 100, tgtVectorDef.lengthUnit) - values[tgtVectorDef.angleHandle] = (self.tgtVector.GetAngle(), srcVectorDef.angleUnit) + values[tgtVectorDef.lengthHandle] = self.tgtVector.GetLength() * 100 + values[tgtVectorDef.angleHandle] = self.tgtVector.GetAngle() # Input boxes - for k, v in self.inputs.items(): - inputHandle, inputUnit = k - inputBox = v[0] + for inputHandle, inputData in self._inputs.items(): + inputBox = inputData[0] if isinstance(inputBox, RangeBox): - values[inputHandle] = (inputBox.GetValueRange(), inputUnit) + values[inputHandle] = inputBox.GetValueRange() elif isinstance(inputBox, ConstantBox): - values[inputHandle] = (inputBox.GetValueFloat(), inputUnit) + values[inputHandle] = inputBox.GetValueFloat() return values @property @@ -278,13 +277,11 @@ class GraphControlPanel(wx.Panel): return '{}, {}'.format(axisDef.label, axisDef.unit) def _storeCurrentValues(self): - for k, v in self.getValues().items(): - handle = k - value, unit = v + for handle, value in self.getValues().items(): if isinstance(value, (tuple, list)): - self._storedRanges[(handle, unit)] = value + self._storedRanges[handle] = value else: - self._storedConsts[(handle, unit)] = value + self._storedConsts[handle] = value def _clearStoredValues(self): self._storedRanges.clear()