diff --git a/rare/commands/launcher/__init__.py b/rare/commands/launcher/__init__.py index d075f62ca..83c5eea21 100644 --- a/rare/commands/launcher/__init__.py +++ b/rare/commands/launcher/__init__.py @@ -35,15 +35,15 @@ } -class PreLaunchThread(QRunnable): +class PreLaunch(QRunnable): class Signals(QObject): ready_to_launch = pyqtSignal(LaunchArgs) - started_pre_launch_command = pyqtSignal() + pre_launch_command_started = pyqtSignal() pre_launch_command_finished = pyqtSignal(int) # exit_code error_occurred = pyqtSignal(str) def __init__(self, args: InitArgs, rgame: RareGameSlim, sync_action=None): - super(PreLaunchThread, self).__init__() + super(PreLaunch, self).__init__() self.signals = self.Signals() self.logger = getLogger(type(self).__name__) self.args = args @@ -76,7 +76,7 @@ def prepare_launch(self, args: InitArgs) -> Optional[LaunchArgs]: if launch_args.pre_launch_command: proc = get_configured_process() proc.setProcessEnvironment(launch_args.environment) - self.signals.started_pre_launch_command.emit() + self.signals.pre_launch_command_started.emit() pre_launch_command = shlex.split(launch_args.pre_launch_command) # self.logger.debug("Executing prelaunch command %s, %s", pre_launch_command[0], pre_launch_command[1:]) proc.start(pre_launch_command[0], pre_launch_command[1:]) @@ -174,13 +174,13 @@ def __init__(self, args: InitArgs): @pyqtSlot() def __proc_log_stdout(self): - self.console.log( + self.console.log_stdout( self.game_process.readAllStandardOutput().data().decode("utf-8", "ignore") ) @pyqtSlot() def __proc_log_stderr(self): - self.console.error( + self.console.log_stderr( self.game_process.readAllStandardError().data().decode("utf-8", "ignore") ) @@ -327,7 +327,7 @@ def error_occurred(self, error_str: str): self.stop() def start_prepare(self, sync_action=None): - worker = PreLaunchThread(self.args, self.rgame, sync_action) + worker = PreLaunch(self.args, self.rgame, sync_action) worker.signals.ready_to_launch.connect(self.launch_game) worker.signals.error_occurred.connect(self.error_occurred) # worker.signals.started_pre_launch_command(None) diff --git a/rare/commands/launcher/console_dialog.py b/rare/commands/launcher/console_dialog.py index 9df2c1370..a952bc5ef 100644 --- a/rare/commands/launcher/console_dialog.py +++ b/rare/commands/launcher/console_dialog.py @@ -1,3 +1,4 @@ +import os from typing import Union from PyQt5.QtCore import QProcessEnvironment, pyqtSignal, QSize, Qt @@ -31,8 +32,8 @@ def __init__(self, app_title: str, parent=None): self.setGeometry(0, 0, 640, 480) layout = QVBoxLayout() - self.console = ConsoleEdit(self) - layout.addWidget(self.console) + self.console_edit = ConsoleEdit(self) + layout.addWidget(self.console_edit) button_layout = QHBoxLayout() @@ -46,7 +47,7 @@ def __init__(self, app_title: str, parent=None): self.clear_button = QPushButton(self.tr("Clear console")) button_layout.addWidget(self.clear_button) - self.clear_button.clicked.connect(self.console.clear) + self.clear_button.clicked.connect(self.console_edit.clear) button_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Fixed)) @@ -102,7 +103,7 @@ def save(self): if "." not in file: file += ".log" with open(file, "w") as f: - f.write(self.console.toPlainText()) + f.write(self.console_edit.toPlainText()) f.close() self.save_button.setText(self.tr("Saved")) @@ -113,15 +114,21 @@ def show_env(self): self.env_variables.setTable(self.env) self.env_variables.show() - def log(self, text: str, end: str = "\n"): - self.console.log(text + end) + def log(self, text: str): + self.console_edit.log(f"Rare: {text}") - def error(self, text, end: str = "\n"): - self.console.error(text + end) + def log_stdout(self, text: str): + self.console_edit.log(text) + + def error(self, text): + self.console_edit.error(f"Rare: {text}") + + def log_stderr(self, text): + self.console_edit.error(text) def on_process_exit(self, app_title: str, status: Union[int, str]): self.error( - self.tr("Application \"{}\" finished with \"{}\"\n").format(app_title, status) + self.tr("Application finished with exit code \"{}\"").format(status) ) self.accept_close = True @@ -170,17 +177,6 @@ def __init__(self, parent=None): font = QFont("Monospace") font.setStyleHint(QFont.Monospace) self.setFont(font) - self._cursor_output = self.textCursor() - - def log(self, text): - html = f"

{text}

" - self._cursor_output.insertHtml(html) - self.scroll_to_last_line() - - def error(self, text): - html = f"

{text}

" - self._cursor_output.insertHtml(html) - self.scroll_to_last_line() def scroll_to_last_line(self): cursor = self.textCursor() @@ -189,3 +185,14 @@ def scroll_to_last_line(self): QTextCursor.Up if cursor.atBlockStart() else QTextCursor.StartOfLine ) self.setTextCursor(cursor) + + def print_to_console(self, text: str, color: str): + html = f"

{text}

" + self.appendHtml(html) + self.scroll_to_last_line() + + def log(self, text): + self.print_to_console(text, "#aaa") + + def error(self, text): + self.print_to_console(text, "#a33") diff --git a/rare/commands/launcher/lgd_helper.py b/rare/commands/launcher/lgd_helper.py index 4f6ab032d..a7ac0ef1e 100644 --- a/rare/commands/launcher/lgd_helper.py +++ b/rare/commands/launcher/lgd_helper.py @@ -11,7 +11,7 @@ from rare.models.base_game import RareGameSlim -logger = getLogger("Helper") +logger = getLogger("RareLauncherHelper") class GameArgsError(Exception): @@ -156,7 +156,7 @@ def get_launch_args(rgame: RareGameSlim, init_args: InitArgs = None) -> LaunchAr if not rgame.is_installed: raise GameArgsError("Game is not installed or has unsupported format") - if rgame.is_dlc: + if rgame.is_dlc and not rgame.is_launchable_addon: raise GameArgsError("Game is a DLC") if not os.path.exists(rgame.install_path): raise GameArgsError("Game path does not exist") diff --git a/rare/ui/components/tabs/games/game_info/details.py b/rare/ui/components/tabs/games/game_info/details.py index 8321571ae..e47bad728 100644 --- a/rare/ui/components/tabs/games/game_info/details.py +++ b/rare/ui/components/tabs/games/game_info/details.py @@ -62,7 +62,7 @@ def setupUi(self, GameDetails): self.right_layout.setObjectName("right_layout") self.details_layout = QtWidgets.QFormLayout() self.details_layout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize) - self.details_layout.setFieldGrowthPolicy(QtWidgets.QFormLayout.FieldsStayAtSizeHint) + self.details_layout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.details_layout.setLabelAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.details_layout.setContentsMargins(6, 6, 6, 6) self.details_layout.setSpacing(12) @@ -329,11 +329,11 @@ def retranslateUi(self, GameDetails): self.favorites_check.setText(_translate("GameDetails", "Favorites")) self.backlog_check.setText(_translate("GameDetails", "Backlog")) self.lbl_dev.setText(_translate("GameDetails", "Developer")) - self.lbl_app_name.setText(_translate("GameDetails", "Application Name")) + self.lbl_app_name.setText(_translate("GameDetails", "Application name")) self.lbl_version.setText(_translate("GameDetails", "Version")) - self.lbl_grade.setText(_translate("GameDetails", "ProtonDB Grade")) - self.lbl_install_size.setText(_translate("GameDetails", "Installation Size")) - self.lbl_install_path.setText(_translate("GameDetails", "Installation Path")) + self.lbl_grade.setText(_translate("GameDetails", "ProtonDB grade")) + self.lbl_install_size.setText(_translate("GameDetails", "Installation size")) + self.lbl_install_path.setText(_translate("GameDetails", "Installation path")) self.lbl_platform.setText(_translate("GameDetails", "Platform")) self.lbl_game_actions.setText(_translate("GameDetails", "Actions")) self.modify_button.setText(_translate("GameDetails", "Modify")) diff --git a/rare/ui/components/tabs/games/game_info/details.ui b/rare/ui/components/tabs/games/game_info/details.ui index 779bbac14..ce7f9ff09 100644 --- a/rare/ui/components/tabs/games/game_info/details.ui +++ b/rare/ui/components/tabs/games/game_info/details.ui @@ -92,7 +92,7 @@ QLayout::SetFixedSize - QFormLayout::FieldsStayAtSizeHint + QFormLayout::AllNonFixedFieldsGrow Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -162,7 +162,7 @@ - Application Name + Application name Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -226,7 +226,7 @@ - ProtonDB Grade + ProtonDB grade Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -261,7 +261,7 @@ - Installation Size + Installation size Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -293,7 +293,7 @@ - Installation Path + Installation path Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter diff --git a/rare/ui/components/tabs/store/details.py b/rare/ui/components/tabs/store/details.py index e93bdfa64..2c21920fb 100644 --- a/rare/ui/components/tabs/store/details.py +++ b/rare/ui/components/tabs/store/details.py @@ -36,7 +36,7 @@ def setupUi(self, StoreDetailsWidget): self.right_layout.setObjectName("right_layout") self.details_layout = QtWidgets.QFormLayout() self.details_layout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize) - self.details_layout.setFieldGrowthPolicy(QtWidgets.QFormLayout.FieldsStayAtSizeHint) + self.details_layout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.details_layout.setLabelAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.details_layout.setContentsMargins(6, 6, 6, 6) self.details_layout.setSpacing(12) @@ -153,6 +153,11 @@ def setupUi(self, StoreDetailsWidget): self.actions_layout.addWidget(self.wishlist_button) self.details_layout.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.actions) self.price = QtWidgets.QWidget(StoreDetailsWidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.price.sizePolicy().hasHeightForWidth()) + self.price.setSizePolicy(sizePolicy) self.price.setObjectName("price") self.price_layout = QtWidgets.QHBoxLayout(self.price) self.price_layout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize) diff --git a/rare/ui/components/tabs/store/details.ui b/rare/ui/components/tabs/store/details.ui index d2ec9218f..f0b9e726d 100644 --- a/rare/ui/components/tabs/store/details.ui +++ b/rare/ui/components/tabs/store/details.ui @@ -48,7 +48,7 @@ QLayout::SetFixedSize - QFormLayout::FieldsStayAtSizeHint + QFormLayout::AllNonFixedFieldsGrow Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -310,6 +310,12 @@ + + + 0 + 0 + + QLayout::SetFixedSize