Add checkbox to UI which will control if RAAR/RASB will reload or not
This commit is contained in:
@@ -18,6 +18,6 @@
|
||||
# =============================================================================
|
||||
|
||||
from .cache import FitDataCache
|
||||
from .defs import XDef, YDef, VectorDef, Input
|
||||
from .defs import XDef, YDef, VectorDef, Input, InputCheckbox
|
||||
from .getter import PointGetter, SmoothPointGetter
|
||||
from .graph import FitGraph
|
||||
|
||||
@@ -22,6 +22,7 @@ from collections import namedtuple
|
||||
|
||||
|
||||
VectorDef = namedtuple('VectorDef', ('lengthHandle', 'lengthUnit', 'angleHandle', 'angleUnit', 'label'))
|
||||
InputCheckbox = namedtuple('InputCheckbox', ('handle', 'label', 'defaultValue'))
|
||||
|
||||
|
||||
class YDef:
|
||||
|
||||
@@ -79,17 +79,17 @@ class FitGraph(metaclass=ABCMeta):
|
||||
def inputMap(self):
|
||||
return OrderedDict(((i.handle, i.unit), i) for i in self.inputs)
|
||||
|
||||
@property
|
||||
def srcExtraCols(self):
|
||||
return ()
|
||||
checkboxes = ()
|
||||
|
||||
@property
|
||||
def tgtExtraCols(self):
|
||||
return ()
|
||||
def checkboxesMap(self):
|
||||
return OrderedDict((ec.handle, ec) for ec in self.checkboxes)
|
||||
|
||||
hasTargets = False
|
||||
srcVectorDef = None
|
||||
tgtVectorDef = None
|
||||
hasTargets = False
|
||||
srcExtraCols = ()
|
||||
tgtExtraCols = ()
|
||||
usesHpEffectivity = False
|
||||
|
||||
def getPlotPoints(self, mainInput, miscInputs, xSpec, ySpec, src, tgt=None):
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
# =============================================================================
|
||||
|
||||
|
||||
from graphs.data.base import FitGraph, XDef, YDef, Input
|
||||
from graphs.data.base import FitGraph, XDef, YDef, Input, InputCheckbox
|
||||
from service.const import GraphCacheCleanupReason
|
||||
from .cache import TimeCache
|
||||
from .getter import Distance2RpsGetter, Distance2RepAmountGetter, Time2RpsGetter, Time2RepAmountGetter
|
||||
@@ -52,6 +52,7 @@ class FitRemoteRepsGraph(FitGraph):
|
||||
Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=None, defaultRange=(0, 80), secondaryTooltip='When set, uses repairing ship\'s exact RR stats at a given time\nWhen not set, uses repairing ship\'s RR stats as shown in stats panel of main window'),
|
||||
Input(handle='distance', unit='km', label='Distance', iconID=1391, defaultValue=None, defaultRange=(0, 100), mainTooltip='Distance between the repairing ship and the target, as seen in overview (surface-to-surface)', secondaryTooltip='Distance between the repairing ship and the target, as seen in overview (surface-to-surface)')]
|
||||
srcExtraCols = ('ShieldRR', 'ArmorRR', 'HullRR')
|
||||
checkboxes = [InputCheckbox(handle='ancReload', label='Reload ancillary reps', defaultValue=True)]
|
||||
|
||||
# Calculation stuff
|
||||
_normalizers = {('distance', 'km'): lambda v, src, tgt: None if v is None else v * 1000}
|
||||
|
||||
@@ -34,6 +34,7 @@ from .vector import VectorPicker
|
||||
|
||||
InputData = namedtuple('InputData', ('handle', 'unit', 'value'))
|
||||
InputBox = namedtuple('InputBox', ('handle', 'unit', 'textBox', 'icon', 'label'))
|
||||
CheckBox = namedtuple('CheckBox', ('handle', 'checkBox'))
|
||||
|
||||
|
||||
class GraphControlPanel(wx.Panel):
|
||||
@@ -43,6 +44,7 @@ class GraphControlPanel(wx.Panel):
|
||||
self.graphFrame = graphFrame
|
||||
self._mainInputBox = None
|
||||
self._miscInputBoxes = []
|
||||
self._inputCheckboxes = []
|
||||
self._storedRanges = {}
|
||||
self._storedConsts = {}
|
||||
|
||||
@@ -85,7 +87,7 @@ class GraphControlPanel(wx.Panel):
|
||||
self.srcVectorLabel = wx.StaticText(self, wx.ID_ANY, '')
|
||||
self.srcVectorSizer.Add(self.srcVectorLabel, 0, wx.ALIGN_CENTER_HORIZONTAL| wx.BOTTOM, 5)
|
||||
self.srcVector = VectorPicker(self, style=wx.NO_BORDER, size=vectorSize, offset=0)
|
||||
self.srcVector.Bind(VectorPicker.EVT_VECTOR_CHANGED, self.OnMiscFieldChanged)
|
||||
self.srcVector.Bind(VectorPicker.EVT_VECTOR_CHANGED, self.OnNonMainInputChanged)
|
||||
self.srcVectorSizer.Add(self.srcVector, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0)
|
||||
graphOptsSizer.Add(self.srcVectorSizer, 0, wx.EXPAND | wx.LEFT, 15)
|
||||
|
||||
@@ -93,7 +95,7 @@ class GraphControlPanel(wx.Panel):
|
||||
self.tgtVectorLabel = wx.StaticText(self, wx.ID_ANY, '')
|
||||
self.tgtVectorSizer.Add(self.tgtVectorLabel, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.BOTTOM, 5)
|
||||
self.tgtVector = VectorPicker(self, style=wx.NO_BORDER, size=vectorSize, offset=0)
|
||||
self.tgtVector.Bind(VectorPicker.EVT_VECTOR_CHANGED, self.OnMiscFieldChanged)
|
||||
self.tgtVector.Bind(VectorPicker.EVT_VECTOR_CHANGED, self.OnNonMainInputChanged)
|
||||
self.tgtVectorSizer.Add(self.tgtVector, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0)
|
||||
graphOptsSizer.Add(self.tgtVectorSizer, 0, wx.EXPAND | wx.LEFT, 10)
|
||||
|
||||
@@ -178,9 +180,12 @@ class GraphControlPanel(wx.Panel):
|
||||
for child in (inputBox.textBox, inputBox.icon, inputBox.label):
|
||||
if child is not None:
|
||||
child.Destroy()
|
||||
for checkbox in self._inputCheckboxes:
|
||||
checkbox.checkBox.Destroy()
|
||||
self.inputsSizer.Clear()
|
||||
self._mainInputBox = None
|
||||
self._miscInputBoxes.clear()
|
||||
self._inputCheckboxes.clear()
|
||||
|
||||
# Update vectors
|
||||
def handleVector(vectorDef, vector, handledHandles, mainInputHandle):
|
||||
@@ -214,10 +219,10 @@ class GraphControlPanel(wx.Panel):
|
||||
tooltipText = (inputDef.mainTooltip if mainInput else inputDef.secondaryTooltip) or ''
|
||||
if mainInput:
|
||||
fieldTextBox = FloatRangeBox(self, self._storedRanges.get((inputDef.handle, inputDef.unit), inputDef.defaultRange))
|
||||
fieldTextBox.Bind(wx.EVT_TEXT, self.OnMainFieldChanged)
|
||||
fieldTextBox.Bind(wx.EVT_TEXT, self.OnMainInputChanged)
|
||||
else:
|
||||
fieldTextBox = FloatBox(self, self._storedConsts.get((inputDef.handle, inputDef.unit), inputDef.defaultValue))
|
||||
fieldTextBox.Bind(wx.EVT_TEXT, self.OnMiscFieldChanged)
|
||||
fieldTextBox.Bind(wx.EVT_TEXT, self.OnNonMainInputChanged)
|
||||
fieldTextBox.SetToolTip(wx.ToolTip(tooltipText))
|
||||
fieldSizer.Add(fieldTextBox, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 5)
|
||||
fieldIcon = None
|
||||
@@ -239,7 +244,6 @@ class GraphControlPanel(wx.Panel):
|
||||
else:
|
||||
self._miscInputBoxes.append(inputBox)
|
||||
|
||||
|
||||
addInputField(view.inputMap[self.xType.mainInput], handledHandles, mainInput=True)
|
||||
for inputDef in view.inputs:
|
||||
if inputDef.mainOnly:
|
||||
@@ -248,6 +252,21 @@ class GraphControlPanel(wx.Panel):
|
||||
continue
|
||||
addInputField(inputDef, handledHandles)
|
||||
|
||||
def addInputCheckbox(checkboxDef, handledHandles):
|
||||
handledHandles.add(checkboxDef.handle)
|
||||
fieldCheckbox = wx.CheckBox(self, wx.ID_ANY, checkboxDef.label, wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
fieldCheckbox.SetValue(self._storedConsts.get((checkboxDef.handle, None), checkboxDef.defaultValue))
|
||||
fieldCheckbox.Bind(wx.EVT_CHECKBOX, self.OnNonMainInputChanged)
|
||||
self.inputsSizer.Add(fieldCheckbox, 0, wx.BOTTOM, 5)
|
||||
# Store info about added checkbox
|
||||
checkbox = CheckBox(handle=checkboxDef.handle, checkBox=fieldCheckbox)
|
||||
self._inputCheckboxes.append(checkbox)
|
||||
|
||||
for checkboxDef in view.checkboxes:
|
||||
if checkboxDef.handle in handledHandles:
|
||||
continue
|
||||
addInputCheckbox(checkboxDef, handledHandles)
|
||||
|
||||
def refreshAxeLabels(self, restoreSelection=False):
|
||||
view = self.graphFrame.getView()
|
||||
if restoreSelection:
|
||||
@@ -299,13 +318,13 @@ class GraphControlPanel(wx.Panel):
|
||||
self.graphFrame.UpdateWindowSize()
|
||||
self.graphFrame.draw()
|
||||
|
||||
def OnMainFieldChanged(self, event):
|
||||
def OnMainInputChanged(self, event):
|
||||
event.Skip()
|
||||
self.graphFrame.resetXMark()
|
||||
self.inputTimer.Stop()
|
||||
self.inputTimer.Start(Fit.getInstance().serviceFittingOptions['marketSearchDelay'], True)
|
||||
|
||||
def OnMiscFieldChanged(self, event):
|
||||
def OnNonMainInputChanged(self, event):
|
||||
event.Skip()
|
||||
self.inputTimer.Stop()
|
||||
self.inputTimer.Start(Fit.getInstance().serviceFittingOptions['marketSearchDelay'], True)
|
||||
@@ -343,6 +362,9 @@ class GraphControlPanel(wx.Panel):
|
||||
# Other input boxes
|
||||
for inputBox in self._miscInputBoxes:
|
||||
addMiscData(handle=inputBox.handle, unit=inputBox.unit, value=inputBox.textBox.GetValueFloat())
|
||||
# Checkboxes
|
||||
for checkbox in self._inputCheckboxes:
|
||||
addMiscData(handle=checkbox.handle, unit=None, value=checkbox.checkBox.GetValue())
|
||||
|
||||
return main, misc
|
||||
|
||||
@@ -413,8 +435,8 @@ class GraphControlPanel(wx.Panel):
|
||||
self._storedConsts[(input.handle, input.unit)] = input.value
|
||||
|
||||
def _clearStoredValues(self):
|
||||
self._storedConsts.clear()
|
||||
self._storedRanges.clear()
|
||||
self._storedConsts.clear()
|
||||
|
||||
def _setVectorDefaults(self):
|
||||
self.srcVector.SetValue(length=0, angle=90)
|
||||
|
||||
Reference in New Issue
Block a user