mirror of
				https://github.com/derrod/legendary.git
				synced 2025-11-04 10:24:49 +00:00 
			
		
		
		
	[cli/core] Add flags/env vars to override WINE binary/prefix
This commit is contained in:
		
							parent
							
								
									f9d56b8d0d
								
							
						
					
					
						commit
						2945c6c91f
					
				| 
						 | 
				
			
			@ -249,7 +249,8 @@ class LegendaryCLI:
 | 
			
		|||
                    exit(1)
 | 
			
		||||
 | 
			
		||||
        params, cwd, env = self.core.get_launch_parameters(app_name=app_name, offline=args.offline,
 | 
			
		||||
                                                           extra_args=extra, user=args.user_name_override)
 | 
			
		||||
                                                           extra_args=extra, user=args.user_name_override,
 | 
			
		||||
                                                           wine_bin=args.wine_bin, wine_pfx=args.wine_pfx)
 | 
			
		||||
 | 
			
		||||
        logger.info(f'Launching {app_name}...')
 | 
			
		||||
        if args.dry_run:
 | 
			
		||||
| 
						 | 
				
			
			@ -524,6 +525,13 @@ def main():
 | 
			
		|||
                               help='Override username used when launching the game (only works with some titles)')
 | 
			
		||||
    launch_parser.add_argument('--dry-run', dest='dry_run', action='store_true',
 | 
			
		||||
                               help='Print the command line that would have been used to launch the game and exit')
 | 
			
		||||
    if os.name != 'nt':
 | 
			
		||||
        launch_parser.add_argument('--wine', dest='wine_bin', action='store', metavar='<wine binary>',
 | 
			
		||||
                                   default=os.environ.get('LGDRY_WINE_BINARY', None),
 | 
			
		||||
                                   help='Override WINE binary being used to launch the game')
 | 
			
		||||
        launch_parser.add_argument('--wine-prefix', dest='wine_pfx', action='store', metavar='<wine pfx path>',
 | 
			
		||||
                                   default=os.environ.get('LGDRY_WINE_PREFIX', None),
 | 
			
		||||
                                   help='Override WINE prefix used.')
 | 
			
		||||
 | 
			
		||||
    list_parser.add_argument('--platform', dest='platform_override', action='store', metavar='<Platform>',
 | 
			
		||||
                             type=str, help='Override platform that games are shown for')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -201,7 +201,8 @@ class LegendaryCore:
 | 
			
		|||
        return self.lgd.get_installed_game(app_name)
 | 
			
		||||
 | 
			
		||||
    def get_launch_parameters(self, app_name: str, offline: bool = False,
 | 
			
		||||
                              user: str = None, extra_args: list = None) -> (list, str, dict):
 | 
			
		||||
                              user: str = None, extra_args: list = None,
 | 
			
		||||
                              wine_bin: str = None, wine_pfx: str = None) -> (list, str, dict):
 | 
			
		||||
        install = self.lgd.get_installed_game(app_name)
 | 
			
		||||
        game = self.lgd.get_game_meta(app_name)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -223,11 +224,12 @@ class LegendaryCore:
 | 
			
		|||
        params = []
 | 
			
		||||
 | 
			
		||||
        if os.name != 'nt':
 | 
			
		||||
            # check if there's a default override
 | 
			
		||||
            wine_binary = self.lgd.config.get('default', 'wine_executable', fallback='wine')
 | 
			
		||||
            # check if there's a game specific override
 | 
			
		||||
            wine_binary = self.lgd.config.get(app_name, 'wine_executable', fallback=wine_binary)
 | 
			
		||||
            params.append(wine_binary)
 | 
			
		||||
            if not wine_bin:
 | 
			
		||||
                # check if there's a default override
 | 
			
		||||
                wine_bin = self.lgd.config.get('default', 'wine_executable', fallback='wine')
 | 
			
		||||
                # check if there's a game specific override
 | 
			
		||||
                wine_bin = self.lgd.config.get(app_name, 'wine_executable', fallback=wine_bin)
 | 
			
		||||
            params.append(wine_bin)
 | 
			
		||||
 | 
			
		||||
        params.append(game_exe)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -271,6 +273,9 @@ class LegendaryCore:
 | 
			
		|||
        elif 'default.env' in self.lgd.config:
 | 
			
		||||
            env.update(dict(self.lgd.config['default.env']))
 | 
			
		||||
 | 
			
		||||
        if wine_pfx:
 | 
			
		||||
            env['WINEPREFIX'] = wine_pfx
 | 
			
		||||
 | 
			
		||||
        return params, working_dir, env
 | 
			
		||||
 | 
			
		||||
    def get_save_games(self, app_name: str = ''):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue