Merge pull request #407 from loathingKernel/develop
RareLauncher: Fix console window wrapping and skip DLC check for launchable addons
This commit is contained in:
commit
94c2f765f3
|
@ -35,15 +35,15 @@ DETACHED_APP_NAMES = {
|
|||
}
|
||||
|
||||
|
||||
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 @@ class PreLaunchThread(QRunnable):
|
|||
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 @@ class RareLauncher(RareApp):
|
|||
|
||||
@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 @@ class RareLauncher(RareApp):
|
|||
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)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
from typing import Union
|
||||
|
||||
from PyQt5.QtCore import QProcessEnvironment, pyqtSignal, QSize, Qt
|
||||
|
@ -31,8 +32,8 @@ class ConsoleDialog(QDialog):
|
|||
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 @@ class ConsoleDialog(QDialog):
|
|||
|
||||
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 @@ class ConsoleDialog(QDialog):
|
|||
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 @@ class ConsoleDialog(QDialog):
|
|||
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 @@ class ConsoleEdit(QPlainTextEdit):
|
|||
font = QFont("Monospace")
|
||||
font.setStyleHint(QFont.Monospace)
|
||||
self.setFont(font)
|
||||
self._cursor_output = self.textCursor()
|
||||
|
||||
def log(self, text):
|
||||
html = f"<p style=\"color:#aaa;white-space:pre\">{text}</p>"
|
||||
self._cursor_output.insertHtml(html)
|
||||
self.scroll_to_last_line()
|
||||
|
||||
def error(self, text):
|
||||
html = f"<p style=\"color:#a33;white-space:pre\">{text}</p>"
|
||||
self._cursor_output.insertHtml(html)
|
||||
self.scroll_to_last_line()
|
||||
|
||||
def scroll_to_last_line(self):
|
||||
cursor = self.textCursor()
|
||||
|
@ -189,3 +185,14 @@ class ConsoleEdit(QPlainTextEdit):
|
|||
QTextCursor.Up if cursor.atBlockStart() else QTextCursor.StartOfLine
|
||||
)
|
||||
self.setTextCursor(cursor)
|
||||
|
||||
def print_to_console(self, text: str, color: str):
|
||||
html = f"<p style=\"color:{color};white-space:pre\">{text}</p>"
|
||||
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")
|
||||
|
|
|
@ -11,7 +11,7 @@ from legendary.models.game import LaunchParameters
|
|||
|
||||
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")
|
||||
|
|
|
@ -62,7 +62,7 @@ class Ui_GameDetails(object):
|
|||
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 @@ class Ui_GameDetails(object):
|
|||
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"))
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::FieldsStayAtSizeHint</enum>
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
@ -162,7 +162,7 @@
|
|||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Application Name</string>
|
||||
<string>Application name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
@ -226,7 +226,7 @@
|
|||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ProtonDB Grade</string>
|
||||
<string>ProtonDB grade</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
@ -261,7 +261,7 @@
|
|||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Installation Size</string>
|
||||
<string>Installation size</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
@ -293,7 +293,7 @@
|
|||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Installation Path</string>
|
||||
<string>Installation path</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
|
|
@ -36,7 +36,7 @@ class Ui_StoreDetailsWidget(object):
|
|||
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 @@ class Ui_StoreDetailsWidget(object):
|
|||
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)
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::FieldsStayAtSizeHint</enum>
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
@ -310,6 +310,12 @@
|
|||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QWidget" name="price" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="price_layout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
|
|
Loading…
Reference in a new issue