mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2026-06-13 04:04:59 +03:00
Refactor UMU shortcut modification logic
Added a normalization function to standardize codename comparisons and updated the shortcut modification logic to handle UMU entries more robustly.
This commit is contained in:
+32
-13
@@ -3878,12 +3878,17 @@ def extract_base_path(launchoptions):
|
||||
return match.group(1)
|
||||
raise ValueError("STEAM_COMPAT_DATA_PATH not found in launch options")
|
||||
|
||||
def norm(s):
|
||||
return s.strip().lower()
|
||||
|
||||
|
||||
def modify_shortcut_for_umu(appname, exe, launchoptions, startingdir):
|
||||
# Skip UMU modification for specific titles
|
||||
skip_titles = ["genshin impact", "zenless zone zero"]
|
||||
if appname.lower() in skip_titles:
|
||||
print(f"Skipping UMU modification for {appname}.")
|
||||
return exe, startingdir, launchoptions
|
||||
|
||||
# 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.")
|
||||
@@ -3898,6 +3903,7 @@ def modify_shortcut_for_umu(appname, exe, launchoptions, startingdir):
|
||||
print(f"No entries found in UMU database. Skipping modification for {appname}.")
|
||||
return exe, startingdir, launchoptions
|
||||
|
||||
# Fallback: match by appname if codename not found
|
||||
if not codename:
|
||||
for entry in entries:
|
||||
if entry.get('TITLE') and entry['TITLE'].lower() == appname.lower():
|
||||
@@ -3905,16 +3911,27 @@ def modify_shortcut_for_umu(appname, exe, launchoptions, startingdir):
|
||||
break
|
||||
|
||||
if codename:
|
||||
selected_entry = None
|
||||
|
||||
for entry in entries:
|
||||
if entry['CODENAME'] == codename:
|
||||
umu_id = entry['UMU_ID'].replace("umu-", "") # Remove the "umu-" prefix
|
||||
if norm(entry['CODENAME']) == norm(codename):
|
||||
selected_entry = entry
|
||||
break
|
||||
|
||||
if not selected_entry:
|
||||
print(f"No UMU entry match for codename: {codename}")
|
||||
return exe, startingdir, launchoptions
|
||||
|
||||
codename = selected_entry['CODENAME'] # preserve canonical casing
|
||||
umu_id = selected_entry['UMU_ID'].replace("umu-", "")
|
||||
|
||||
base_path = extract_base_path(launchoptions)
|
||||
new_exe = f'"{logged_in_home}/bin/umu-run" {exe}'
|
||||
new_start_dir = f'"{logged_in_home}/bin/"'
|
||||
|
||||
# Update only the launchoptions part for different game types
|
||||
updated_launch = launchoptions
|
||||
|
||||
|
||||
# Hoyoplay - Extract the game identifier
|
||||
#match = re.search(r'--game=(\w+)', launchoptions)
|
||||
#
|
||||
@@ -3924,22 +3941,28 @@ def modify_shortcut_for_umu(appname, exe, launchoptions, startingdir):
|
||||
|
||||
if "origin2://game/launch?offerIds=" in launchoptions:
|
||||
updated_launch = f'"origin2://game/launch?offerIds={codename}"'
|
||||
|
||||
elif "amazon-games://play/amzn1.adg.product." in launchoptions:
|
||||
updated_launch = f"-'amazon-games://play/{codename}'"
|
||||
|
||||
elif "com.epicgames.launcher://apps/" in launchoptions:
|
||||
updated_launch = f"-'com.epicgames.launcher://apps/{codename}?action=launch&silent=true'"
|
||||
|
||||
elif "uplay://launch/" in launchoptions:
|
||||
updated_launch = f'"uplay://launch/{codename}/0"'
|
||||
|
||||
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
|
||||
# Remove duplicate STEAM_COMPAT_DATA_PATH if present
|
||||
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)
|
||||
updated_launch = re.sub(
|
||||
r'STEAM_COMPAT_DATA_PATH="[^"]+" ',
|
||||
'',
|
||||
updated_launch
|
||||
)
|
||||
|
||||
|
||||
#Set compat tool name to UMU-Proton(Latest)
|
||||
# Set compat tool name to latest UMU-Proton
|
||||
dir_path = f"{logged_in_home}/.steam/root/compatibilitytools.d"
|
||||
pattern = re.compile(r"UMU-Proton-(\d+(?:\.\d+)*)(?:-(\d+(?:\.\d+)*))?")
|
||||
|
||||
@@ -3953,10 +3976,8 @@ def modify_shortcut_for_umu(appname, exe, launchoptions, startingdir):
|
||||
if (m := pattern.match(name)) and os.path.isdir(os.path.join(dir_path, name))
|
||||
]
|
||||
|
||||
if umu_folders:
|
||||
compat_tool_name = max(umu_folders)[1]
|
||||
compat_tool_name = max(umu_folders)[1] if umu_folders else "UMU-Proton-Latest"
|
||||
|
||||
# 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" '
|
||||
@@ -3964,11 +3985,9 @@ def modify_shortcut_for_umu(appname, exe, launchoptions, startingdir):
|
||||
f'PROTONPATH="{logged_in_home}/.steam/root/compatibilitytools.d/{compat_tool_name}" '
|
||||
)
|
||||
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user