* Show fighter bay resources in fighter pane
* Give fighters a state * Include some toggled stats on the resources pane * Add some decent icons for fighter stuff
This commit is contained in:
@@ -31,6 +31,7 @@ fighters_table = Table("fighters", saveddata_meta,
|
||||
Column("groupID", Integer, primary_key=True),
|
||||
Column("fitID", Integer, ForeignKey("fits.ID"), nullable = False, index = True),
|
||||
Column("itemID", Integer, nullable = False),
|
||||
Column("active", Boolean, nullable=True),
|
||||
Column("amount", Integer, nullable = False),
|
||||
Column("projected", Boolean, default = False))
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
|
||||
self.itemID = item.ID if item is not None else None
|
||||
self.projected = False
|
||||
self.active = True
|
||||
|
||||
# -1 is a placeholder that represents max squadron size, which we may not know yet as ships may modify this with
|
||||
# their effects. If user changes this, it is then overridden with user value.
|
||||
@@ -257,7 +258,8 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
return copy
|
||||
|
||||
def fits(self, fit):
|
||||
if fit.getSlotsFree(self.slot) <= 0:
|
||||
# If ships doesn't support this type of fighter, don't add it
|
||||
if fit.getNumSlots(self.slot) == 0:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@@ -616,30 +616,36 @@ class Fit(object):
|
||||
|
||||
def getSlotsUsed(self, type, countDummies=False):
|
||||
amount = 0
|
||||
|
||||
for mod in chain(self.modules, self.fighters):
|
||||
if mod.slot is type and (not getattr(mod, "isEmpty", False) or countDummies):
|
||||
if type in (Slot.F_HEAVY, Slot.F_SUPPORT, Slot.F_LIGHT) and not mod.active:
|
||||
continue
|
||||
amount += 1
|
||||
|
||||
return amount
|
||||
|
||||
def getSlotsFree(self, type, countDummies=False):
|
||||
slots = {Slot.LOW: "lowSlots",
|
||||
Slot.MED: "medSlots",
|
||||
Slot.HIGH: "hiSlots",
|
||||
Slot.RIG: "rigSlots",
|
||||
Slot.SUBSYSTEM: "maxSubSystems",
|
||||
Slot.F_LIGHT: "fighterLightSlots",
|
||||
Slot.F_SUPPORT: "fighterSupportSlots",
|
||||
Slot.F_HEAVY: "fighterHeavySlots"}
|
||||
slots = {Slot.LOW: "lowSlots",
|
||||
Slot.MED: "medSlots",
|
||||
Slot.HIGH: "hiSlots",
|
||||
Slot.RIG: "rigSlots",
|
||||
Slot.SUBSYSTEM: "maxSubSystems",
|
||||
Slot.F_LIGHT: "fighterLightSlots",
|
||||
Slot.F_SUPPORT: "fighterSupportSlots",
|
||||
Slot.F_HEAVY: "fighterHeavySlots"}
|
||||
|
||||
def getSlotsFree(self, type, countDummies=False):
|
||||
if type in (Slot.MODE, Slot.SYSTEM):
|
||||
# These slots don't really exist, return default 0
|
||||
return 0
|
||||
|
||||
slotsUsed = self.getSlotsUsed(type, countDummies)
|
||||
totalSlots = self.ship.getModifiedItemAttr(slots[type]) or 0
|
||||
totalSlots = self.ship.getModifiedItemAttr(self.slots[type]) or 0
|
||||
return int(totalSlots - slotsUsed)
|
||||
|
||||
def getNumSlots(self, type):
|
||||
return self.ship.getModifiedItemAttr(self.slots[type]) or 0
|
||||
|
||||
@property
|
||||
def calibrationUsed(self):
|
||||
return self.getItemAttrOnlineSum(self.modules, 'upgradeCost')
|
||||
@@ -668,6 +674,23 @@ class Fit(object):
|
||||
|
||||
return amount
|
||||
|
||||
@property
|
||||
def fighterBayUsed(self):
|
||||
amount = 0
|
||||
for f in self.fighters:
|
||||
amount += f.item.volume * f.amountActive
|
||||
|
||||
return amount
|
||||
|
||||
@property
|
||||
def fighterTubesUsed(self):
|
||||
amount = 0
|
||||
for f in self.fighters:
|
||||
if f.active:
|
||||
amount += 1
|
||||
|
||||
return amount
|
||||
|
||||
@property
|
||||
def cargoBayUsed(self):
|
||||
amount = 0
|
||||
|
||||
Reference in New Issue
Block a user