Merge branch 'tonycoz-colour-item-list'

This commit is contained in:
blitzmann
2019-03-02 17:35:37 -05:00
7 changed files with 66 additions and 34 deletions

View File

@@ -1,10 +1,12 @@
import os
import sys
import yaml
import wx
from logbook import CRITICAL, DEBUG, ERROR, FingersCrossedHandler, INFO, Logger, NestedSetup, NullHandler, \
StreamHandler, TimedRotatingFileHandler, WARNING
import hashlib
from eos.const import Slot
from cryptography.fernet import Fernet
@@ -47,6 +49,13 @@ LOGLEVEL_MAP = {
"debug": DEBUG,
}
slotColourMap = {
Slot.LOW: wx.Colour(250, 235, 204), # yellow = low slots
Slot.MED: wx.Colour(188, 215, 241), # blue = mid slots
Slot.HIGH: wx.Colour(235, 204, 209), # red = high slots
Slot.RIG: '',
Slot.SUBSYSTEM: ''
}
def getClientSecret():
return clientHash

26
eos/const.py Normal file
View File

@@ -0,0 +1,26 @@
from eos.enum import Enum
class Slot(Enum):
# These are self-explanatory
LOW = 1
MED = 2
HIGH = 3
RIG = 4
SUBSYSTEM = 5
# not a real slot, need for pyfa display rack separation
MODE = 6
# system effects. They are projected "modules" and pyfa assumes all modules
# have a slot. In this case, make one up.
SYSTEM = 7
# used for citadel services
SERVICE = 8
# fighter 'slots'. Just easier to put them here...
F_LIGHT = 10
F_SUPPORT = 11
F_HEAVY = 12
# fighter 'slots' (for structures)
FS_LIGHT = 13
FS_SUPPORT = 14
FS_HEAVY = 15

View File

@@ -23,6 +23,7 @@ from logbook import Logger
from sqlalchemy.orm import reconstructor, validates
import eos.db
from eos.const import Slot
from eos.effectHandlerHelpers import HandledCharge, HandledItem
from eos.enum import Enum
from eos.modifiedAttributeDict import ChargeAttrShortcut, ItemAttrShortcut, ModifiedAttributeDict
@@ -42,30 +43,6 @@ class State(Enum):
OVERHEATED = 2
class Slot(Enum):
# These are self-explanatory
LOW = 1
MED = 2
HIGH = 3
RIG = 4
SUBSYSTEM = 5
# not a real slot, need for pyfa display rack separation
MODE = 6
# system effects. They are projected "modules" and pyfa assumes all modules
# have a slot. In this case, make one up.
SYSTEM = 7
# used for citadel services
SERVICE = 8
# fighter 'slots'. Just easier to put them here...
F_LIGHT = 10
F_SUPPORT = 11
F_HEAVY = 12
# fighter 'slots' (for structures)
FS_LIGHT = 13
FS_SUPPORT = 14
FS_HEAVY = 15
ProjectedMap = {
State.OVERHEATED: State.ACTIVE,
State.ACTIVE: State.OFFLINE,
@@ -185,7 +162,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
self.__itemModifiedAttributes.original = self.__item.attributes
self.__itemModifiedAttributes.overrides = self.__item.overrides
self.__hardpoint = self.__calculateHardpoint(self.__item)
self.__slot = self.__calculateSlot(self.__item)
self.__slot = self.calculateSlot(self.__item)
# Instantiate / remove mutators if this is a mutated module
if self.__baseItem:
@@ -755,7 +732,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
return Hardpoint.NONE
@staticmethod
def __calculateSlot(item):
def calculateSlot(item):
effectSlotMap = {
"rigSlot" : Slot.RIG,
"loPower" : Slot.LOW,
@@ -772,7 +749,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
if item.group.name in Module.SYSTEM_GROUPS:
return Slot.SYSTEM
raise ValueError("Passed item does not fit in any known slot")
return None
@validates("ID", "itemID", "ammoID")
def validator(self, key, val):

View File

@@ -1,6 +1,7 @@
import wx
from logbook import Logger
from eos.saveddata.module import Module
import gui.builtinMarketBrowser.pfSearchBox as SBox
from gui.builtinMarketBrowser.events import ItemSelected, MAX_RECENTLY_USED_MODULES, RECENTLY_USED_MODULES
from gui.contextMenu import ContextMenu
@@ -8,6 +9,7 @@ from gui.display import Display
from gui.utils.staticHelpers import DragDropHelper
from service.attribute import Attribute
from service.fit import Fit
from config import slotColourMap
pyfalog = Logger(__name__)
@@ -28,6 +30,7 @@ class ItemView(Display):
self.recentlyUsedModules = set()
self.sMkt = marketBrowser.sMkt
self.searchMode = marketBrowser.searchMode
self.sFit = Fit.getInstance()
self.marketBrowser = marketBrowser
self.marketView = marketBrowser.marketView
@@ -266,3 +269,9 @@ class ItemView(Display):
revmap[mgid] = i
i += 1
return revmap
def columnBackground(self, colItem, item):
if self.sFit.serviceFittingOptions["colorFitBySlot"]:
return slotColourMap.get(Module.calculateSlot(item)) or self.GetBackgroundColour()
else:
return self.GetBackgroundColour()

View File

@@ -162,9 +162,16 @@ class PFGeneralPref(PreferenceView):
event.Skip()
def onCBGlobalColorBySlot(self, event):
# todo: maybe create a SettingChanged event that we can fire, and have other things hook into, instead of having the preference panel itself handle the
# updating of things related to settings.
self.sFit.serviceFittingOptions["colorFitBySlot"] = self.cbFitColorSlots.GetValue()
fitID = self.mainFrame.getActiveFit()
self.sFit.refreshFit(fitID)
iView = self.mainFrame.marketBrowser.itemView
if iView.active:
iView.update(iView.active)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
event.Skip()

View File

@@ -40,6 +40,7 @@ from gui.contextMenu import ContextMenu
from gui.utils.staticHelpers import DragDropHelper
from service.fit import Fit
from service.market import Market
from config import slotColourMap
pyfalog = Logger(__name__)
@@ -629,14 +630,8 @@ class FittingView(d.Display):
else:
event.Skip()
slotColourMap = {1: wx.Colour(250, 235, 204), # yellow = low slots
2: wx.Colour(188, 215, 241), # blue = mid slots
3: wx.Colour(235, 204, 209), # red = high slots
4: '',
5: ''}
def slotColour(self, slot):
return self.slotColourMap.get(slot) or self.GetBackgroundColour()
return slotColourMap.get(slot) or self.GetBackgroundColour()
def refresh(self, stuff):
"""

View File

@@ -206,15 +206,18 @@ class Display(wx.ListCtrl):
colItem = self.GetItem(item, i)
oldText = colItem.GetText()
oldImageId = colItem.GetImage()
oldColour = colItem.GetBackgroundColour();
newText = col.getText(st)
if newText is False:
col.delayedText(st, self, colItem)
newText = "\u21bb"
newColour = self.columnBackground(colItem, st);
newImageId = col.getImageId(st)
colItem.SetText(newText)
colItem.SetImage(newImageId)
colItem.SetBackgroundColour(newColour)
mask = 0
@@ -228,6 +231,9 @@ class Display(wx.ListCtrl):
if mask:
colItem.SetMask(mask)
self.SetItem(colItem)
else:
if newColour != oldColour:
self.SetItem(colItem)
self.SetItemData(item, id_)
@@ -257,3 +263,6 @@ class Display(wx.ListCtrl):
def getColumn(self, point):
row, _, col = self.HitTestSubItem(point)
return col
def columnBackground(self, colItem, item):
return colItem.GetBackgroundColour()