mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Multiple WIP changes on UI / Submit manually debriefing.
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
import json
|
||||
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, QGroupBox, QGridLayout, QPushButton
|
||||
from PySide2.QtCore import QObject, Signal, Qt
|
||||
from PySide2.QtGui import QMovie, QIcon, QPixmap
|
||||
from PySide2.QtWidgets import QLabel, QDialog, QGroupBox, QGridLayout, QPushButton, QFileDialog, QMessageBox, QTextEdit, \
|
||||
QHBoxLayout
|
||||
|
||||
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
|
||||
@@ -38,40 +41,63 @@ class QWaitingForMissionResultWindow(QDialog):
|
||||
self.setWindowTitle("Waiting for mission completion.")
|
||||
self.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False)
|
||||
self.setWindowIcon(QIcon("./resources/icon.png"))
|
||||
self.setMinimumHeight(570)
|
||||
|
||||
self.initUi()
|
||||
DebriefingFileWrittenSignal.get_instance().debriefingReceived.connect(self.updateLayout)
|
||||
wait_for_debriefing(lambda debriefing: self.on_debriefing_udpate(debriefing), self.game)
|
||||
self.wait_thread = wait_for_debriefing(lambda debriefing: self.on_debriefing_udpate(debriefing), self.game)
|
||||
|
||||
def initUi(self):
|
||||
self.layout = QGridLayout()
|
||||
|
||||
header = QLabel(self)
|
||||
header.setGeometry(0, 0, 655, 106)
|
||||
pixmap = QPixmap("./resources/ui/conflict.png")
|
||||
header.setPixmap(pixmap)
|
||||
self.layout.addWidget(header, 0, 0)
|
||||
|
||||
self.gridLayout = QGridLayout()
|
||||
self.gridLayout.addWidget(QLabel("<b>You are clear for takeoff</b>"), 1, 0)
|
||||
self.gridLayout.addWidget(QLabel(""), 2, 0)
|
||||
self.gridLayout.addWidget(QLabel("<h2>For Singleplayer :</h2>"), 3, 0)
|
||||
self.gridLayout.addWidget(QLabel("In DCS, open the Mission Editor, and load the file : "), 4, 0)
|
||||
self.gridLayout.addWidget(QLabel("<i>liberation_nextturn</i>"), 5, 0)
|
||||
self.gridLayout.addWidget(QLabel("Then once the mission is loaded in ME, in menu \"Flight\", click on FLY Mission to launch"), 6, 0)
|
||||
self.gridLayout.addWidget(QLabel(""), 7, 0)
|
||||
self.gridLayout.addWidget(QLabel("<h2>For Multiplayer :</h2>"), 8, 0)
|
||||
self.gridLayout.addWidget(QLabel("In DCS, open the Mission Editor, and load the file : "), 9, 0)
|
||||
self.gridLayout.addWidget(QLabel("<i>liberation_nextturn</i>"), 10, 0)
|
||||
self.gridLayout.addWidget(QLabel("Click on File/Save. Then exit the mission editor, and go to Multiplayer."), 11, 0)
|
||||
self.gridLayout.addWidget(QLabel("Then host a server with the mission, and tell your friends to join !"), 12, 0)
|
||||
self.gridLayout.addWidget(QLabel("(The step in the mission editor is important, and fix a game breaking bug.)"), 13, 0)
|
||||
self.gridLayout.addWidget(QLabel(""), 14, 0)
|
||||
TEXT = "" + \
|
||||
"<b>You are clear for takeoff</b>" + \
|
||||
"" + \
|
||||
"<h2>For Singleplayer :</h2>\n" + \
|
||||
"In DCS, open the Mission Editor, and load the file : \n" + \
|
||||
"<i>liberation_nextturn</i>\n" + \
|
||||
"<p>Then once the mission is loaded in ME, in menu \"Flight\",\n" + \
|
||||
"click on FLY Mission to launch.</p>\n" + \
|
||||
"" + \
|
||||
"<h2>For Multiplayer :</h2>" + \
|
||||
"In DCS, open the Mission Editor, and load the file : " + \
|
||||
"<i>liberation_nextturn</i>" + \
|
||||
"<p>Click on File/Save. Then exit the mission editor, and go to Multiplayer.</p>" + \
|
||||
"<p>Then host a server with the mission, and tell your friends to join !</p>" + \
|
||||
"<i>(The step in the mission editor is important, and fix a game breaking bug.)</i>" + \
|
||||
"<h2>Finishing</h2>" + \
|
||||
"<p>Once you have played the mission, click on the \"Accept Results\" button.</p>"
|
||||
|
||||
self.instructions_text = QTextEdit(TEXT)
|
||||
self.instructions_text.setReadOnly(True)
|
||||
self.gridLayout.addWidget(self.instructions_text, 1, 0)
|
||||
|
||||
progress = QLabel("")
|
||||
progress.setAlignment(QtCore.Qt.AlignCenter)
|
||||
progressBar = QMovie("./resources/ui/loader.gif")
|
||||
progress.setMovie(progressBar)
|
||||
self.gridLayout.addWidget(progress, 15, 0)
|
||||
self.gridLayout.addWidget(QLabel(""), 16, 0)
|
||||
self.gridLayout.addWidget(QLabel("Once you have played the mission, this window will dissapear."), 17, 0)
|
||||
self.gridLayout.addWidget(QLabel("You will have to click on \"Accept Results\" to proceed"), 18, 0)
|
||||
progress_bar = QMovie("./resources/ui/loader.gif")
|
||||
progress.setMovie(progress_bar)
|
||||
|
||||
progressBar.start()
|
||||
self.layout.addLayout(self.gridLayout,0,0)
|
||||
self.actions = QGroupBox("Actions :")
|
||||
self.actions_layout = QHBoxLayout()
|
||||
self.actions.setLayout(self.actions_layout)
|
||||
|
||||
manually_submit = QPushButton("Manually Submit [Advanced users]")
|
||||
manually_submit.clicked.connect(self.submit_manually)
|
||||
self.actions_layout.addWidget(manually_submit)
|
||||
cancel = QPushButton("Abort mission")
|
||||
cancel.clicked.connect(self.close)
|
||||
self.actions_layout.addWidget(cancel)
|
||||
self.gridLayout.addWidget(self.actions, 2, 0)
|
||||
|
||||
progress_bar.start()
|
||||
self.layout.addLayout(self.gridLayout, 1, 0)
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def updateLayout(self, debriefing):
|
||||
@@ -100,6 +126,7 @@ class QWaitingForMissionResultWindow(QDialog):
|
||||
|
||||
if not debriefing.mission_ended:
|
||||
self.gridLayout.addWidget(QLabel("<b>Mission is being played</b>"), 1, 0)
|
||||
self.gridLayout.addWidget(self.actions, 2, 0)
|
||||
else:
|
||||
#self.gridLayout.addWidget(QLabel("<b>Mission is over !</b>"), 1, 0)
|
||||
proceed = QPushButton("Accept results")
|
||||
@@ -111,7 +138,9 @@ class QWaitingForMissionResultWindow(QDialog):
|
||||
print("On Debriefing update")
|
||||
print(debriefing)
|
||||
DebriefingFileWrittenSignal.get_instance().sendDebriefing(debriefing)
|
||||
wait_for_debriefing(lambda debriefing: self.on_debriefing_udpate(debriefing), self.game)
|
||||
|
||||
if not debriefing.mission_ended:
|
||||
self.wait_thread = wait_for_debriefing(lambda debriefing: self.on_debriefing_udpate(debriefing), self.game)
|
||||
|
||||
def process_debriefing(self, debriefing: Debriefing):
|
||||
self.game.finish_event(event=self.gameEvent, debriefing=debriefing)
|
||||
@@ -122,3 +151,28 @@ class QWaitingForMissionResultWindow(QDialog):
|
||||
|
||||
def debriefing_directory_location(self) -> str:
|
||||
return os.path.join(base_path(), "liberation_debriefings")
|
||||
|
||||
def closeEvent(self, evt):
|
||||
super(QWaitingForMissionResultWindow, self).closeEvent(evt)
|
||||
if self.wait_thread is not None:
|
||||
self.wait_thread.stop()
|
||||
|
||||
def submit_manually(self):
|
||||
file = str(QFileDialog.getOpenFileName(self, "Select game file to open", filter="json(*.json)"))
|
||||
print(file)
|
||||
try:
|
||||
with open("state.json", "r") as json_file:
|
||||
json_data = json.load(json_file)
|
||||
json_data["mission_ended"] = True
|
||||
debriefing = Debriefing(json_data, self.game)
|
||||
self.on_debriefing_udpate(debriefing)
|
||||
except:
|
||||
msg = QMessageBox()
|
||||
msg.setIcon(QMessageBox.Information)
|
||||
msg.setText("Invalid file : " + file)
|
||||
msg.setWindowTitle("Invalid file.")
|
||||
msg.setStandardButtons(QMessageBox.Ok)
|
||||
msg.setWindowFlags(Qt.WindowStaysOnTopHint)
|
||||
msg.exec_()
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user