From 3c6071ad8841a7f4d4e8df09545c5dc4be419f93 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Mon, 5 Aug 2019 10:41:06 +0300 Subject: [PATCH] Do not show resist column and mode picker when resists are ignored --- graphs/data/fitDamageStats/graph.py | 9 ++++++++- graphs/gui/frame.py | 4 ++++ graphs/gui/panel.py | 10 ++++++---- gui/builtinContextMenus/graphDmgIgnoreResists.py | 2 +- gui/builtinContextMenus/resistMode.py | 3 +++ 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/graphs/data/fitDamageStats/graph.py b/graphs/data/fitDamageStats/graph.py index 57495daf6..a6a26c09a 100644 --- a/graphs/data/fitDamageStats/graph.py +++ b/graphs/data/fitDamageStats/graph.py @@ -68,7 +68,6 @@ class FitDamageStatsGraph(FitGraph): tgtVectorDef = VectorDef(lengthHandle='tgtSpeed', lengthUnit='%', angleHandle='tgtAngle', angleUnit='degrees', label='Target') hasTargets = True srcExtraCols = ('Dps', 'Volley', 'Speed', 'Radius') - tgtExtraCols = ('Target Resists', 'Speed', 'SigRadius', 'Radius') @property def yDefs(self): @@ -78,6 +77,14 @@ class FitDamageStatsGraph(FitGraph): YDef(handle='volley', unit=None, label='Volley' if ignoreResists else 'Effective volley'), YDef(handle='damage', unit=None, label='Damage inflicted' if ignoreResists else 'Effective damage inflicted')] + @property + def tgtExtraCols(self): + cols = [] + if not GraphSettings.getInstance().get('ignoreResists'): + cols.append('Target Resists') + cols.extend(('Speed', 'SigRadius', 'Radius')) + return cols + # Calculation stuff _normalizers = { ('distance', 'km'): lambda v, src, tgt: None if v is None else v * 1000, diff --git a/graphs/gui/frame.py b/graphs/gui/frame.py index 8f1c63b44..55a6d18e6 100644 --- a/graphs/gui/frame.py +++ b/graphs/gui/frame.py @@ -205,8 +205,12 @@ class GraphFrame(wx.Frame): def OnGraphOptionChanged(self, event): event.Skip() + self.ctrlPanel.Freeze() if getattr(event, 'refreshAxeLabels', False): self.ctrlPanel.refreshAxeLabels() + if getattr(event, 'refreshColumns', False): + self.ctrlPanel.refreshColumns() + self.ctrlPanel.Thaw() self.clearCache(reason=GraphCacheCleanupReason.optionChanged) self.draw() diff --git a/graphs/gui/panel.py b/graphs/gui/panel.py index df6c32029..0229eb9d1 100644 --- a/graphs/gui/panel.py +++ b/graphs/gui/panel.py @@ -162,8 +162,7 @@ class GraphControlPanel(wx.Panel): self.tgtVectorLabel.Show(False) # Source and target list - self.sourceList.refreshExtraColumns(view.srcExtraCols) - self.targetList.refreshExtraColumns(view.tgtExtraCols) + self.refreshColumns() self.targetList.Show(view.hasTargets) # Inputs @@ -260,12 +259,15 @@ class GraphControlPanel(wx.Panel): # Currently we need to refresh only Y for dps graph selectedY = self.ySubSelection.GetSelection() view = self.graphFrame.getView() - self.Freeze() self.ySubSelection.Clear() for yDef in view.yDefs: self.ySubSelection.Append(self.formatLabel(yDef), yDef) self.ySubSelection.SetSelection(selectedY) - self.Thaw() + + def refreshColumns(self): + view = self.graphFrame.getView() + self.sourceList.refreshExtraColumns(view.srcExtraCols) + self.targetList.refreshExtraColumns(view.tgtExtraCols) def OnShowLegendChange(self, event): event.Skip() diff --git a/gui/builtinContextMenus/graphDmgIgnoreResists.py b/gui/builtinContextMenus/graphDmgIgnoreResists.py index cecfafbdd..79fc3b67d 100644 --- a/gui/builtinContextMenus/graphDmgIgnoreResists.py +++ b/gui/builtinContextMenus/graphDmgIgnoreResists.py @@ -21,7 +21,7 @@ class GraphDmgIgnoreResistsMenu(ContextMenuUnconditional): def activate(self, callingWindow, fullContext, i): self.settings.set('ignoreResists', not self.settings.get('ignoreResists')) - wx.PostEvent(self.mainFrame, GE.GraphOptionChanged(refreshAxeLabels=True)) + wx.PostEvent(self.mainFrame, GE.GraphOptionChanged(refreshAxeLabels=True, refreshColumns=True)) def isChecked(self, i): return self.settings.get('ignoreResists') diff --git a/gui/builtinContextMenus/resistMode.py b/gui/builtinContextMenus/resistMode.py index 1401298eb..7995b4fc1 100644 --- a/gui/builtinContextMenus/resistMode.py +++ b/gui/builtinContextMenus/resistMode.py @@ -8,6 +8,7 @@ from graphs.events import ResistModeChanged from graphs.wrapper import TargetWrapper from gui.contextMenu import ContextMenuCombined from service.const import TargetResistMode +from service.settings import GraphSettings optionMap = OrderedDict(( @@ -26,6 +27,8 @@ class TargetWrapperResists(ContextMenuCombined): def display(self, callingWindow, srcContext, mainItem, selection): if srcContext != 'graphTgtList': return False + if GraphSettings.getInstance().get('ignoreResists'): + return False if not isinstance(mainItem, TargetWrapper) or not mainItem.isFit: return False self.callingWindow = callingWindow