mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2025-04-23 15:52:21 +02:00
Update NSLGameScanner.py
This commit is contained in:
parent
9ee7a12dc3
commit
10e9412112
@ -689,10 +689,11 @@ def modify_shortcut_for_umu(appname, exe, launchoptions, startingdir):
|
||||
updated_launch = launchoptions
|
||||
|
||||
# Hoyoplay - Extract the game identifier
|
||||
match = re.search(r'--game=(\w+)', launchoptions)
|
||||
if match:
|
||||
codename = match.group(1) # Capture the identifier
|
||||
updated_launch = f"'--game={codename}'"
|
||||
#match = re.search(r'--game=(\w+)', launchoptions)
|
||||
#
|
||||
#if match:
|
||||
#codename = match.group(1) # Capture the identifier
|
||||
#updated_launch = f"'--game={codename}'"
|
||||
|
||||
if "origin2://game/launch?offerIds=" in launchoptions:
|
||||
updated_launch = f'"origin2://game/launch?offerIds={codename}"'
|
||||
@ -1835,56 +1836,65 @@ else:
|
||||
# Parse each JSON object
|
||||
for json_object in json_objects:
|
||||
json_object = json_object.strip()
|
||||
|
||||
# Skip empty JSON objects
|
||||
if json_object == "{}":
|
||||
continue
|
||||
|
||||
if json_object:
|
||||
try:
|
||||
# Attempt to load the JSON object
|
||||
data = json.loads(json_object)
|
||||
|
||||
# Extract gameBiz from the root and from the 'gameInstallStatus' object
|
||||
game_biz = data.get("gameBiz", "").strip()
|
||||
|
||||
# If gameBiz is empty, check inside the 'gameInstallStatus' object
|
||||
if not game_biz:
|
||||
game_biz = data.get("gameInstallStatus", {}).get("gameBiz", "").strip()
|
||||
|
||||
# Skip JSON objects where gameBiz is empty or already processed
|
||||
if not game_biz or game_biz in seen_game_biz:
|
||||
continue
|
||||
continue # Skip this object and move to the next one
|
||||
|
||||
# Add this gameBiz to the seen set
|
||||
seen_game_biz.add(game_biz)
|
||||
|
||||
# Extract other relevant fields
|
||||
persistent_install_path = data.get("persistentInstallPath", None)
|
||||
install_path = data.get("installPath", None) # This is the fallback option
|
||||
game_install_status = data.get("gameInstallStatus", {})
|
||||
game_exe_name = game_install_status.get("gameExeName", None)
|
||||
install_path = game_install_status.get("gameInstallPath", None)
|
||||
game_shortcut_name = data.get("gameShortcutName", None)
|
||||
|
||||
game_exe_name = game_install_status.get("gameExeName", None)
|
||||
game_shortcut_name = data.get("gameShortcutName", None) # Get the game shortcut name
|
||||
|
||||
# Debugging prints to check the values of persistentInstallPath and installPath
|
||||
print(f"GameBiz: {game_biz}")
|
||||
print(f"Persistent Install Path: {persistent_install_path}")
|
||||
print(f"Install Path: {install_path}")
|
||||
|
||||
# If persistentInstallPath is empty, use installPath as fallback
|
||||
if not persistent_install_path:
|
||||
print(f"Persistent Install Path is empty for gameBiz: {game_biz}, using Install Path as fallback.")
|
||||
print(f"Persistent Install Path is empty, using Install Path as fallback.")
|
||||
persistent_install_path = install_path
|
||||
|
||||
if not game_exe_name or not persistent_install_path:
|
||||
print(f"Skipping gameBiz: {game_biz} - Missing exe name or install path.")
|
||||
continue
|
||||
# Check if all important fields are missing or empty
|
||||
if not game_exe_name and not persistent_install_path:
|
||||
print(f"Skipping empty game entry for gameBiz: {game_biz}")
|
||||
continue # Skip if all important fields are empty
|
||||
|
||||
# Convert Windows-style path to Steam Proton path
|
||||
proton_path_base = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{hoyoplay_launcher}/pfx/drive_c"
|
||||
relative_game_path = persistent_install_path.replace("C:\\", "").replace("\\", "/")
|
||||
full_game_dir = os.path.join(proton_path_base, relative_game_path)
|
||||
full_game_exe = os.path.join(full_game_dir, game_exe_name)
|
||||
if not persistent_install_path:
|
||||
print(f"Skipping gameBiz: {game_biz} - No persistent install path found.")
|
||||
continue # Skip if no persistent install path
|
||||
|
||||
# Log information for debugging
|
||||
print(f" Game Business: {game_biz}")
|
||||
print(f" Game Shortcut Name: {game_shortcut_name}")
|
||||
print(f" Game Executable: {game_exe_name}")
|
||||
print(f" Persistent Install Path: {persistent_install_path}")
|
||||
if game_shortcut_name:
|
||||
print(f" Game Shortcut Name: {game_shortcut_name}")
|
||||
|
||||
# Set the display name to the game shortcut name from the JSON
|
||||
display_name = game_shortcut_name if game_shortcut_name else game_biz
|
||||
launch_options = f"STEAM_COMPAT_DATA_PATH=\"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{hoyoplay_launcher}/\" %command% \"--game={game_biz}\""
|
||||
exe_path = f"\"{full_game_exe}\""
|
||||
start_dir = f"\"{full_game_dir}\""
|
||||
|
||||
if any(v is None for v in [exe_path, display_name, launch_options, start_dir]):
|
||||
print(f"Missing fields for gameBiz: {game_biz}, skipping entry creation.")
|
||||
continue
|
||||
exe_path = f"\"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{hoyoplay_launcher}/pfx/drive_c/Program Files/HoYoPlay/launcher.exe\""
|
||||
start_dir = f"\"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{hoyoplay_launcher}/pfx/drive_c/Program Files/HoYoPlay\""
|
||||
|
||||
# Create the new entry (this is where you can use your custom function for Steam shortcuts)
|
||||
create_new_entry(exe_path, display_name, launch_options, start_dir)
|
||||
|
Loading…
x
Reference in New Issue
Block a user