mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
- completly refactored the way TGO handles groups and replaced the usage of the pydcs ground groups (vehicle, ship, static) with an own Group and Unit class. - this allows us to only take care of dcs group generation during miz generation, where it should have always been. - We can now have any type of unit (even statics) in the same logic ground group we handle in liberation. this is independent from the dcs group handling. the dcs group will only be genarted when takeoff is pressed. - Refactored the unitmap and the scenery object handling to adopt to changes that now TGOs can hold all Units we want. - Cleaned up many many many lines of uneeded hacks to build stuff around dcs groups. - Removed IDs for TGOs as the names we generate are unique and for liberation to work we need no ids. Unique IDs for dcs will be generated for the units and groups only.
89 lines
2.9 KiB
Python
89 lines
2.9 KiB
Python
import logging
|
|
from typing import Callable, Dict, TypeVar
|
|
|
|
from PySide2.QtGui import QIcon, QPixmap
|
|
from PySide2.QtWidgets import (
|
|
QDialog,
|
|
QGridLayout,
|
|
QGroupBox,
|
|
QLabel,
|
|
QPushButton,
|
|
QVBoxLayout,
|
|
)
|
|
|
|
from game.debriefing import Debriefing
|
|
|
|
|
|
T = TypeVar("T")
|
|
|
|
|
|
class LossGrid(QGridLayout):
|
|
def __init__(self, debriefing: Debriefing, player: bool) -> None:
|
|
super().__init__()
|
|
|
|
self.add_loss_rows(debriefing.air_losses.by_type(player), lambda u: u.name)
|
|
self.add_loss_rows(
|
|
debriefing.front_line_losses_by_type(player), lambda u: str(u)
|
|
)
|
|
self.add_loss_rows(
|
|
debriefing.convoy_losses_by_type(player), lambda u: f"{u} from convoy"
|
|
)
|
|
self.add_loss_rows(
|
|
debriefing.cargo_ship_losses_by_type(player),
|
|
lambda u: f"{u} from cargo ship",
|
|
)
|
|
self.add_loss_rows(
|
|
debriefing.airlift_losses_by_type(player), lambda u: f"{u} from airlift"
|
|
)
|
|
self.add_loss_rows(debriefing.ground_object_losses_by_type(player), lambda u: u)
|
|
self.add_loss_rows(debriefing.scenery_losses_by_type(player), lambda u: u)
|
|
|
|
# TODO: Display dead ground object units and runways.
|
|
|
|
def add_loss_rows(self, losses: Dict[T, int], make_name: Callable[[T], str]):
|
|
for unit_type, count in losses.items():
|
|
row = self.rowCount()
|
|
try:
|
|
name = make_name(unit_type)
|
|
except AttributeError:
|
|
logging.exception(f"Could not make unit name for {unit_type}")
|
|
name = unit_type.id
|
|
self.addWidget(QLabel(name), row, 0)
|
|
self.addWidget(QLabel(str(count)), row, 1)
|
|
|
|
|
|
class QDebriefingWindow(QDialog):
|
|
def __init__(self, debriefing: Debriefing):
|
|
super(QDebriefingWindow, self).__init__()
|
|
self.debriefing = debriefing
|
|
|
|
self.setModal(True)
|
|
self.setWindowTitle("Debriefing")
|
|
self.setMinimumSize(300, 200)
|
|
self.setWindowIcon(QIcon("./resources/icon.png"))
|
|
|
|
layout = QVBoxLayout()
|
|
self.setLayout(layout)
|
|
|
|
header = QLabel(self)
|
|
header.setGeometry(0, 0, 655, 106)
|
|
pixmap = QPixmap("./resources/ui/debriefing.png")
|
|
header.setPixmap(pixmap)
|
|
layout.addWidget(header)
|
|
layout.addStretch()
|
|
|
|
title = QLabel("<b>Casualty report</b>")
|
|
layout.addWidget(title)
|
|
|
|
player_lost_units = QGroupBox(f"{self.debriefing.player_country}'s lost units:")
|
|
player_lost_units.setLayout(LossGrid(debriefing, player=True))
|
|
layout.addWidget(player_lost_units)
|
|
|
|
enemy_lost_units = QGroupBox(f"{self.debriefing.enemy_country}'s lost units:")
|
|
enemy_lost_units.setLayout(LossGrid(debriefing, player=False))
|
|
layout.addWidget(enemy_lost_units)
|
|
|
|
okay = QPushButton("Okay")
|
|
okay.clicked.connect(self.close)
|
|
layout.addWidget(okay)
|