mirror of
https://github.com/derrod/legendary.git
synced 2025-02-27 23:56:45 +00:00
[cli/core] Add option to override launch executable
This commit is contained in:
parent
ee3b3fb9fe
commit
a2280edea8
|
@ -474,7 +474,8 @@ class LegendaryCLI:
|
|||
extra_args=extra, user=args.user_name_override,
|
||||
wine_bin=args.wine_bin, wine_pfx=args.wine_pfx,
|
||||
language=args.language, wrapper=args.wrapper,
|
||||
disable_wine=args.no_wine)
|
||||
disable_wine=args.no_wine,
|
||||
executable_override=args.executable_override)
|
||||
|
||||
if args.set_defaults:
|
||||
self.core.lgd.config[app_name] = dict()
|
||||
|
@ -1202,6 +1203,8 @@ def main():
|
|||
help='Save parameters used to launch to config (does not include env vars)')
|
||||
launch_parser.add_argument('--reset-defaults', dest='reset_defaults', action='store_true',
|
||||
help='Reset config settings for app and exit')
|
||||
launch_parser.add_argument('--override-exe', dest='executable_override', action='store', metavar='<exe path>',
|
||||
help='Override executable to launch (relative path)')
|
||||
|
||||
if os.name != 'nt':
|
||||
launch_parser.add_argument('--wine', dest='wine_bin', action='store', metavar='<wine binary>',
|
||||
|
|
|
@ -296,7 +296,8 @@ class LegendaryCore:
|
|||
user: str = None, extra_args: list = None,
|
||||
wine_bin: str = None, wine_pfx: str = None,
|
||||
language: str = None, wrapper: str = None,
|
||||
disable_wine: bool = False) -> (list, str, dict):
|
||||
disable_wine: bool = False,
|
||||
executable_override: str = None) -> (list, str, dict):
|
||||
install = self.lgd.get_installed_game(app_name)
|
||||
game = self.lgd.get_game_meta(app_name)
|
||||
|
||||
|
@ -312,8 +313,15 @@ class LegendaryCore:
|
|||
if user:
|
||||
user_name = user
|
||||
|
||||
game_exe = os.path.join(install.install_path,
|
||||
install.executable.replace('\\', '/').lstrip('/'))
|
||||
if executable_override or (executable_override := self.lgd.config.get(app_name, 'override_exe', fallback=None)):
|
||||
game_exe = os.path.join(install.install_path,
|
||||
executable_override.replace('\\', '/'))
|
||||
if not os.path.exists(game_exe):
|
||||
raise ValueError(f'Executable path is invalid: {game_exe}')
|
||||
else:
|
||||
game_exe = os.path.join(install.install_path,
|
||||
install.executable.replace('\\', '/').lstrip('/'))
|
||||
|
||||
working_dir = os.path.split(game_exe)[0]
|
||||
|
||||
params = []
|
||||
|
|
Loading…
Reference in a new issue