make slot a property for item and use that for the item list bg

This commit is contained in:
Tony Cook
2019-03-01 19:24:39 +11:00
parent 2ea3394845
commit af17a4f1c9
2 changed files with 22 additions and 6 deletions

View File

@@ -240,6 +240,7 @@ class Item(EqBase):
self.__assistive = None
self.__overrides = None
self.__priceObj = None
self.__slot = None
@property
def attributes(self):
@@ -479,6 +480,21 @@ class Item(EqBase):
def isCharge(self):
return self.category.name == "Charge"
effectSlots = { 'loPower' : 1,
'medPower' : 2,
'hiPower' : 3,
'rigSlot' : 4,
'subSystem': 5 }
@property
def slot(self):
if self.__slot is None:
self.__slot = 0
for effectName in self.effectSlots:
if effectName in self.effects:
self.__slot = self.effectSlots[effectName]
break
return self.__slot;
def __repr__(self):
return "Item(ID={}, name={}) at {}".format(
self.ID, self.name, hex(id(self))

View File

@@ -268,13 +268,13 @@ class ItemView(Display):
i += 1
return revmap
slotColourMap = { 'loPower' : wx.Colour(250, 235, 204),
'medPower': wx.Colour(188, 215, 241),
'hiPower' : wx.Colour(235, 204, 209) }
slotColourMap = { 1: wx.Colour(250, 235, 204),
2: wx.Colour(188, 215, 241),
3: wx.Colour(235, 204, 209) }
def columnBackground(self, colItem, item):
if self.sFit.serviceFittingOptions["colorFitBySlot"]:
for effectName in self.slotColourMap:
if effectName in item.effects:
return self.slotColourMap[effectName]
slot = item.slot;
if slot in self.slotColourMap:
return self.slotColourMap[slot]
return wx.Colour(255, 255, 255)