From 11f1c16f5b6bc8254f135418bf2bf5d58e1d3abd Mon Sep 17 00:00:00 2001 From: Sakari Orisi Date: Sat, 8 Dec 2012 12:37:00 +0100 Subject: [PATCH] Add option to color the fitting view by slot --- .../pyfaGlobalPreferences.py | 12 ++++++++++++ gui/builtinViews/fittingView.py | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py index 21f0330d3..8b3996864 100644 --- a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py @@ -45,6 +45,9 @@ class PFGlobalPref ( PreferenceView): self.cbGlobalForceReload = wx.CheckBox( panel, wx.ID_ANY, u"Factor in reload time", wx.DefaultPosition, wx.DefaultSize, 0 ) mainSizer.Add( self.cbGlobalForceReload, 0, wx.ALL|wx.EXPAND, 5 ) + self.cbFitColorSlots = wx.CheckBox( panel, wx.ID_ANY, u"Color fitting view by slot", wx.DefaultPosition, wx.DefaultSize, 0 ) + mainSizer.Add( self.cbFitColorSlots, 0, wx.ALL|wx.EXPAND, 5 ) + defCharSizer = wx.BoxSizer( wx.HORIZONTAL ) self.stDefChar = wx.StaticText( panel, wx.ID_ANY, u"Default character:", wx.DefaultPosition, wx.DefaultSize, 0 ) @@ -150,10 +153,12 @@ class PFGlobalPref ( PreferenceView): self.cbGlobalChar.SetValue(useGlobalChar) self.cbGlobalDmgPattern.SetValue(useGlobalDmgPattern) self.cbGlobalForceReload.SetValue(useGlobalForceReload) + self.cbFitColorSlots.SetValue(self.sFit.serviceFittingOptions["colorFitBySlot"]) self.cbGlobalChar.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalCharStateChange) self.cbGlobalDmgPattern.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalDmgPatternStateChange) self.cbGlobalForceReload.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalForceReloadStateChange) + self.cbFitColorSlots.Bind(wx.EVT_CHECKBOX, self.onCBGlobalColorBySlot) self.chDefaultChar.Disable() self.chDefaultChar.Show(False) @@ -232,6 +237,13 @@ class PFGlobalPref ( PreferenceView): self.ToggleProxySettings(self.cbProxySettings.GetValue()) event.Skip() + def onCBGlobalColorBySlot(self, event): + self.sFit.serviceFittingOptions["colorFitBySlot"] = self.cbFitColorSlots.GetValue() + fitID = self.mainFrame.getActiveFit() + self.sFit.refreshFit(fitID) + wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) + event.Skip() + def OnCBGlobalForceReloadStateChange(self, event): self.sFit.serviceFittingOptions["useGlobalForceReload"] = self.cbGlobalForceReload.GetValue() fitID = self.mainFrame.getActiveFit() diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index dac586877..eedaddc03 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -446,6 +446,14 @@ class FittingView(d.Display): else: event.Skip() + slotColourMap = {1: wx.Colour(238, 221, 130), + 2: wx.Colour(100, 149, 237), + 3: wx.Colour(205, 120, 120), + 4: '', + 5: ''} + def slotColour(self, slot): + return self.slotColourMap[slot] or self.GetBackgroundColour() + def refresh(self, stuff): d.Display.refresh(self, stuff) sFit = service.Fit.getInstance() @@ -454,14 +462,14 @@ class FittingView(d.Display): for slotType in Slot.getTypes(): slot = Slot.getValue(slotType) slotMap[slot] = fit.getSlotsFree(slot) < 0 - bkcolor = self.GetBackgroundColour() + for i, mod in enumerate(self.mods): if slotMap[mod.slot]: self.SetItemBackgroundColour(i, wx.Colour(204, 51, 51)) + elif sFit.serviceFittingOptions["colorFitBySlot"]: + self.SetItemBackgroundColour(i, self.slotColour(mod.slot)) else: - icolor = self.GetItemBackgroundColour(i) - if icolor != bkcolor: - self.SetItemBackgroundColour(i, bkcolor) + self.SetItemBackgroundColour(i, self.GetBackgroundColour()) self.itemCount = self.GetItemCount() self.itemRect = self.GetItemRect(0)