Do not exit console, when game exited
This commit is contained in:
parent
fd5fcd3b92
commit
e6fc2323f1
|
@ -1,7 +1,6 @@
|
|||
import datetime
|
||||
import json
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from logging import getLogger
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@dataclass
|
||||
class RunningGameModel:
|
||||
process: GameProcess
|
||||
app_name: str
|
||||
always_ask_sync: bool = False
|
||||
|
||||
|
||||
class GameUtils(QObject):
|
||||
running_games = dict()
|
||||
finished = pyqtSignal(str, str) # app_name, error
|
||||
|
@ -265,6 +257,8 @@ class GameUtils(QObject):
|
|||
return
|
||||
|
||||
if exit_code != 0:
|
||||
pass
|
||||
"""
|
||||
QMessageBox.warning(
|
||||
None,
|
||||
"Warning",
|
||||
|
@ -272,8 +266,8 @@ class GameUtils(QObject):
|
|||
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():
|
||||
self.running_games.pop(app_name)
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ class GameProcessApp(RareApp):
|
|||
if self.console:
|
||||
self.game_process.readyReadStandardOutput.connect(
|
||||
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(
|
||||
|
@ -160,13 +160,14 @@ class GameProcessApp(RareApp):
|
|||
if args.cwd:
|
||||
self.game_process.setWorkingDirectory(args.cwd)
|
||||
self.game_process.setProcessEnvironment(args.env)
|
||||
self.game_process.start(args.executable, args.args)
|
||||
self.send_message(
|
||||
# send start message after process started
|
||||
self.game_process.started.connect(lambda: self.send_message(
|
||||
StateChangedModel(
|
||||
action=Actions.state_update, app_name=self.app_name,
|
||||
new_state=StateChangedModel.States.started
|
||||
)
|
||||
)
|
||||
))
|
||||
self.game_process.start(args.executable, args.args)
|
||||
|
||||
def error_occurred(self, error_str: str):
|
||||
self.logger.warning(error_str)
|
||||
|
@ -208,6 +209,7 @@ def start_game(args: Namespace):
|
|||
)
|
||||
|
||||
app = GameProcessApp(args.app_name)
|
||||
app.setQuitOnLastWindowClosed(True)
|
||||
|
||||
def excepthook(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:
|
||||
return
|
||||
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
|
||||
# quit_button = QPushButton("Quit")
|
||||
# quit_button.show()
|
||||
# quit_button.clicked.connect(lambda: app.exit(0))
|
||||
app.exec_()
|
||||
sys.exit(app.exec_())
|
||||
|
|
Loading…
Reference in a new issue