From 1f37656169a4b0cee924e6ea2a627502eb96e1b1 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Tue, 25 Mar 2014 12:43:15 -0400 Subject: [PATCH] Added option to show rack labels --- .../pyfaGeneralPreferences.py | 30 +++++++++++++++---- gui/builtinViewColumns/baseName.py | 8 +++-- gui/builtinViews/fittingView.py | 19 +++++++++--- service/fit.py | 3 +- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/gui/builtinPreferenceViews/pyfaGeneralPreferences.py b/gui/builtinPreferenceViews/pyfaGeneralPreferences.py index b23b59ebe..9f7ae718a 100644 --- a/gui/builtinPreferenceViews/pyfaGeneralPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGeneralPreferences.py @@ -40,8 +40,14 @@ class PFGeneralPref ( PreferenceView): 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 ) - self.cbDivideSlots = wx.CheckBox( panel, wx.ID_ANY, u"Separate Racks", wx.DefaultPosition, wx.DefaultSize, 0 ) - mainSizer.Add( self.cbDivideSlots, 0, wx.ALL|wx.EXPAND, 5 ) + self.cbRackSlots = wx.CheckBox( panel, wx.ID_ANY, u"Separate Racks", wx.DefaultPosition, wx.DefaultSize, 0 ) + mainSizer.Add( self.cbRackSlots, 0, wx.ALL|wx.EXPAND, 5 ) + + labelSizer = wx.BoxSizer( wx.VERTICAL ) + self.cbRackLabels = wx.CheckBox( panel, wx.ID_ANY, u"Show Rack Labels", wx.DefaultPosition, wx.DefaultSize, 0 ) + labelSizer.Add( self.cbRackLabels, 0, wx.ALL|wx.EXPAND, 5 ) + mainSizer.Add( labelSizer, 0, wx.LEFT|wx.EXPAND, 30 ) + # Needs to be implemented - save active fittings and reapply when starting pyfa #self.cbReopenFits = wx.CheckBox( panel, wx.ID_ANY, u"Reopen Fits", wx.DefaultPosition, wx.DefaultSize, 0 ) @@ -58,13 +64,17 @@ class PFGeneralPref ( PreferenceView): self.cbGlobalDmgPattern.SetValue(useGlobalDmgPattern) self.cbGlobalForceReload.SetValue(useGlobalForceReload) self.cbFitColorSlots.SetValue(self.sFit.serviceFittingOptions["colorFitBySlot"] or False) - self.cbDivideSlots.SetValue(self.sFit.serviceFittingOptions["divideSlots"] or False) + self.cbRackSlots.SetValue(self.sFit.serviceFittingOptions["rackSlots"] or False) + self.cbRackLabels.SetValue(self.sFit.serviceFittingOptions["rackLabels"] or False) 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.cbDivideSlots.Bind(wx.EVT_CHECKBOX, self.onCBGlobalDivideSlots) + self.cbRackSlots.Bind(wx.EVT_CHECKBOX, self.onCBGlobalRackSlots) + self.cbRackLabels.Bind(wx.EVT_CHECKBOX, self.onCBGlobalRackLabels) + + self.cbRackLabels.Enable(self.sFit.serviceFittingOptions["rackSlots"] or False) panel.SetSizer( mainSizer ) panel.Layout() @@ -76,8 +86,16 @@ class PFGeneralPref ( PreferenceView): wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) event.Skip() - def onCBGlobalDivideSlots(self, event): - self.sFit.serviceFittingOptions["divideSlots"] = self.cbDivideSlots.GetValue() + def onCBGlobalRackSlots(self, event): + self.sFit.serviceFittingOptions["rackSlots"] = self.cbRackSlots.GetValue() + self.cbRackLabels.Enable(self.cbRackSlots.GetValue()) + fitID = self.mainFrame.getActiveFit() + self.sFit.refreshFit(fitID) + wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) + event.Skip() + + def onCBGlobalRackLabels(self, event): + self.sFit.serviceFittingOptions["rackLabels"] = self.cbRackLabels.GetValue() fitID = self.mainFrame.getActiveFit() self.sFit.refreshFit(fitID) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) diff --git a/gui/builtinViewColumns/baseName.py b/gui/builtinViewColumns/baseName.py index 2021ad6ed..a6e0b937a 100644 --- a/gui/builtinViewColumns/baseName.py +++ b/gui/builtinViewColumns/baseName.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- #=============================================================================== # Copyright (C) 2010 Diego Duclos # @@ -22,6 +23,7 @@ from gui.viewColumn import ViewColumn from gui import bitmapLoader import wx from eos.types import Drone, Fit, Module, Slot, Rack +import service class BaseName(ViewColumn): name = "Base Name" @@ -37,8 +39,10 @@ class BaseName(ViewColumn): elif isinstance(stuff, Fit): return "%s (%s)" % (stuff.name, stuff.ship.item.name) elif isinstance(stuff, Rack): - return "" - #return "%s Rack" % Slot.getName(stuff.slot).capitalize() + if service.Fit.getInstance().serviceFittingOptions["rackLabels"]: + return u'─ {} Rack ─'.format(Slot.getName(stuff.slot).capitalize()) + else: + return "" elif isinstance(stuff, Module): if stuff.isEmpty: return "%s Slot" % Slot.getName(stuff.slot).capitalize() diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index 6c06205a5..a158a591d 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -377,17 +377,19 @@ class FittingView(d.Display): self.mods = fit.modules[:] self.mods.sort(key=lambda mod: (slotOrder.index(mod.slot), mod.position)) - # set up blanks - slotDivider = self.mods[0].slot # flag to know when to add blank (default: don't add blank for first "slot group") self.blanks = [] # preliminary markers where blanks will be inserted - if cFit.serviceFittingOptions["divideSlots"]: + + if cFit.serviceFittingOptions["rackSlots"]: + # flag to know when to add blanks, based on previous slot + slotDivider = None if cFit.serviceFittingOptions["rackLabels"] else self.mods[0].slot + for i, mod in enumerate(self.mods): if mod.slot != slotDivider: slotDivider = mod.slot self.blanks.append(i) for i, x in enumerate(self.blanks): - self.blanks[i] = x+i # modify blanks + self.blanks[i] = x+i # modify blanks with actual index self.mods.insert(x+i, Rack.buildRack(slotOrder.index(i+1))) else: @@ -502,6 +504,7 @@ class FittingView(d.Display): Sends data to d.Display.refresh where the rows and columns are set up, then does a bit of post-processing (colors) ''' + self.Freeze() d.Display.refresh(self, stuff) sFit = service.Fit.getInstance() @@ -521,6 +524,14 @@ class FittingView(d.Display): else: self.SetItemBackgroundColour(i, self.GetBackgroundColour()) + if sFit.serviceFittingOptions["rackSlots"] and sFit.serviceFittingOptions["rackLabels"]: + for i in self.blanks: + font = self.GetItemFont(i) + font.SetWeight(wx.FONTWEIGHT_BOLD) + self.SetItemFont(i, font) + self.SetItemTextColour(i, wx.Colour(0, 51, 153)) + + self.Thaw() self.itemCount = self.GetItemCount() self.itemRect = self.GetItemRect(0) diff --git a/service/fit.py b/service/fit.py index 46aaeb6f4..a1dfa4cd0 100644 --- a/service/fit.py +++ b/service/fit.py @@ -88,7 +88,8 @@ class Fit(object): "defaultCharacter": self.character.ID, "useGlobalForceReload": False, "colorFitBySlot": False, - "divideSlots": False} + "rackSlots": False, + "rackLabels": False} self.serviceFittingOptions = SettingsProvider.getInstance().getSettings("pyfaServiceFittingOptions", serviceFittingDefaultOptions)