Show extra labels only when there's something inside

This commit is contained in:
DarkPhoenix
2019-10-02 10:56:01 +03:00
parent c040353f6e
commit 05ac0a528a
7 changed files with 21 additions and 13 deletions

View File

@@ -238,9 +238,11 @@ class BoosterView(d.Display):
opt = sFit.serviceFittingOptions["additionsLabels"]
# Amount of active boosters
if opt == 1:
return ' ({})'.format(len([b for b in fit.boosters if b.active]))
amount = len([b for b in fit.boosters if b.active])
return ' ({})'.format(amount) if amount else None
# Total amount of boosters
elif opt == 2:
return ' ({})'.format(len(fit.boosters))
amount = len(fit.boosters)
return ' ({})'.format(amount) if amount else None
else:
return None

View File

@@ -226,6 +226,7 @@ class CargoView(d.Display):
opt = sFit.serviceFittingOptions["additionsLabels"]
# Total amount of cargo items
if opt in (1, 2):
return ' ({})'.format(len(fit.cargo))
amount = len(fit.cargo)
return ' ({})'.format(amount) if amount else None
else:
return None

View File

@@ -264,9 +264,10 @@ class CommandView(d.Display):
info = commandFit.getCommandInfo(fitID)
if info is not None and info.active:
amount += 1
return ' ({})'.format(amount)
return ' ({})'.format(amount) if amount else None
# Total amount of command fits
elif opt == 2:
return ' ({})'.format(len(fit.commandFits))
amount = len(fit.commandFits)
return ' ({})'.format(amount) if amount else None
else:
return None

View File

@@ -352,12 +352,12 @@ class DroneView(Display):
amount = 0
for droneStack in fit.drones:
amount += droneStack.amountActive
return ' ({})'.format(int(amount))
return ' ({})'.format(amount) if amount else None
# Total amount of drones
elif opt == 2:
amount = 0
for droneStack in fit.drones:
amount += droneStack.amount
return ' ({})'.format(int(amount))
return ' ({})'.format(amount) if amount else None
else:
return None

View File

@@ -128,10 +128,12 @@ class FighterView(wx.Panel):
opt = sFit.serviceFittingOptions["additionsLabels"]
# Amount of active fighter squads
if opt == 1:
return ' ({})'.format(len([f for f in fit.fighters if f.active]))
amount = len([f for f in fit.fighters if f.active])
return ' ({})'.format(amount) if amount else None
# Total amount of fighter squads
elif opt == 2:
return ' ({})'.format(len(fit.fighters))
amount = len(fit.fighters)
return ' ({})'.format(amount) if amount else None
else:
return None

View File

@@ -112,10 +112,12 @@ class ImplantView(wx.Panel):
opt = sFit.serviceFittingOptions["additionsLabels"]
# Amount of active implants
if opt == 1:
return ' ({})'.format(len([i for i in fit.appliedImplants if i.active]))
amount = len([i for i in fit.appliedImplants if i.active])
return ' ({})'.format(amount) if amount else None
# Total amount of implants
elif opt == 2:
return ' ({})'.format(len(fit.appliedImplants))
amount = len(fit.appliedImplants)
return ' ({})'.format(amount) if amount else None
else:
return None

View File

@@ -418,7 +418,7 @@ class ProjectedView(d.Display):
amount += len([m for m in fit.projectedModules if m.state > FittingModuleState.OFFLINE])
amount += len([d for d in fit.projectedDrones if d.amountActive > 0])
amount += len([f for f in fit.projectedFighters if f.active])
return ' ({})'.format(amount)
return ' ({})'.format(amount) if amount else None
# Total amount of projected items
elif opt == 2:
amount = 0
@@ -426,6 +426,6 @@ class ProjectedView(d.Display):
amount += len(fit.projectedModules)
amount += len(fit.projectedDrones)
amount += len(fit.projectedFighters)
return ' ({})'.format(amount)
return ' ({})'.format(amount) if amount else None
else:
return None