mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
New automatic de-briefing system implemented
This commit is contained in:
@@ -47,12 +47,6 @@ if __name__ == "__main__":
|
||||
copyfile("./resources/scripts/MissionScripting.lua", installation.get_dcs_install_directory() + os.path.sep + "Scripts/MissionScripting.lua")
|
||||
app.processEvents()
|
||||
|
||||
# Create DCS Liberation script folder
|
||||
script_dir = installation.get_dcs_saved_games_directory() + os.sep + "Scripts" + os.sep + "DCSLiberation"
|
||||
if not os.path.exists(script_dir):
|
||||
os.makedirs(script_dir)
|
||||
copyfile("./resources/scripts/json.lua", script_dir + os.path.sep + "json.lua")
|
||||
|
||||
# Apply CSS (need works)
|
||||
app.setStyleSheet(css)
|
||||
GameUpdateSignal()
|
||||
|
||||
11
qt_ui/widgets/QDebriefingInformation.py
Normal file
11
qt_ui/widgets/QDebriefingInformation.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from PySide2.QtWidgets import QFrame
|
||||
|
||||
|
||||
class QDebriefingInformation(QFrame):
|
||||
"""
|
||||
UI component to display debreifing informations
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(QDebriefingInformation, self).__init__()
|
||||
self.init_ui()
|
||||
@@ -19,9 +19,6 @@ class QDebriefingWindow(QDialog):
|
||||
self.gameEvent = gameEvent
|
||||
self.debriefing = debriefing
|
||||
|
||||
self.player_losses = debriefing.destroyed_units.get(self.game.player_country, {})
|
||||
self.enemy_losses = debriefing.destroyed_units.get(self.game.enemy_country, {})
|
||||
|
||||
self.initUI()
|
||||
|
||||
def initUI(self):
|
||||
@@ -44,7 +41,12 @@ class QDebriefingWindow(QDialog):
|
||||
lostUnits.setLayout(lostUnitsLayout)
|
||||
|
||||
row = 0
|
||||
for unit_type, count in self.player_losses.items():
|
||||
for unit_type, count in self.debriefing.player_dead_aircraft_dict.items():
|
||||
lostUnitsLayout.addWidget(QLabel(db.unit_type_name(unit_type)), row, 0)
|
||||
lostUnitsLayout.addWidget(QLabel("{}".format(count)), row, 1)
|
||||
row += 1
|
||||
|
||||
for unit_type, count in self.debriefing.player_dead_units_dict.items():
|
||||
lostUnitsLayout.addWidget(QLabel(db.unit_type_name(unit_type)), row, 0)
|
||||
lostUnitsLayout.addWidget(QLabel("{}".format(count)), row, 1)
|
||||
row += 1
|
||||
@@ -56,13 +58,20 @@ class QDebriefingWindow(QDialog):
|
||||
enemylostUnitsLayout = QGridLayout()
|
||||
enemylostUnits.setLayout(enemylostUnitsLayout)
|
||||
|
||||
row = 0
|
||||
if self.debriefing.destroyed_objects:
|
||||
enemylostUnitsLayout.addWidget(QLabel("Ground assets"), row, 0)
|
||||
enemylostUnitsLayout.addWidget(QLabel("{}".format(len(self.debriefing.destroyed_objects))), row, 1)
|
||||
#row = 0
|
||||
#if self.debriefing.destroyed_objects:
|
||||
# enemylostUnitsLayout.addWidget(QLabel("Ground assets"), row, 0)
|
||||
# enemylostUnitsLayout.addWidget(QLabel("{}".format(len(self.debriefing.destroyed_objects))), row, 1)
|
||||
# row += 1
|
||||
|
||||
for unit_type, count in self.debriefing.enemy_dead_aircraft_dict.items():
|
||||
if count == 0:
|
||||
continue
|
||||
enemylostUnitsLayout.addWidget(QLabel(db.unit_type_name(unit_type)), row, 0)
|
||||
enemylostUnitsLayout.addWidget(QLabel("{}".format(count)), row, 1)
|
||||
row += 1
|
||||
|
||||
for unit_type, count in self.enemy_losses.items():
|
||||
for unit_type, count in self.debriefing.enemy_dead_units_dict.items():
|
||||
if count == 0:
|
||||
continue
|
||||
enemylostUnitsLayout.addWidget(QLabel(db.unit_type_name(unit_type)), row, 0)
|
||||
|
||||
@@ -1,14 +1,32 @@
|
||||
import os
|
||||
|
||||
from PySide2 import QtCore
|
||||
from PySide2.QtCore import QObject, Signal
|
||||
from PySide2.QtGui import QMovie, QIcon
|
||||
from PySide2.QtWidgets import QLabel, QDialog, QVBoxLayout
|
||||
from PySide2.QtWidgets import QLabel, QDialog, QVBoxLayout, QGroupBox, QGridLayout, QPushButton
|
||||
|
||||
from game.game import Event, Game
|
||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||
from userdata.debriefing import wait_for_debriefing, Debriefing
|
||||
from userdata.persistency import base_path
|
||||
|
||||
class DebriefingFileWrittenSignal(QObject):
|
||||
|
||||
instance = None
|
||||
debriefingReceived = Signal(Debriefing)
|
||||
|
||||
def __init__(self):
|
||||
super(DebriefingFileWrittenSignal, self).__init__()
|
||||
DebriefingFileWrittenSignal.instance = self
|
||||
|
||||
def sendDebriefing(self, debriefing: Debriefing):
|
||||
self.debriefingReceived.emit(debriefing)
|
||||
|
||||
@staticmethod
|
||||
def get_instance():
|
||||
return DebriefingFileWrittenSignal.instance
|
||||
|
||||
DebriefingFileWrittenSignal()
|
||||
|
||||
class QWaitingForMissionResultWindow(QDialog):
|
||||
|
||||
@@ -22,34 +40,67 @@ class QWaitingForMissionResultWindow(QDialog):
|
||||
self.setWindowIcon(QIcon("./resources/icon.png"))
|
||||
|
||||
self.initUi()
|
||||
wait_for_debriefing(lambda debriefing: self.process_debriefing(debriefing))
|
||||
DebriefingFileWrittenSignal.get_instance().debriefingReceived.connect(self.updateLayout)
|
||||
wait_for_debriefing(lambda debriefing: self.on_debriefing_udpate(debriefing), self.game)
|
||||
|
||||
def initUi(self):
|
||||
self.layout = QVBoxLayout()
|
||||
self.layout.addWidget(QLabel("<b>You are clear for takeoff !</b>"))
|
||||
self.layout.addWidget(QLabel("In DCS open and play the mission : "))
|
||||
self.layout.addWidget(QLabel("<i>liberation_nextturn</i>"))
|
||||
self.layout.addWidget(QLabel("or"))
|
||||
self.layout.addWidget(QLabel("<i>liberation_nextturn_quick</i>"))
|
||||
self.layout.addWidget(QLabel("<b>Then save the debriefing to the folder :</b>"))
|
||||
self.layout.addWidget(QLabel(self.debriefing_directory_location()))
|
||||
self.layout = QGridLayout()
|
||||
self.gridLayout = QGridLayout()
|
||||
self.gridLayout.addWidget(QLabel("<b>You are clear for takeoff !</b>"),0,0)
|
||||
self.gridLayout.addWidget(QLabel("In DCS open and start playing the mission : "),1,0)
|
||||
self.gridLayout.addWidget(QLabel("<i>liberation_nextturn</i>"),2,0)
|
||||
self.gridLayout.addWidget(QLabel("or"),3,0)
|
||||
self.gridLayout.addWidget(QLabel("<i>liberation_nextturn_quick</i>"),4,0)
|
||||
|
||||
progress = QLabel("")
|
||||
progress.setAlignment(QtCore.Qt.AlignCenter)
|
||||
progressBar = QMovie("./resources/ui/loader.gif")
|
||||
progress.setMovie(progressBar)
|
||||
self.layout.addWidget(progress)
|
||||
self.gridLayout.addWidget(progress,5,0)
|
||||
progressBar.start()
|
||||
|
||||
self.layout.addLayout(self.gridLayout,0,0)
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def updateLayout(self, debriefing):
|
||||
updateBox = QGroupBox("Mission status")
|
||||
updateLayout = QGridLayout()
|
||||
updateBox.setLayout(updateLayout)
|
||||
|
||||
updateLayout.addWidget(QLabel("<b>Aircrafts destroyed</b>"), 0, 0)
|
||||
updateLayout.addWidget(QLabel(str(len(debriefing.killed_aircrafts))), 0, 1)
|
||||
|
||||
updateLayout.addWidget(QLabel("<b>Ground units destroyed</b>"), 1, 0)
|
||||
updateLayout.addWidget(QLabel(str(len(debriefing.killed_ground_units))), 1, 1)
|
||||
|
||||
updateLayout.addWidget(QLabel("<b>Weapons fired</b>"), 2, 0)
|
||||
updateLayout.addWidget(QLabel(str(len(debriefing.weapons_fired))), 2, 1)
|
||||
|
||||
updateLayout.addWidget(QLabel("<b>Base Capture Events</b>"), 3, 0)
|
||||
updateLayout.addWidget(QLabel(str(len(debriefing.base_capture_events))), 3, 1)
|
||||
|
||||
# Clear previous content of the window
|
||||
for i in reversed(range(self.gridLayout.count())):
|
||||
self.gridLayout.itemAt(i).widget().setParent(None)
|
||||
|
||||
# Set new window content
|
||||
self.gridLayout.addWidget(updateBox, 0, 0)
|
||||
|
||||
if not debriefing.mission_ended:
|
||||
self.gridLayout.addWidget(QLabel("<b>Mission is being played</b>"), 1, 0)
|
||||
else:
|
||||
#self.gridLayout.addWidget(QLabel("<b>Mission is over !</b>"), 1, 0)
|
||||
proceed = QPushButton("Accept results")
|
||||
proceed.setProperty("style", "btn-primary")
|
||||
proceed.clicked.connect(lambda: self.process_debriefing(debriefing))
|
||||
self.gridLayout.addWidget(proceed, 1, 0)
|
||||
|
||||
def on_debriefing_udpate(self, debriefing):
|
||||
print("On Debriefing update")
|
||||
print(debriefing)
|
||||
DebriefingFileWrittenSignal.get_instance().sendDebriefing(debriefing)
|
||||
wait_for_debriefing(lambda debriefing: self.on_debriefing_udpate(debriefing), self.game)
|
||||
|
||||
def process_debriefing(self, debriefing: Debriefing):
|
||||
|
||||
debriefing.calculate_units(regular_mission=self.gameEvent.operation.regular_mission,
|
||||
quick_mission=self.gameEvent.operation.quick_mission,
|
||||
player_country=self.game.player_country,
|
||||
enemy_country=self.game.enemy_country)
|
||||
|
||||
self.game.finish_event(event=self.gameEvent, debriefing=debriefing)
|
||||
self.game.pass_turn(ignored_cps=[self.gameEvent.to_cp, ])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user