mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Clean up available parking code a bit.
Moved more into the `ControlPoint`.
This commit is contained in:
parent
c4b8a41742
commit
75edbb62f1
@ -235,7 +235,7 @@ class ControlPoint(MissionTarget):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available_aircraft_slots(self):
|
def total_aircraft_parking(self):
|
||||||
"""
|
"""
|
||||||
:return: The maximum number of aircraft that can be stored in this control point
|
:return: The maximum number of aircraft that can be stored in this control point
|
||||||
"""
|
"""
|
||||||
@ -385,6 +385,10 @@ class ControlPoint(MissionTarget):
|
|||||||
total += self.pending_unit_deliveries.units[unit_bought]
|
total += self.pending_unit_deliveries.units[unit_bought]
|
||||||
return total
|
return total
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unclaimed_parking(self) -> int:
|
||||||
|
return self.total_aircraft_parking - self.expected_aircraft_next_turn
|
||||||
|
|
||||||
|
|
||||||
class OffMapSpawn(ControlPoint):
|
class OffMapSpawn(ControlPoint):
|
||||||
def __init__(self, id: int, name: str, position: Point):
|
def __init__(self, id: int, name: str, position: Point):
|
||||||
@ -400,5 +404,5 @@ class OffMapSpawn(ControlPoint):
|
|||||||
yield from []
|
yield from []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available_aircraft_slots(self) -> int:
|
def total_aircraft_parking(self) -> int:
|
||||||
return 1000
|
return 1000
|
||||||
|
|||||||
@ -32,13 +32,13 @@ class QAircraftRecruitmentMenu(QFrame, QRecruitBehaviour):
|
|||||||
self.existing_units_labels = {}
|
self.existing_units_labels = {}
|
||||||
|
|
||||||
# Determine maximum number of aircrafts that can be bought
|
# Determine maximum number of aircrafts that can be bought
|
||||||
self.set_maximum_units(self.cp.available_aircraft_slots)
|
self.set_maximum_units(self.cp.total_aircraft_parking)
|
||||||
self.set_recruitable_types([CAP, CAS])
|
self.set_recruitable_types([CAP, CAS])
|
||||||
|
|
||||||
self.bought_amount_labels = {}
|
self.bought_amount_labels = {}
|
||||||
self.existing_units_labels = {}
|
self.existing_units_labels = {}
|
||||||
|
|
||||||
self.hangar_status = QHangarStatus(self.total_aircraft, self.cp.available_aircraft_slots)
|
self.hangar_status = QHangarStatus(self.cp)
|
||||||
|
|
||||||
self.init_ui()
|
self.init_ui()
|
||||||
|
|
||||||
@ -82,17 +82,12 @@ class QAircraftRecruitmentMenu(QFrame, QRecruitBehaviour):
|
|||||||
|
|
||||||
def buy(self, unit_type):
|
def buy(self, unit_type):
|
||||||
if self.maximum_units > 0:
|
if self.maximum_units > 0:
|
||||||
if self.total_aircraft + 1 > self.maximum_units:
|
if self.cp.unclaimed_parking <= 0:
|
||||||
logging.debug(f"No space for additional aircraft at {self.cp}.")
|
logging.debug(f"No space for additional aircraft at {self.cp}.")
|
||||||
return
|
return
|
||||||
|
|
||||||
super().buy(unit_type)
|
super().buy(unit_type)
|
||||||
self.hangar_status.update_label(self.total_aircraft,
|
self.hangar_status.update_label()
|
||||||
self.cp.available_aircraft_slots)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def total_aircraft(self) -> int:
|
|
||||||
return self.cp.expected_aircraft_next_turn
|
|
||||||
|
|
||||||
def sell(self, unit_type: UnitType):
|
def sell(self, unit_type: UnitType):
|
||||||
# Don't need to remove aircraft from the inventory if we're canceling
|
# Don't need to remove aircraft from the inventory if we're canceling
|
||||||
@ -110,22 +105,26 @@ class QAircraftRecruitmentMenu(QFrame, QRecruitBehaviour):
|
|||||||
"assigned to a mission?", QMessageBox.Ok)
|
"assigned to a mission?", QMessageBox.Ok)
|
||||||
return
|
return
|
||||||
super().sell(unit_type)
|
super().sell(unit_type)
|
||||||
self.hangar_status.update_label(self.total_aircraft, self.cp.available_aircraft_slots)
|
self.hangar_status.update_label()
|
||||||
|
|
||||||
|
|
||||||
class QHangarStatus(QHBoxLayout):
|
class QHangarStatus(QHBoxLayout):
|
||||||
|
|
||||||
def __init__(self, current_amount: int, max_amount: int):
|
def __init__(self, control_point: ControlPoint) -> None:
|
||||||
super(QHangarStatus, self).__init__()
|
super().__init__()
|
||||||
|
self.control_point = control_point
|
||||||
|
|
||||||
self.icon = QLabel()
|
self.icon = QLabel()
|
||||||
self.icon.setPixmap(ICONS["Hangar"])
|
self.icon.setPixmap(ICONS["Hangar"])
|
||||||
self.text = QLabel("")
|
self.text = QLabel("")
|
||||||
|
|
||||||
self.update_label(current_amount, max_amount)
|
self.update_label()
|
||||||
self.addWidget(self.icon, Qt.AlignLeft)
|
self.addWidget(self.icon, Qt.AlignLeft)
|
||||||
self.addWidget(self.text, Qt.AlignLeft)
|
self.addWidget(self.text, Qt.AlignLeft)
|
||||||
self.addStretch(50)
|
self.addStretch(50)
|
||||||
self.setAlignment(Qt.AlignLeft)
|
self.setAlignment(Qt.AlignLeft)
|
||||||
|
|
||||||
def update_label(self, current_amount: int, max_amount: int):
|
def update_label(self) -> None:
|
||||||
self.text.setText("<strong>{}/{}</strong>".format(current_amount, max_amount))
|
current_amount = self.control_point.expected_aircraft_next_turn
|
||||||
|
max_amount = self.control_point.total_aircraft_parking
|
||||||
|
self.text.setText(f"<strong>{current_amount}/{max_amount}</strong>")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user