MCPcopy
hub / github.com/legendary-gl/legendary / get_launch_parameters

Method get_launch_parameters

legendary/core.py:685–779  ·  view source on GitHub ↗
(self, app_name: str, offline: bool = False,
                              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,
                              executable_override: str = None,
                              crossover_app: str = None,
                              crossover_bottle: str = None)

Source from the content-addressed store, hash-verified

683 return pre_launch_command, pre_launch_wait
684
685 def get_launch_parameters(self, app_name: str, offline: bool = False,
686 user: str = None, extra_args: list = None,
687 wine_bin: str = None, wine_pfx: str = None,
688 language: str = None, wrapper: str = None,
689 disable_wine: bool = False,
690 executable_override: str = None,
691 crossover_app: str = None,
692 crossover_bottle: str = None) -> LaunchParameters:
693 install = self.lgd.get_installed_game(app_name)
694 game = self.lgd.get_game_meta(app_name)
695
696 # Disable wine for non-Windows executables (e.g. native macOS)
697 if not install.platform.startswith('Win'):
698 disable_wine = True
699 wine_pfx = wine_bin = None
700
701 disable_wine = disable_wine or self.lgd.config.getboolean(
702 app_name, 'no_wine', fallback=self.lgd.config.get('default', 'no_wine', fallback=False)
703 )
704
705 if executable_override or (executable_override := self.lgd.config.get(app_name, 'override_exe', fallback=None)):
706 game_exe = executable_override.replace('\\', '/')
707 exe_path = os.path.join(install.install_path, game_exe)
708 if not os.path.exists(exe_path):
709 raise ValueError(f'Executable path is invalid: {exe_path}')
710 else:
711 game_exe = install.executable.replace('\\', '/').lstrip('/')
712 exe_path = os.path.join(install.install_path, game_exe)
713
714 working_dir = os.path.split(exe_path)[0]
715
716 params = LaunchParameters(
717 game_executable=game_exe, game_directory=install.install_path, working_directory=working_dir,
718 launch_command=self.get_app_launch_command(app_name=app_name, wrapper=wrapper, wine_binary=wine_bin,
719 crossover_app=crossover_app, disable_wine=disable_wine),
720 environment=self.get_app_environment(app_name=app_name, wine_pfx=wine_pfx,
721 cx_bottle=crossover_bottle, disable_wine=disable_wine)
722 )
723
724 cmd, wait = self.get_pre_launch_command(app_name)
725 if cmd:
726 params.pre_launch_command = cmd
727 params.pre_launch_wait = wait
728
729 if install.launch_parameters:
730 try:
731 params.game_parameters.extend(shlex.split(install.launch_parameters, posix=False))
732 except ValueError as e:
733 self.log.warning(f'Parsing predefined launch parameters failed with: {e!r}, '
734 f'input: {install.launch_parameters}')
735
736 game_token = ''
737 if not offline:
738 self.log.info('Getting authentication token...')
739 game_token = self.egs.get_game_token()['code']
740 elif not install.can_run_offline:
741 self.log.warning('Game is not approved for offline use and may not work correctly.')
742

Callers 1

launch_gameMethod · 0.80

Calls 11

get_app_environmentMethod · 0.95
LaunchParametersClass · 0.85
get_game_metaMethod · 0.80
infoMethod · 0.80
get_game_tokenMethod · 0.80
get_ownership_tokenMethod · 0.80
get_tmp_pathMethod · 0.80
get_installed_gameMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected