Do not exit console, when game exited
This commit is contained in:
parent
fd5fcd3b92
commit
e6fc2323f1
|
@ -1,7 +1,6 @@
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from dataclasses import dataclass
|
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
||||||
from PyQt5.QtCore import QObject, QProcess, pyqtSignal, QUrl, QTimer
|
from PyQt5.QtCore import QObject, QProcess, pyqtSignal, QUrl, QTimer
|
||||||
|
@ -122,13 +121,6 @@ class GameProcess(QObject):
|
||||||
self.game_finished.emit(exit_code, self.app_name)
|
self.game_finished.emit(exit_code, self.app_name)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class RunningGameModel:
|
|
||||||
process: GameProcess
|
|
||||||
app_name: str
|
|
||||||
always_ask_sync: bool = False
|
|
||||||
|
|
||||||
|
|
||||||
class GameUtils(QObject):
|
class GameUtils(QObject):
|
||||||
running_games = dict()
|
running_games = dict()
|
||||||
finished = pyqtSignal(str, str) # app_name, error
|
finished = pyqtSignal(str, str) # app_name, error
|
||||||
|
@ -265,6 +257,8 @@ class GameUtils(QObject):
|
||||||
return
|
return
|
||||||
|
|
||||||
if exit_code != 0:
|
if exit_code != 0:
|
||||||
|
pass
|
||||||
|
"""
|
||||||
QMessageBox.warning(
|
QMessageBox.warning(
|
||||||
None,
|
None,
|
||||||
"Warning",
|
"Warning",
|
||||||
|
@ -272,8 +266,8 @@ class GameUtils(QObject):
|
||||||
self.core.get_game(app_name).app_title
|
self.core.get_game(app_name).app_title
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
game: RunningGameModel = self.running_games.get(app_name, None)
|
|
||||||
if app_name in self.running_games.keys():
|
if app_name in self.running_games.keys():
|
||||||
self.running_games.pop(app_name)
|
self.running_games.pop(app_name)
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ class GameProcessApp(RareApp):
|
||||||
if self.console:
|
if self.console:
|
||||||
self.game_process.readyReadStandardOutput.connect(
|
self.game_process.readyReadStandardOutput.connect(
|
||||||
lambda: self.console.log(
|
lambda: self.console.log(
|
||||||
self.game_process.readAllStandardOutput().data().decode("utf-8", "ignore")
|
self.game_process.readAllStandardOutput().data().decode("utf-8", "ignore")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.game_process.readyReadStandardError.connect(
|
self.game_process.readyReadStandardError.connect(
|
||||||
|
@ -160,13 +160,14 @@ class GameProcessApp(RareApp):
|
||||||
if args.cwd:
|
if args.cwd:
|
||||||
self.game_process.setWorkingDirectory(args.cwd)
|
self.game_process.setWorkingDirectory(args.cwd)
|
||||||
self.game_process.setProcessEnvironment(args.env)
|
self.game_process.setProcessEnvironment(args.env)
|
||||||
self.game_process.start(args.executable, args.args)
|
# send start message after process started
|
||||||
self.send_message(
|
self.game_process.started.connect(lambda: self.send_message(
|
||||||
StateChangedModel(
|
StateChangedModel(
|
||||||
action=Actions.state_update, app_name=self.app_name,
|
action=Actions.state_update, app_name=self.app_name,
|
||||||
new_state=StateChangedModel.States.started
|
new_state=StateChangedModel.States.started
|
||||||
)
|
)
|
||||||
)
|
))
|
||||||
|
self.game_process.start(args.executable, args.args)
|
||||||
|
|
||||||
def error_occurred(self, error_str: str):
|
def error_occurred(self, error_str: str):
|
||||||
self.logger.warning(error_str)
|
self.logger.warning(error_str)
|
||||||
|
@ -208,6 +209,7 @@ def start_game(args: Namespace):
|
||||||
)
|
)
|
||||||
|
|
||||||
app = GameProcessApp(args.app_name)
|
app = GameProcessApp(args.app_name)
|
||||||
|
app.setQuitOnLastWindowClosed(True)
|
||||||
|
|
||||||
def excepthook(exc_type, exc_value, exc_tb):
|
def excepthook(exc_type, exc_value, exc_tb):
|
||||||
tb = "".join(traceback.format_exception(exc_type, exc_value, exc_tb))
|
tb = "".join(traceback.format_exception(exc_type, exc_value, exc_tb))
|
||||||
|
@ -226,10 +228,6 @@ def start_game(args: Namespace):
|
||||||
if not app.success:
|
if not app.success:
|
||||||
return
|
return
|
||||||
app.start(args)
|
app.start(args)
|
||||||
app.exit_app.connect(lambda: app.exit(0))
|
# app.exit_app.connect(lambda: app.exit(0))
|
||||||
|
|
||||||
# this button is for debug. Closing with keyboard interrupt does not kill the server
|
sys.exit(app.exec_())
|
||||||
# quit_button = QPushButton("Quit")
|
|
||||||
# quit_button.show()
|
|
||||||
# quit_button.clicked.connect(lambda: app.exit(0))
|
|
||||||
app.exec_()
|
|
||||||
|
|
Loading…
Reference in a new issue