mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
This appears to be incompatible with pyinstaller. I get the following when trying to run the executable generated with pyside6: ``` Traceback (most recent call last): File "qt_ui\main.py", line 29, in <module> File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module File "qt_ui\windows\QLiberationWindow.py", line 28, in <module> File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module File "qt_ui\widgets\map\QLiberationMap.py", line 11, in <module> ImportError: could not import module 'PySide6.QtPrintSupport' ```
88 lines
2.8 KiB
Python
88 lines
2.8 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.building_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)
|