From 7bcdf95f5c6513d9b76f07ed3fdda87816f80c8d Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sat, 6 Jul 2019 03:16:31 +0300 Subject: [PATCH] Refresh graph when graph options change --- gui/builtinContextMenus/graphDmgDroneMode.py | 4 ++++ gui/builtinContextMenus/graphDmgIgnoreResists.py | 5 +++++ gui/globalEvents.py | 1 + gui/graphFrame/frame.py | 7 +++++++ 4 files changed, 17 insertions(+) diff --git a/gui/builtinContextMenus/graphDmgDroneMode.py b/gui/builtinContextMenus/graphDmgDroneMode.py index 8bc9fb4b4..3ec31dba1 100644 --- a/gui/builtinContextMenus/graphDmgDroneMode.py +++ b/gui/builtinContextMenus/graphDmgDroneMode.py @@ -3,6 +3,7 @@ from collections import OrderedDict # noinspection PyPackageRequirements import wx +import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuUnconditional from service.settings import GraphSettings @@ -22,7 +23,10 @@ class TargetResists(ContextMenuUnconditional): def handleModeSwitch(self, event): optionName = self.idOptionMap[event.Id] + if optionName == self.settings.get('mobileDroneMode'): + return self.settings.set('mobileDroneMode', optionName) + wx.PostEvent(self.mainFrame, GE.GraphOptionChanged()) def getSubMenu(self, context, rootMenu, i, pitem): m = wx.Menu() diff --git a/gui/builtinContextMenus/graphDmgIgnoreResists.py b/gui/builtinContextMenus/graphDmgIgnoreResists.py index 0799e4273..dc3b43267 100644 --- a/gui/builtinContextMenus/graphDmgIgnoreResists.py +++ b/gui/builtinContextMenus/graphDmgIgnoreResists.py @@ -1,3 +1,7 @@ +# noinspection PyPackageRequirements +import wx + +import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuUnconditional from service.settings import GraphSettings @@ -17,6 +21,7 @@ class GraphDmgIgnoreResists(ContextMenuUnconditional): def activate(self, fullContext, i): self.settings.set('ignoreResists', not self.settings.get('ignoreResists')) + wx.PostEvent(self.mainFrame, GE.GraphOptionChanged()) @property def checked(self): diff --git a/gui/globalEvents.py b/gui/globalEvents.py index 67ef86d39..92c71c25d 100644 --- a/gui/globalEvents.py +++ b/gui/globalEvents.py @@ -5,6 +5,7 @@ FitChanged, FIT_CHANGED = wx.lib.newevent.NewEvent() FitRemoved, FIT_REMOVED = wx.lib.newevent.NewEvent() CharListUpdated, CHAR_LIST_UPDATED = wx.lib.newevent.NewEvent() CharChanged, CHAR_CHANGED = wx.lib.newevent.NewEvent() +GraphOptionChanged, GRAPH_OPTION_CHANGED = wx.lib.newevent.NewEvent() SsoLoggingIn, EVT_SSO_LOGGING_IN = wx.lib.newevent.NewEvent() SsoLogin, EVT_SSO_LOGIN = wx.lib.newevent.NewEvent() diff --git a/gui/graphFrame/frame.py b/gui/graphFrame/frame.py index 7f18dd27f..0304a0722 100644 --- a/gui/graphFrame/frame.py +++ b/gui/graphFrame/frame.py @@ -122,6 +122,7 @@ class GraphFrame(wx.Frame): self.Bind(wx.EVT_CHAR_HOOK, self.kbEvent) # Event bindings - external events self.mainFrame.Bind(GE.FIT_CHANGED, self.OnFitChanged) + self.mainFrame.Bind(GE.GRAPH_OPTION_CHANGED, self.OnGraphOptionChanged) self.Layout() self.UpdateWindowSize() @@ -154,6 +155,11 @@ class GraphFrame(wx.Frame): self.getView().clearCache(fitID=event.fitID) self.draw() + def OnGraphOptionChanged(self, event): + event.Skip() + self.getView().clearCache() + self.draw() + def OnGraphSwitched(self, event): view = self.getView() GraphSettings.getInstance().set('selectedGraph', view.internalName) @@ -164,6 +170,7 @@ class GraphFrame(wx.Frame): def closeWindow(self): self.mainFrame.Unbind(GE.FIT_CHANGED, handler=self.OnFitChanged) + self.mainFrame.Unbind(GE.GRAPH_OPTION_CHANGED, handler=self.OnGraphOptionChanged) self.ctrlPanel.unbindExternalEvents() self.Destroy()