Rare: Add launchable addons as games in the library
This commit is contained in:
parent
ef09354b62
commit
2cbe6cadd9
|
@ -37,9 +37,8 @@ class PreLaunchThread(QRunnable):
|
||||||
|
|
||||||
def __init__(self, core: LegendaryCore, args: InitArgs, rgame: RareGameSlim, sync_action=None):
|
def __init__(self, core: LegendaryCore, args: InitArgs, rgame: RareGameSlim, sync_action=None):
|
||||||
super(PreLaunchThread, self).__init__()
|
super(PreLaunchThread, self).__init__()
|
||||||
self.logger = getLogger(type(self).__name__)
|
|
||||||
self.core = core
|
|
||||||
self.signals = self.Signals()
|
self.signals = self.Signals()
|
||||||
|
self.logger = getLogger(type(self).__name__)
|
||||||
self.args = args
|
self.args = args
|
||||||
self.rgame = rgame
|
self.rgame = rgame
|
||||||
self.sync_action = sync_action
|
self.sync_action = sync_action
|
||||||
|
@ -60,7 +59,7 @@ class PreLaunchThread(QRunnable):
|
||||||
|
|
||||||
def prepare_launch(self, args: InitArgs) -> Optional[LaunchArgs]:
|
def prepare_launch(self, args: InitArgs) -> Optional[LaunchArgs]:
|
||||||
try:
|
try:
|
||||||
launch_args = get_launch_args(self.core, args)
|
launch_args = get_launch_args(self.rgame, args)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.signals.error_occurred.emit(str(e))
|
self.signals.error_occurred.emit(str(e))
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -7,10 +7,9 @@ from logging import getLogger
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from PyQt5.QtCore import QProcess, QProcessEnvironment
|
from PyQt5.QtCore import QProcess, QProcessEnvironment
|
||||||
from legendary.models.game import InstalledGame, LaunchParameters
|
from legendary.models.game import LaunchParameters
|
||||||
|
|
||||||
from rare.lgndr.core import LegendaryCore
|
|
||||||
|
|
||||||
|
from rare.models.base_game import RareGameSlim
|
||||||
|
|
||||||
logger = getLogger("Helper")
|
logger = getLogger("Helper")
|
||||||
|
|
||||||
|
@ -55,9 +54,11 @@ class LaunchArgs:
|
||||||
return bool(self.executable)
|
return bool(self.executable)
|
||||||
|
|
||||||
|
|
||||||
def get_origin_params(core: LegendaryCore, app_name, offline: bool,
|
def get_origin_params(rgame: RareGameSlim, init_args: InitArgs, launch_args: LaunchArgs) -> LaunchArgs:
|
||||||
launch_args: LaunchArgs) -> LaunchArgs:
|
core = rgame.core
|
||||||
origin_uri = core.get_origin_uri(app_name, offline)
|
app_name = rgame.app_name
|
||||||
|
|
||||||
|
origin_uri = core.get_origin_uri(app_name, init_args.offline)
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
launch_args.executable = origin_uri
|
launch_args.executable = origin_uri
|
||||||
launch_args.arguments = []
|
launch_args.arguments = []
|
||||||
|
@ -87,24 +88,25 @@ def get_origin_params(core: LegendaryCore, app_name, offline: bool,
|
||||||
return launch_args
|
return launch_args
|
||||||
|
|
||||||
|
|
||||||
def get_game_params(core: LegendaryCore, igame: InstalledGame, args: InitArgs,
|
def get_game_params(rgame: RareGameSlim, args: InitArgs, launch_args: LaunchArgs) -> LaunchArgs:
|
||||||
launch_args: LaunchArgs) -> LaunchArgs:
|
|
||||||
if not args.offline: # skip for update
|
if not args.offline: # skip for update
|
||||||
if not args.skip_update_check and not core.is_noupdate_game(igame.app_name):
|
if not args.skip_update_check and not rgame.core.is_noupdate_game(rgame.app_name):
|
||||||
# print("Checking for updates...")
|
|
||||||
# check updates
|
|
||||||
try:
|
try:
|
||||||
latest = core.get_asset(
|
latest = rgame.core.get_asset(rgame.app_name, rgame.igame.platform, update=False)
|
||||||
igame.app_name, igame.platform, update=False
|
|
||||||
)
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise GameArgsError("Metadata doesn't exist")
|
raise GameArgsError("Metadata doesn't exist")
|
||||||
else:
|
else:
|
||||||
if latest.build_version != igame.version:
|
if latest.build_version != rgame.igame.version:
|
||||||
raise GameArgsError("Game is not up to date. Please update first")
|
raise GameArgsError("Game is not up to date. Please update first")
|
||||||
|
|
||||||
params: LaunchParameters = core.get_launch_parameters(
|
if (not rgame.igame or not rgame.igame.executable) and rgame.game is not None:
|
||||||
app_name=igame.app_name, offline=args.offline
|
# override installed game with base title
|
||||||
|
if rgame.is_launchable_addon:
|
||||||
|
app_name = rgame.game.metadata['mainGameItem']['releaseInfo'][0]['appId']
|
||||||
|
rgame.igame = rgame.core.get_installed_game(app_name)
|
||||||
|
|
||||||
|
params: LaunchParameters = rgame.core.get_launch_parameters(
|
||||||
|
app_name=rgame.game.app_name, offline=args.offline, addon_app_name=rgame.igame.app_name
|
||||||
)
|
)
|
||||||
|
|
||||||
full_params = []
|
full_params = []
|
||||||
|
@ -135,32 +137,30 @@ def get_game_params(core: LegendaryCore, igame: InstalledGame, args: InitArgs,
|
||||||
return launch_args
|
return launch_args
|
||||||
|
|
||||||
|
|
||||||
def get_launch_args(core: LegendaryCore, args: InitArgs = None) -> LaunchArgs:
|
def get_launch_args(rgame: RareGameSlim, init_args: InitArgs = None) -> LaunchArgs:
|
||||||
game = core.get_game(args.app_name)
|
|
||||||
igame = core.get_installed_game(args.app_name)
|
|
||||||
|
|
||||||
resp = LaunchArgs()
|
resp = LaunchArgs()
|
||||||
|
|
||||||
if not game:
|
if not rgame.game:
|
||||||
raise GameArgsError("Could not find metadata for ")
|
raise GameArgsError(f"Could not find metadata for {rgame.app_title}")
|
||||||
|
|
||||||
if game.third_party_store == "Origin":
|
if rgame.is_origin:
|
||||||
args.offline = False
|
init_args.offline = False
|
||||||
else:
|
else:
|
||||||
if not igame:
|
if not rgame.is_installed:
|
||||||
raise GameArgsError("Game is not installed or has unsupported format")
|
raise GameArgsError("Game is not installed or has unsupported format")
|
||||||
|
|
||||||
if game.is_dlc:
|
if rgame.is_dlc:
|
||||||
raise GameArgsError("Game is a DLC")
|
raise GameArgsError("Game is a DLC")
|
||||||
if not os.path.exists(igame.install_path):
|
if not os.path.exists(rgame.install_path):
|
||||||
raise GameArgsError("Game path does not exist")
|
raise GameArgsError("Game path does not exist")
|
||||||
|
|
||||||
if game.third_party_store == "Origin":
|
if rgame.is_origin:
|
||||||
resp = get_origin_params(core, args.app_name, args.offline, resp)
|
resp = get_origin_params(rgame, init_args, resp)
|
||||||
else:
|
else:
|
||||||
resp = get_game_params(core, igame, args, resp)
|
resp = get_game_params(rgame, init_args, resp)
|
||||||
|
|
||||||
pre_cmd, wait = core.get_pre_launch_command(args.app_name)
|
pre_cmd, wait = rgame.core.get_pre_launch_command(init_args.app_name)
|
||||||
resp.pre_launch_command, resp.pre_launch_wait = pre_cmd, wait
|
resp.pre_launch_command, resp.pre_launch_wait = pre_cmd, wait
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,24 @@ class RareGameBase(QObject):
|
||||||
def is_overlay(self):
|
def is_overlay(self):
|
||||||
return self.app_name == eos.EOSOverlayApp.app_name
|
return self.app_name == eos.EOSOverlayApp.app_name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_dlc(self) -> bool:
|
||||||
|
"""!
|
||||||
|
@brief Property to report if Game is a dlc
|
||||||
|
|
||||||
|
@return bool
|
||||||
|
"""
|
||||||
|
return self.game.is_dlc
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_launchable_addon(self) -> bool:
|
||||||
|
# lk: the attribute doesn't exist in the currently released version
|
||||||
|
# FIXME: remove after legendary >= 0.20.35
|
||||||
|
try:
|
||||||
|
return self.game.is_launchable_addon
|
||||||
|
except AttributeError:
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def version(self) -> str:
|
def version(self) -> str:
|
||||||
"""!
|
"""!
|
||||||
|
@ -190,7 +208,9 @@ class RareGameSlim(RareGameBase):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_installed(self) -> bool:
|
def is_installed(self) -> bool:
|
||||||
return True
|
if self.is_origin:
|
||||||
|
return True
|
||||||
|
return self.igame is not None
|
||||||
|
|
||||||
def set_installed(self, installed: bool) -> None:
|
def set_installed(self, installed: bool) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -376,15 +376,6 @@ class RareGame(RareGameSlim):
|
||||||
if not needs and os.path.exists(self.repair_file):
|
if not needs and os.path.exists(self.repair_file):
|
||||||
os.unlink(self.repair_file)
|
os.unlink(self.repair_file)
|
||||||
|
|
||||||
@property
|
|
||||||
def is_dlc(self) -> bool:
|
|
||||||
"""!
|
|
||||||
@brief Property to report if Game is a dlc
|
|
||||||
|
|
||||||
@return bool
|
|
||||||
"""
|
|
||||||
return self.game.is_dlc
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_unreal(self) -> bool:
|
def is_unreal(self) -> bool:
|
||||||
"""!
|
"""!
|
||||||
|
|
|
@ -374,7 +374,7 @@ class RareCore(QObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def games(self) -> Iterator[RareGame]:
|
def games(self) -> Iterator[RareGame]:
|
||||||
return self.__filter_games(lambda game: not game.is_dlc)
|
return self.__filter_games(lambda game: not game.is_dlc or game.is_launchable_addon)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def installed_games(self) -> Iterator[RareGame]:
|
def installed_games(self) -> Iterator[RareGame]:
|
||||||
|
|
|
@ -2,8 +2,10 @@ requests
|
||||||
PyQt5
|
PyQt5
|
||||||
QtAwesome
|
QtAwesome
|
||||||
setuptools
|
setuptools
|
||||||
legendary-gl>=0.20.33
|
legendary-gl>=0.20.34; platform_system != "Windows" or platform_system != "Darwin"
|
||||||
|
legendary-gl @ git+https://github.com/derrod/legendary@96e07ff ; platform_system == "Windows" or platform_system == "Darwin"
|
||||||
orjson
|
orjson
|
||||||
|
vdf; platform_system != "Windows"
|
||||||
pywin32; platform_system == "Windows"
|
pywin32; platform_system == "Windows"
|
||||||
pywebview[qt]; platform_system == "Linux"
|
pywebview[qt]; platform_system == "Linux"
|
||||||
pywebview[qt]; platform_system == "FreeBSD"
|
pywebview[qt]; platform_system == "FreeBSD"
|
||||||
|
|
|
@ -2,7 +2,8 @@ requests
|
||||||
PyQt5
|
PyQt5
|
||||||
QtAwesome
|
QtAwesome
|
||||||
setuptools
|
setuptools
|
||||||
legendary-gl>=0.20.34
|
legendary-gl>=0.20.34; platform_system != "Windows" or platform_system != "Darwin"
|
||||||
|
legendary-gl @ git+https://github.com/derrod/legendary@96e07ff ; platform_system == "Windows" or platform_system == "Darwin"
|
||||||
orjson
|
orjson
|
||||||
vdf; platform_system != "Windows"
|
vdf; platform_system != "Windows"
|
||||||
pywin32; platform_system == "Windows"
|
pywin32; platform_system == "Windows"
|
||||||
|
|
Loading…
Reference in a new issue