From a7de732b02445dd5eaa67371cd998f924152729b Mon Sep 17 00:00:00 2001 From: Roy <88516395+moraroy@users.noreply.github.com> Date: Sat, 11 Jan 2025 23:42:07 -0800 Subject: [PATCH] fixed umu shortcuts --- NSLGameScanner.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/NSLGameScanner.py b/NSLGameScanner.py index 9c04dd8..8051bc5 100644 --- a/NSLGameScanner.py +++ b/NSLGameScanner.py @@ -569,7 +569,7 @@ def extract_base_path(launchoptions): return match.group(1) raise ValueError("STEAM_COMPAT_DATA_PATH not found in launch options") -def modify_shortcut_for_umu(appname, exe, launchoptions, startingdir): +def modify_shortcut_for_umu(appname, exe, launchoptions, startingdir, logged_in_home, compat_tool_name): # Skip processing if STEAM_COMPAT_DATA_PATH is not present if 'STEAM_COMPAT_DATA_PATH=' not in launchoptions: print(f"Launch options for {appname} do not contain STEAM_COMPAT_DATA_PATH. Skipping modification.") @@ -618,14 +618,26 @@ def modify_shortcut_for_umu(appname, exe, launchoptions, startingdir): elif "/command=runGame /gameId=" in launchoptions: updated_launch = f'/command=runGame /gameId={codename} /path={launchoptions.split("/path=")[1]}' + # Ensure the first STEAM_COMPAT_DATA_PATH is included and avoid adding it again + if 'STEAM_COMPAT_DATA_PATH=' in updated_launch: + # Remove the existing STEAM_COMPAT_DATA_PATH if it exists in the launch options + updated_launch = re.sub(r'STEAM_COMPAT_DATA_PATH="[^"]+" ', '', updated_launch) + + # Always include the first STEAM_COMPAT_DATA_PATH at the start new_launch_options = ( f'STEAM_COMPAT_DATA_PATH="{base_path}" ' f'WINEPREFIX="{base_path}pfx" ' f'GAMEID="{umu_id}" ' f'PROTONPATH="{logged_in_home}/.steam/root/compatibilitytools.d/{compat_tool_name}" ' - f'%command% {updated_launch}' ) + # Check if %command% is already in the launch options + if '%command%' not in updated_launch: + updated_launch = f'%command% {updated_launch}' + + # Final new launch options + new_launch_options += updated_launch + umu_processed_shortcuts[umu_id] = True return new_exe, new_start_dir, new_launch_options