Skip to content

Commit

Permalink
Merge pull request #514 from loathingKernel/next
Browse files Browse the repository at this point in the history
Fix games not launching due to requesting to launch offline
  • Loading branch information
loathingKernel authored Jan 11, 2025
2 parents d3331bc + e3a6bdd commit 42c5167
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 86 deletions.
4 changes: 2 additions & 2 deletions rare/commands/launcher/lgd_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def from_argparse(cls, args):
debug=args.debug,
offline=args.offline,
skip_update_check=args.skip_update_check,
wine_bin=args.wine_bin,
wine_prefix=args.wine_pfx,
wine_bin=args.wine_bin if hasattr(args, "wine_bin") else "",
wine_prefix=args.wine_pfx if hasattr(args, "wine_prefix") else "",
dry_run=args.dry_run
)

Expand Down
8 changes: 4 additions & 4 deletions rare/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from rare.models.options import options
from rare.components.dialogs.launch_dialog import LaunchDialog
from rare.components.main_window import MainWindow
from rare.components.main_window import RareWindow
from rare.shared import RareCore
from rare.utils import paths
from rare.utils.misc import ExitCodes
Expand Down Expand Up @@ -50,7 +50,7 @@ def __init__(self, args: Namespace):
self.load_translator(language)

# set Application name for settings
self.main_window: Optional[MainWindow] = None
self.main_window: Optional[RareWindow] = None
self.launch_dialog: Optional[LaunchDialog] = None
self.relogin_timer: Optional[QTimer] = None

Expand Down Expand Up @@ -91,10 +91,10 @@ def __on_start_app(self):
self.relogin_timer.timeout.connect(self.relogin)
self.poke_timer()

self.main_window = MainWindow()
self.main_window = RareWindow()
self.main_window.exit_app.connect(self.__on_exit_app)

if not self.args.silent:
if (not self.args.silent) and (not self.settings.value(*options.sys_tray_start)):
self.main_window.show()

if self.args.test_start:
Expand Down
14 changes: 7 additions & 7 deletions rare/components/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
logger = getLogger("MainWindow")


class MainWindow(QMainWindow):
class RareWindow(QMainWindow):
# int: exit code
exit_app: Signal = Signal(int)

def __init__(self, parent=None):
self.__exit_code = 0
self.__accept_close = False
self._window_launched = False
super(MainWindow, self).__init__(parent=parent)
super(RareWindow, self).__init__(parent=parent)
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, True)
self.rcore = RareCore.instance()
self.core = RareCore.instance().core()
Expand Down Expand Up @@ -149,7 +149,7 @@ def center_window(self):

@Slot()
def show(self) -> None:
super(MainWindow, self).show()
super(RareWindow, self).show()
if not self._window_launched:
self.center_window()
self._window_launched = True
Expand All @@ -158,7 +158,7 @@ def hide(self) -> None:
if self.settings.value(*options.restore_window):
self.settings.setValue(options.window_width.key, self.size().width())
self.settings.setValue(options.window_height.key, self.size().height())
super(MainWindow, self).hide()
super(RareWindow, self).hide()

def toggle(self):
if self.isHidden():
Expand Down Expand Up @@ -212,13 +212,13 @@ def __on_exit_app(self, exit_code=0) -> None:

def close(self) -> bool:
self.__accept_close = True
return super(MainWindow, self).close()
return super(RareWindow, self).close()

def closeEvent(self, e: QCloseEvent) -> None:
# lk: `accept_close` is set to `True` by the `close()` method, overrides exiting to tray in `closeEvent()`
# lk: ensures exiting instead of hiding when `close()` is called programmatically
if not self.__accept_close:
if self.settings.value(*options.sys_tray):
if self.settings.value(*options.sys_tray_close):
self.hide()
e.ignore()
return
Expand Down Expand Up @@ -265,5 +265,5 @@ def closeEvent(self, e: QCloseEvent) -> None:
self.tray_icon.deleteLater()
self.hide()
self.exit_app.emit(self.__exit_code)
super(MainWindow, self).closeEvent(e)
super(RareWindow, self).closeEvent(e)

19 changes: 16 additions & 3 deletions rare/components/tabs/settings/rare.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,22 @@ def __init__(self, parent=None):
self.discord_rpc_settings = DiscordRPCSettings(self)
self.ui.right_layout.insertWidget(1, self.discord_rpc_settings, alignment=Qt.AlignmentFlag.AlignTop)

self.ui.sys_tray.setChecked(self.settings.value(*options.sys_tray))
self.ui.sys_tray.stateChanged.connect(
lambda: self.settings.setValue(options.sys_tray.key, self.ui.sys_tray.isChecked())
self.ui.sys_tray_close.setChecked(self.settings.value(*options.sys_tray_close))
self.ui.sys_tray_close.stateChanged.connect(
lambda: self.settings.setValue(options.sys_tray_close.key, self.ui.sys_tray_close.isChecked())
)

self.ui.sys_tray_start.setChecked(self.settings.value(*options.sys_tray_start))
self.ui.sys_tray_start.stateChanged.connect(
lambda: self.settings.setValue(options.sys_tray_start.key, self.ui.sys_tray_start.isChecked())
)

# Disable starting in system tray if closing to system tray is disabled.
self.ui.sys_tray_close.checkStateChanged.connect(
lambda: self.ui.sys_tray_start.setChecked(False)
)
self.ui.sys_tray_close.checkStateChanged.connect(
lambda: self.ui.sys_tray_start.setEnabled(self.ui.sys_tray_close.isChecked())
)

self.ui.auto_update.setChecked(self.settings.value(*options.auto_update))
Expand Down
14 changes: 8 additions & 6 deletions rare/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import multiprocessing
import os
import pathlib
import platform
import sys
from argparse import ArgumentParser

Expand Down Expand Up @@ -65,16 +66,17 @@ def main() -> int:
launch_parser.add_argument("--dry-run", help="Print arguments and exit", action="store_true")
launch_parser.add_argument("--offline", help="Launch game offline",
action="store_true")
launch_parser.add_argument('--wine-bin', dest='wine_bin', action='store', metavar='<wine binary>',
default=os.environ.get('LGDRY_WINE_BINARY', None),
help='Set WINE binary to use to launch the app')
launch_parser.add_argument('--wine-prefix', dest='wine_pfx', action='store', metavar='<wine pfx path>',
default=os.environ.get('LGDRY_WINE_PREFIX', None),
help='Set WINE prefix to use')
launch_parser.add_argument("--ask-sync-saves", help="Ask to sync cloud saves",
action="store_true")
launch_parser.add_argument("--skip-update-check", help="Do not check for updates",
action="store_true")
if platform.system() != "Windows":
launch_parser.add_argument('--wine-bin', dest='wine_bin', action='store', metavar='<wine binary>',
default=os.environ.get('LGDRY_WINE_BINARY', None),
help='Set WINE binary to use to launch the app')
launch_parser.add_argument('--wine-prefix', dest='wine_pfx', action='store', metavar='<wine pfx path>',
default=os.environ.get('LGDRY_WINE_PREFIX', None),
help='Set WINE prefix to use')

login_parser = subparsers.add_parser("login", aliases=["auth"])
login_parser.add_argument("egl_version", help="Epic Games Launcher User Agent version",
Expand Down
8 changes: 4 additions & 4 deletions rare/models/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from rare.shared.image_manager import ImageManager
from rare.utils.paths import data_dir, get_rare_executable
from rare.utils.steam_grades import get_rating
from rare.utils.config_helper import set_envvar, get_option
from rare.utils.config_helper import set_envvar, get_boolean

logger = getLogger("RareGame")

Expand Down Expand Up @@ -566,10 +566,10 @@ def launch(

cmd_line = get_rare_executable()
executable, args = cmd_line[0], cmd_line[1:]
args.extend(["launch", self.app_name])
if offline or get_option(self.app_name, "offline", fallback=None):
args.extend(("launch", self.app_name))
if offline or get_boolean(self.app_name, "offline", fallback=False):
args.append("--offline")
if skip_update_check or get_option(self.app_name, "skip_update_check", fallback=None):
if skip_update_check or get_boolean(self.app_name, "skip_update_check", fallback=False):
args.append("--skip-update-check")
if wine_bin:
args.extend(["--wine-bin", wine_bin])
Expand Down
5 changes: 4 additions & 1 deletion rare/models/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ class Defaults(Namespace):
exclude_entitlements = Value(key="exclude_entitlements", default=False, dtype=bool)

language = Value(key="language", default=locale.getlocale()[0], dtype=str)
sys_tray = Value(key="sys_tray", default=True, dtype=bool)

sys_tray_close = Value(key="sys_tray", default=True, dtype=bool)
sys_tray_start = Value(key="sys_tray_start", default=False, dtype=bool)

auto_update = Value(key="auto_update", default=False, dtype=bool)
auto_sync_cloud = Value(key="auto_sync_cloud", default=False, dtype=bool)
confirm_start = Value(key="confirm_start", default=False, dtype=bool)
Expand Down
68 changes: 37 additions & 31 deletions rare/ui/components/tabs/settings/rare.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'rare.ui'
##
## Created by: Qt User Interface Compiler version 6.7.2
## Created by: Qt User Interface Compiler version 6.8.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down Expand Up @@ -39,8 +39,8 @@ def setupUi(self, RareSettings):
self.interface_group.setSizePolicy(sizePolicy)
self.interface_layout = QFormLayout(self.interface_group)
self.interface_layout.setObjectName(u"interface_layout")
self.interface_layout.setFieldGrowthPolicy(QFormLayout.FieldsStayAtSizeHint)
self.interface_layout.setLabelAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignTrailing|Qt.AlignmentFlag.AlignVCenter)
self.interface_layout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.FieldsStayAtSizeHint)
self.interface_layout.setLabelAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignmentFlag.AlignTrailing|Qt.AlignmentFlag.AlignVCenter)
self.lang_label = QLabel(self.interface_group)
self.lang_label.setObjectName(u"lang_label")

Expand All @@ -49,7 +49,7 @@ def setupUi(self, RareSettings):
self.lang_select = QComboBox(self.interface_group)
self.lang_select.setObjectName(u"lang_select")

self.interface_layout.setWidget(0, QFormLayout.ItemRole.FieldRole, self.lang_select)
self.interface_layout.setWidget(0, QFormLayout.FieldRole, self.lang_select)

self.color_label = QLabel(self.interface_group)
self.color_label.setObjectName(u"color_label")
Expand All @@ -59,7 +59,7 @@ def setupUi(self, RareSettings):
self.color_select = QComboBox(self.interface_group)
self.color_select.setObjectName(u"color_select")

self.interface_layout.setWidget(1, QFormLayout.ItemRole.FieldRole, self.color_select)
self.interface_layout.setWidget(1, QFormLayout.FieldRole, self.color_select)

self.style_label = QLabel(self.interface_group)
self.style_label.setObjectName(u"style_label")
Expand All @@ -69,7 +69,7 @@ def setupUi(self, RareSettings):
self.style_select = QComboBox(self.interface_group)
self.style_select.setObjectName(u"style_select")

self.interface_layout.setWidget(2, QFormLayout.ItemRole.FieldRole, self.style_select)
self.interface_layout.setWidget(2, QFormLayout.FieldRole, self.style_select)

self.interface_info = QLabel(self.interface_group)
self.interface_info.setObjectName(u"interface_info")
Expand All @@ -88,7 +88,7 @@ def setupUi(self, RareSettings):
self.view_combo = QComboBox(self.interface_group)
self.view_combo.setObjectName(u"view_combo")

self.interface_layout.setWidget(3, QFormLayout.ItemRole.FieldRole, self.view_combo)
self.interface_layout.setWidget(3, QFormLayout.FieldRole, self.view_combo)


self.left_layout.addWidget(self.interface_group)
Expand All @@ -97,44 +97,49 @@ def setupUi(self, RareSettings):
self.settings_group.setObjectName(u"settings_group")
self.behavior_layout = QGridLayout(self.settings_group)
self.behavior_layout.setObjectName(u"behavior_layout")
self.save_size = QCheckBox(self.settings_group)
self.save_size.setObjectName(u"save_size")
self.confirm_start = QCheckBox(self.settings_group)
self.confirm_start.setObjectName(u"confirm_start")

self.behavior_layout.addWidget(self.save_size, 5, 0, 1, 1)
self.behavior_layout.addWidget(self.confirm_start, 3, 0, 1, 1)

self.notification = QCheckBox(self.settings_group)
self.notification.setObjectName(u"notification")
self.sys_tray_close = QCheckBox(self.settings_group)
self.sys_tray_close.setObjectName(u"sys_tray_close")

self.behavior_layout.addWidget(self.notification, 4, 0, 1, 1)
self.behavior_layout.addWidget(self.sys_tray_close, 0, 0, 1, 1)

self.log_games = QCheckBox(self.settings_group)
self.log_games.setObjectName(u"log_games")

self.behavior_layout.addWidget(self.log_games, 6, 0, 1, 1)
self.behavior_layout.addWidget(self.log_games, 7, 0, 1, 1)

self.auto_sync_cloud = QCheckBox(self.settings_group)
self.auto_sync_cloud.setObjectName(u"auto_sync_cloud")

self.sys_tray = QCheckBox(self.settings_group)
self.sys_tray.setObjectName(u"sys_tray")
self.behavior_layout.addWidget(self.auto_sync_cloud, 4, 0, 1, 1)

self.behavior_layout.addWidget(self.sys_tray, 0, 0, 1, 1)
self.save_size = QCheckBox(self.settings_group)
self.save_size.setObjectName(u"save_size")

self.behavior_layout.addWidget(self.save_size, 6, 0, 1, 1)

self.auto_update = QCheckBox(self.settings_group)
self.auto_update.setObjectName(u"auto_update")

self.behavior_layout.addWidget(self.auto_update, 1, 0, 1, 1)
self.behavior_layout.addWidget(self.auto_update, 2, 0, 1, 1)

self.confirm_start = QCheckBox(self.settings_group)
self.confirm_start.setObjectName(u"confirm_start")
self.settings_hspacer = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)

self.behavior_layout.addWidget(self.confirm_start, 2, 0, 1, 1)
self.behavior_layout.addItem(self.settings_hspacer, 3, 1, 2, 1)

self.auto_sync_cloud = QCheckBox(self.settings_group)
self.auto_sync_cloud.setObjectName(u"auto_sync_cloud")
self.notification = QCheckBox(self.settings_group)
self.notification.setObjectName(u"notification")

self.behavior_layout.addWidget(self.auto_sync_cloud, 3, 0, 1, 1)
self.behavior_layout.addWidget(self.notification, 5, 0, 1, 1)

self.settings_hspacer = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
self.sys_tray_start = QCheckBox(self.settings_group)
self.sys_tray_start.setObjectName(u"sys_tray_start")

self.behavior_layout.addItem(self.settings_hspacer, 2, 1, 2, 1)
self.behavior_layout.addWidget(self.sys_tray_start, 1, 0, 1, 1)


self.left_layout.addWidget(self.settings_group)
Expand Down Expand Up @@ -213,13 +218,14 @@ def retranslateUi(self, RareSettings):
self.interface_info.setText(QCoreApplication.translate("RareSettings", u"Restart Rare to apply changes.", None))
self.view_label.setText(QCoreApplication.translate("RareSettings", u"Library view", None))
self.settings_group.setTitle(QCoreApplication.translate("RareSettings", u"Behavior", None))
self.save_size.setText(QCoreApplication.translate("RareSettings", u"Restore window size on application startup", None))
self.notification.setText(QCoreApplication.translate("RareSettings", u"Show notifications when downloads complete", None))
self.log_games.setText(QCoreApplication.translate("RareSettings", u"Show console window when launching games", None))
self.sys_tray.setText(QCoreApplication.translate("RareSettings", u"Close to system tray", None))
self.auto_update.setText(QCoreApplication.translate("RareSettings", u"Queue game updates on application startup", None))
self.confirm_start.setText(QCoreApplication.translate("RareSettings", u"Confirm before launching games", None))
self.sys_tray_close.setText(QCoreApplication.translate("RareSettings", u"Close to system tray", None))
self.log_games.setText(QCoreApplication.translate("RareSettings", u"Show console window when launching games", None))
self.auto_sync_cloud.setText(QCoreApplication.translate("RareSettings", u"Automatically upload/download cloud saves", None))
self.save_size.setText(QCoreApplication.translate("RareSettings", u"Restore window size on application startup", None))
self.auto_update.setText(QCoreApplication.translate("RareSettings", u"Queue game updates on application startup", None))
self.notification.setText(QCoreApplication.translate("RareSettings", u"Show notifications when downloads complete", None))
self.sys_tray_start.setText(QCoreApplication.translate("RareSettings", u"Start minimized to the system tray", None))
self.log_dir_group.setTitle(QCoreApplication.translate("RareSettings", u"Logs", None))
self.log_dir_open_button.setText(QCoreApplication.translate("RareSettings", u"Open log folder", None))
self.log_dir_clean_button.setText(QCoreApplication.translate("RareSettings", u"Clean log folder", None))
Expand Down
Loading

0 comments on commit 42c5167

Please sign in to comment.