Skip to content
Merged
15 changes: 10 additions & 5 deletions rare/commands/launcher/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
import platform
import shlex
import subprocess
Expand All @@ -17,7 +18,6 @@
QUrl,
QRunnable,
QThreadPool,
QSettings,
Qt,
Slot,
QTimer,
Expand Down Expand Up @@ -167,10 +167,7 @@ def __init__(self, args: InitArgs):
language = self.settings.value(*options.language)
self.load_translator(language)

# if QSettings(self).value(*options.log_games) or (
# game.app_name in DETACHED_APP_NAMES and platform.system() == "Windows"
# ):
if QSettings(self).value(*options.log_games):
if args.show_console:
self.console = ConsoleDialog(game.app_title)
self.console.show()

Expand Down Expand Up @@ -339,6 +336,14 @@ def launch_game(self, args: LaunchArgs):
self.stop() # stop because we do not attach to the output
return

# TODO: move to environment configuration, do not resuse variables from this block
# Sanity check environment (mostly for Linux)
command_line = shlex.join((args.executable, *args.arguments))
if os.environ.get("XDG_CURRENT_DESKTOP", None) == "gamescope" or "gamescope" in command_line:
# disable mangohud in gamescope
args.environment.insert("MANGOHUD", "0")
# TODO: end

if args.working_directory:
self.game_process.setWorkingDirectory(args.working_directory)
self.game_process.setProcessEnvironment(args.environment)
Expand Down
10 changes: 6 additions & 4 deletions rare/commands/launcher/lgd_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ class GameArgsError(Exception):

class InitArgs(Namespace):
app_name: str
dry_run: bool = False
debug: bool = False
offline: bool = False
debug: bool = False
dry_run: bool = False
show_console: bool = False
skip_update_check: bool = False
wine_prefix: str = ""
wine_bin: str = ""
Expand All @@ -31,12 +32,13 @@ class InitArgs(Namespace):
def from_argparse(cls, args):
return cls(
app_name=args.app_name,
debug=args.debug,
offline=args.offline,
debug=args.debug,
dry_run=args.dry_run,
show_console=args.show_console,
skip_update_check=args.skip_update_check,
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
1 change: 1 addition & 0 deletions rare/components/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(self, parent=None):
self._window_launched = False
super(RareWindow, self).__init__(parent=parent)
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, True)
# self.setWindowFlag(Qt.WindowType.FramelessWindowHint, True)
self.rcore = RareCore.instance()
self.core = RareCore.instance().core()
self.signals = RareCore.instance().signals()
Expand Down
5 changes: 4 additions & 1 deletion rare/components/tabs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class MainTabWidget(QTabWidget):

def __init__(self, parent):
super(MainTabWidget, self).__init__(parent=parent)
self.setObjectName(type(self).__name__)

self.rcore = RareCore.instance()
self.core = LegendaryCoreSingleton()
Expand All @@ -44,7 +45,7 @@ def __init__(self, parent):
self.setTabEnabled(self.store_index, not self.args.offline)

# Space Tab
space_index = self.addTab(QWidget(self), "")
space_index = self.addTab(QWidget(self), "Rare")
self.setTabEnabled(space_index, False)
self.tab_bar.expanded = space_index

Expand Down Expand Up @@ -76,6 +77,8 @@ def __init__(self, parent):
QShortcut("Alt+3", self).activated.connect(lambda: self.setCurrentIndex(self.store_index))
QShortcut("Alt+4", self).activated.connect(lambda: self.setCurrentIndex(self.settings_index))

self.setCurrentIndex(self.games_index)

@Slot(int)
def __on_downloads_update_title(self, num_downloads: int):
self.setTabText(self.indexOf(self.downloads_tab), self.tr("Downloads ({})").format(num_downloads))
Expand Down
32 changes: 6 additions & 26 deletions rare/components/tabs/store/landing.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ def __init__(self, api: StoreAPI, parent=None):
self.setLayout(layout)
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)

self.free_games_now = StoreGroup(self.tr("Free now"), layout=QHBoxLayout, parent=self)
self.free_games_now = StoreGroup(self.tr("Free now"), layout=FlowLayout, parent=self)
self.free_games_now.main_layout.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
self.free_games_now.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
self.free_games_now.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)

self.free_games_next = StoreGroup(self.tr("Free next week"), layout=QHBoxLayout, parent=self)
self.free_games_next = StoreGroup(self.tr("Free next week"), layout=FlowLayout, parent=self)
self.free_games_next.main_layout.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
self.free_games_next.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
self.free_games_next.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)

self.discounts_group = StoreGroup(self.tr("Wishlist discounts"), layout=FlowLayout, parent=self)
self.discounts_group.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
Expand All @@ -123,28 +123,8 @@ def __init__(self, api: StoreAPI, parent=None):
self.games_group.loading(False)
self.games_group.setVisible(False)

free_scroll = FreeGamesScroll(self)
free_container = QWidget(free_scroll)
free_scroll.setWidget(free_container)
free_container_layout = QHBoxLayout(free_container)

free_scroll.setWidgetResizable(True)
free_scroll.setFrameShape(QScrollArea.Shape.NoFrame)
free_scroll.setSizeAdjustPolicy(QScrollArea.SizeAdjustPolicy.AdjustToContents)
free_scroll.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)

free_container_layout.setContentsMargins(0, 0, 0, 0)
free_container_layout.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)
free_container_layout.setSizeConstraint(QHBoxLayout.SizeConstraint.SetFixedSize)
free_container_layout.addWidget(self.free_games_now)
free_container_layout.addWidget(self.free_games_next)

free_scroll.widget().setAutoFillBackground(False)
free_scroll.viewport().setAutoFillBackground(False)

# layout.addWidget(self.free_games_now, alignment=Qt.AlignmentFlag.AlignTop)
# layout.addWidget(self.free_games_next, alignment=Qt.AlignmentFlag.AlignTop)
layout.addWidget(free_scroll, alignment=Qt.AlignmentFlag.AlignTop)
layout.addWidget(self.free_games_now, alignment=Qt.AlignmentFlag.AlignTop)
layout.addWidget(self.free_games_next, alignment=Qt.AlignmentFlag.AlignTop)
layout.addWidget(self.discounts_group, alignment=Qt.AlignmentFlag.AlignTop)
layout.addWidget(self.games_group, alignment=Qt.AlignmentFlag.AlignTop)
layout.addItem(QSpacerItem(0, 0, QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Expanding))
Expand Down
2 changes: 2 additions & 0 deletions rare/components/tabs/tab_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class MainTabBar(QTabBar):
def __init__(self, parent=None):
super(MainTabBar, self).__init__(parent=parent)
self.setObjectName(type(self).__name__)
self.setProperty("drawBase", False)

font = self.font()
font.setPointSize(font.pointSize() + 1)
font.setBold(True)
Expand Down
71 changes: 43 additions & 28 deletions rare/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ def main() -> int:
"-V", "--version", action="store_true", help="Shows version and exits"
)
parser.add_argument(
"-S",
"--silent",
action="store_true",
help="Launch Rare in background. Open it from System Tray Icon",
"-S", "--silent", action="store_true", help="Launch Rare in background. Open it from System Tray Icon",
)
parser.add_argument(
"--debug", action="store_true", help="Launch in debug mode"
)
parser.add_argument("--debug", action="store_true", help="Launch in debug mode")
parser.add_argument(
"--offline", action="store_true", help="Launch Rare in offline mode"
)
Expand All @@ -47,40 +46,56 @@ def main() -> int:
)

parser.add_argument(
"--desktop-shortcut",
action="store_true",
dest="desktop_shortcut",
"--desktop-shortcut", action="store_true", dest="desktop_shortcut",
help="Use this, if there is no link on desktop to start Rare",
)
parser.add_argument(
"--startmenu-shortcut",
action="store_true",
dest="startmenu_shortcut",
"--startmenu-shortcut", action="store_true", dest="startmenu_shortcut",
help="Use this, if there is no link in start menu to launch Rare",
)
subparsers = parser.add_subparsers(title="Commands", dest="subparser")

# Launch command
launch_parser = subparsers.add_parser("launch", aliases=["start"])
launch_parser.add_argument("app_name", help="AppName of the game to launch",
metavar="<App Name>", action="store")
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("--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")
launch_parser.add_argument(
"--dry-run", action="store_true", help="Print arguments and exit"
)
launch_parser.add_argument(
"--offline", action="store_true", help="Launch game offline"
)
launch_parser.add_argument(
"--ask-sync-saves", action="store_true", help="Ask to sync cloud saves"
)
launch_parser.add_argument(
"--skip-update-check", action="store_true", help="Do not check for updates"
)
launch_parser.add_argument(
"--show-console", action="store_true", help="Show a console window to log the application's output"
)
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')
launch_parser.add_argument(
'--wine-bin', action='store', dest='wine_bin', default=os.environ.get('LGDRY_WINE_BINARY', None),
metavar='<wine binary>',
help="Set WINE binary to use to launch the app",
)
launch_parser.add_argument(
'--wine-prefix', action='store', dest='wine_pfx', default=os.environ.get('LGDRY_WINE_PREFIX', None),
metavar='<wine pfx path>',
help="Set WINE prefix to use",
)
launch_parser.add_argument(
"app_name", action="store",
metavar="<App Name>",
help="AppName of the game to launch",
)

# Login command
login_parser = subparsers.add_parser("login", aliases=["auth"])
login_parser.add_argument("egl_version", help="Epic Games Launcher User Agent version",
metavar="<EGL Version>", action="store")
login_parser.add_argument(
"egl_version", action="store",
metavar="<EGL Version>",
help="Epic Games Launcher User Agent version",
)

args = parser.parse_args()

Expand Down
15 changes: 11 additions & 4 deletions rare/models/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
from threading import Lock
from typing import List, Optional, Dict, Set

from PySide6.QtCore import QRunnable, Slot, QProcess, QThreadPool
from PySide6.QtCore import QRunnable, Slot, QProcess, QThreadPool, QSettings
from PySide6.QtGui import QPixmap
from legendary.lfs import eos
from legendary.models.game import Game, InstalledGame

from rare.models.image import ImageSize
from rare.lgndr.core import LegendaryCore
from rare.models.base_game import RareGameBase, RareGameSlim
from rare.models.image import ImageSize
from rare.models.install import InstallOptionsModel, UninstallOptionsModel
from rare.models.options import options
from rare.shared.game_process import GameProcess
from rare.shared.image_manager import ImageManager
from rare.utils.config_helper import set_envvar, get_boolean
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_boolean

logger = getLogger("RareGame")

Expand Down Expand Up @@ -556,6 +557,7 @@ def uninstall(self) -> bool:

def launch(
self,
debug: bool = False,
offline: bool = False,
skip_update_check: bool = False,
wine_bin: Optional[str] = None,
Expand All @@ -566,15 +568,20 @@ def launch(

cmd_line = get_rare_executable()
executable, args = cmd_line[0], cmd_line[1:]
args.extend(("launch", self.app_name))
args.append("launch")
if offline or get_boolean(self.app_name, "offline", fallback=False):
args.append("--offline")
if debug:
args.append("--debug")
if QSettings(self).value(*options.log_games):
args.append("--show-console")
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])
if wine_pfx:
args.extend(["--wine-prefix", wine_pfx])
args.append(self.app_name)

logger.info(f"Starting game process: ({executable} {' '.join(args)})")
QProcess.startDetached(executable, args)
Expand Down
Loading
Loading