Add graph settings and save selected graph type there
This commit is contained in:
@@ -32,10 +32,14 @@ class FitGraph(metaclass=ABCMeta):
|
||||
|
||||
# UI stuff
|
||||
views = []
|
||||
viewMap = {}
|
||||
viewIndexMap = {}
|
||||
|
||||
@classmethod
|
||||
def register(cls):
|
||||
FitGraph.views.append(cls)
|
||||
FitGraph.viewMap[cls.internalName] = cls
|
||||
FitGraph.viewIndexMap[cls.internalName] = FitGraph.views.index(cls)
|
||||
|
||||
def __init__(self):
|
||||
# Format: {(fit ID, target type, target ID): data}
|
||||
@@ -46,6 +50,11 @@ class FitGraph(metaclass=ABCMeta):
|
||||
def name(self):
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def internalName(self):
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def yDefs(self):
|
||||
|
||||
@@ -26,6 +26,7 @@ from .base import FitGraph, XDef, YDef, Input
|
||||
class FitCapRegenGraph(FitGraph):
|
||||
|
||||
# UI stuff
|
||||
internalName = 'capRegenGraph'
|
||||
name = 'Capacitor Regeneration'
|
||||
xDefs = [
|
||||
XDef(handle='time', unit='s', label='Time', mainInput=('time', 's')),
|
||||
|
||||
@@ -37,6 +37,7 @@ class FitDamageStatsGraph(FitGraph):
|
||||
self._timeCache.clear(fitID)
|
||||
|
||||
# UI stuff
|
||||
internalName = 'dmgStatsGraph'
|
||||
name = 'Damage Stats'
|
||||
xDefs = [
|
||||
XDef(handle='distance', unit='km', label='Distance', mainInput=('distance', 'km')),
|
||||
|
||||
@@ -26,6 +26,7 @@ from .base import FitGraph, XDef, YDef, Input
|
||||
class FitMobilityVsTimeGraph(FitGraph):
|
||||
|
||||
# UI stuff
|
||||
internalName = 'mobilityGraph'
|
||||
name = 'Mobility'
|
||||
xDefs = [
|
||||
XDef(handle='time', unit='s', label='Time', mainInput=('time', 's'))]
|
||||
|
||||
@@ -26,6 +26,7 @@ from .base import FitGraph, XDef, YDef, Input
|
||||
class FitShieldRegenGraph(FitGraph):
|
||||
|
||||
# UI stuff
|
||||
internalName = 'shieldRegenGraph'
|
||||
name = 'Shield Regeneration'
|
||||
xDefs = [
|
||||
XDef(handle='time', unit='s', label='Time', mainInput=('time', 's')),
|
||||
|
||||
@@ -37,6 +37,7 @@ class FitWarpTimeGraph(FitGraph):
|
||||
self._subspeedCache.clear(fitID)
|
||||
|
||||
# UI stuff
|
||||
internalName = 'warpTimeGraph'
|
||||
name = 'Warp Time'
|
||||
xDefs = [
|
||||
XDef(handle='distance', unit='AU', label='Distance', mainInput=('distance', 'AU')),
|
||||
|
||||
@@ -31,6 +31,7 @@ import gui.globalEvents as GE
|
||||
import gui.mainFrame
|
||||
from gui.bitmap_loader import BitmapLoader
|
||||
from gui.builtinGraphs.base import FitGraph
|
||||
from service.settings import GraphSettings
|
||||
from .panel import GraphControlPanel
|
||||
|
||||
|
||||
@@ -113,7 +114,9 @@ class GraphFrame(wx.Frame):
|
||||
# Setup - graph selector
|
||||
for view in FitGraph.views:
|
||||
self.graphSelection.Append(view.name, view())
|
||||
self.graphSelection.SetSelection(0)
|
||||
viewToSelect = GraphSettings.getInstance().get('selectedGraph')
|
||||
viewToSelect = FitGraph.viewIndexMap.get(viewToSelect, 0)
|
||||
self.graphSelection.SetSelection(viewToSelect)
|
||||
self.ctrlPanel.updateControls(layout=False)
|
||||
|
||||
# Event bindings - local events
|
||||
@@ -154,13 +157,14 @@ class GraphFrame(wx.Frame):
|
||||
self.draw()
|
||||
|
||||
def OnGraphSwitched(self, event):
|
||||
view = self.getView()
|
||||
GraphSettings.getInstance().set('selectedGraph', view.internalName)
|
||||
self.clearCache()
|
||||
self.ctrlPanel.updateControls()
|
||||
self.draw()
|
||||
event.Skip()
|
||||
|
||||
def closeWindow(self):
|
||||
from gui.builtinStatsViews.resistancesViewFull import EFFECTIVE_HP_TOGGLED
|
||||
self.mainFrame.Unbind(GE.FIT_CHANGED, handler=self.OnFitChanged)
|
||||
self.ctrlPanel.unbindExternalEvents()
|
||||
self.Destroy()
|
||||
|
||||
Reference in New Issue
Block a user