Add number of slots in the rack heading (#1535)

This commit is contained in:
blitzmann
2018-05-19 17:55:17 -04:00
parent 155a3a4e42
commit cb509a832e
3 changed files with 8 additions and 6 deletions

View File

@@ -144,10 +144,11 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
return empty
@classmethod
def buildRack(cls, slot):
def buildRack(cls, slot, num=None):
empty = Rack(None)
empty.__slot = slot
empty.dummySlot = slot
empty.num = num
return empty
@property
@@ -799,6 +800,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
class Rack(Module):
"""
This is simply the Module class named something else to differentiate
it for app logic. This class does not do anything special
it for app logic. The only thing interesting about it is the num property,
which is the number of slots for this rack
"""
pass
num = None

View File

@@ -73,7 +73,7 @@ class BaseName(ViewColumn):
if stuff.slot == Slot.MODE:
return '─ Tactical Mode ─'
else:
return '{} Slots ─'.format(Slot.getName(stuff.slot).capitalize())
return '{} Slots ({})'.format(Slot.getName(stuff.slot).capitalize(), stuff.num)
else:
return ""
elif isinstance(stuff, Module):

View File

@@ -520,7 +520,7 @@ class FittingView(d.Display):
# second loop modifies self.mods, rewrites self.blanks to represent actual index of blanks
for i, (x, slot) in enumerate(self.blanks):
self.blanks[i] = x + i # modify blanks with actual index
self.mods.insert(x + i, Rack.buildRack(slot))
self.mods.insert(x + i, Rack.buildRack(slot, sum(m.slot == slot for m in self.mods)))
if fit.mode:
# Modes are special snowflakes and need a little manual loving
@@ -528,7 +528,7 @@ class FittingView(d.Display):
# while also marking the mode header position in the Blanks list
if sFit.serviceFittingOptions["rackSlots"]:
self.blanks.append(len(self.mods))
self.mods.append(Rack.buildRack(Slot.MODE))
self.mods.append(Rack.buildRack(Slot.MODE, None))
self.mods.append(fit.mode)
else: