mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
https://github.com/Khopa/dcs_liberation/issues/658 (cherry picked from commit b53cac4c7a9f35d0d0a9a4d7a3bf37d2357a4f33)
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
from typing import Optional
|
|
|
|
from PySide2.QtWidgets import QGroupBox, QHBoxLayout, QLabel, QVBoxLayout
|
|
|
|
from game import Game
|
|
|
|
|
|
class QIntelBox(QGroupBox):
|
|
def __init__(self, game: Game) -> None:
|
|
super().__init__("Intel")
|
|
self.game = game
|
|
|
|
columns = QHBoxLayout()
|
|
self.setLayout(columns)
|
|
|
|
summary = QVBoxLayout()
|
|
columns.addLayout(summary)
|
|
|
|
self.total_aircraft = QLabel()
|
|
summary.addWidget(self.total_aircraft)
|
|
self.total_ground_forces = QLabel()
|
|
summary.addWidget(self.total_ground_forces)
|
|
|
|
self.update_summary()
|
|
|
|
def set_game(self, game: Optional[Game]) -> None:
|
|
self.game = game
|
|
self.update_summary()
|
|
|
|
def update_summary(self) -> None:
|
|
if self.game is None:
|
|
aircraft = 0
|
|
ground_units = 0
|
|
else:
|
|
data = self.game.game_stats.data_per_turn[-1]
|
|
aircraft = data.enemy_units.aircraft_count
|
|
ground_units = data.enemy_units.vehicles_count
|
|
self.total_aircraft.setText(f"Total enemy aircraft: {aircraft}")
|
|
self.total_ground_forces.setText(
|
|
f"Total enemy ground units: {ground_units}")
|