Skip to content

Commit

Permalink
[cli/core] Support launchable DLC/Addons
Browse files Browse the repository at this point in the history
  • Loading branch information
derrod committed Dec 14, 2023
1 parent 691048d commit ac62906
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 10 additions & 1 deletion legendary/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ def sync_saves(self, args):

def launch_game(self, args, extra):
app_name = self._resolve_aliases(args.app_name)
addon_app_name = None

# Interactive CrossOver setup
if args.crossover and sys_platform == 'darwin':
Expand All @@ -578,6 +579,13 @@ def launch_game(self, args, extra):
return self._launch_origin(args)

igame = self.core.get_installed_game(app_name)
if not igame and (game := self.core.get_game(app_name)) is not None:
# override installed game with base title
if game.is_launchable_addon:
addon_app_name = app_name
app_name = game.metadata['mainGameItem']['releaseInfo'][0]['appId']
igame = self.core.get_installed_game(app_name)

if not igame:
logger.error(f'Game {app_name} is not currently installed!')
exit(1)
Expand Down Expand Up @@ -622,7 +630,8 @@ def launch_game(self, args, extra):
disable_wine=args.no_wine,
executable_override=args.executable_override,
crossover_app=args.crossover_app,
crossover_bottle=args.crossover_bottle)
crossover_bottle=args.crossover_bottle,
addon_app_name=addon_app_name)

if args.set_defaults:
self.core.lgd.config[app_name] = dict()
Expand Down
5 changes: 3 additions & 2 deletions legendary/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,10 @@ def get_launch_parameters(self, app_name: str, offline: bool = False,
disable_wine: bool = False,
executable_override: str = None,
crossover_app: str = None,
crossover_bottle: str = None) -> LaunchParameters:
crossover_bottle: str = None,
addon_app_name: str = None) -> LaunchParameters:
install = self.lgd.get_installed_game(app_name)
game = self.lgd.get_game_meta(app_name)
game = self.lgd.get_game_meta(addon_app_name if addon_app_name else app_name)

# Disable wine for non-Windows executables (e.g. native macOS)
if not install.platform.startswith('Win'):
Expand Down

0 comments on commit ac62906

Please sign in to comment.