From 6094179a4036521f8cfee02f8f7621dfc78ca6c8 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sat, 5 Jun 2021 13:24:12 -0700 Subject: [PATCH] Show pending ground unit count in the base menu. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1161 --- game/theater/controlpoint.py | 18 +++++++++++++----- qt_ui/windows/basemenu/QBaseMenu2.py | 6 +++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/game/theater/controlpoint.py b/game/theater/controlpoint.py index 999f4968..ba4be18a 100644 --- a/game/theater/controlpoint.py +++ b/game/theater/controlpoint.py @@ -151,11 +151,19 @@ class GroundUnitAllocations: @cached_property def total(self) -> int: - return ( - sum(self.present.values()) - + sum(self.ordered.values()) - + sum(self.transferring.values()) - ) + return self.total_present + self.total_ordered + self.total_transferring + + @cached_property + def total_present(self) -> int: + return sum(self.present.values()) + + @cached_property + def total_ordered(self) -> int: + return sum(self.ordered.values()) + + @cached_property + def total_transferring(self) -> int: + return sum(self.transferring.values()) @dataclass diff --git a/qt_ui/windows/basemenu/QBaseMenu2.py b/qt_ui/windows/basemenu/QBaseMenu2.py index a0619b51..4b8265c8 100644 --- a/qt_ui/windows/basemenu/QBaseMenu2.py +++ b/qt_ui/windows/basemenu/QBaseMenu2.py @@ -203,18 +203,22 @@ class QBaseMenu2(QDialog): parking = self.cp.total_aircraft_parking ground_unit_limit = self.cp.frontline_unit_count_limit deployable_unit_info = "" + + allocated = self.cp.allocated_ground_units(self.game_model.game.transfers) unit_overage = max( - self.cp.base.total_armor - self.cp.frontline_unit_count_limit, 0 + allocated.total_present - self.cp.frontline_unit_count_limit, 0 ) if self.cp.has_active_frontline: deployable_unit_info = ( f" (Up to {ground_unit_limit} deployable, {unit_overage} reserve)" ) + self.intel_summary.setText( "\n".join( [ f"{aircraft}/{parking} aircraft", f"{self.cp.base.total_armor} ground units" + deployable_unit_info, + f"{allocated.total_transferring} more ground units en route, {allocated.total_ordered} ordered", str(self.cp.runway_status), f"{self.cp.active_ammo_depots_count}/{self.cp.total_ammo_depots_count} ammo depots", f"{'Factory can produce units' if self.cp.has_factory else 'Does not have a factory'}",