diff --git a/NSLGameScanner.py b/NSLGameScanner.py index cb01a8e..2c13fc7 100644 --- a/NSLGameScanner.py +++ b/NSLGameScanner.py @@ -76,6 +76,7 @@ legacy_launcher = os.environ.get('legacy_launcher', '') vkplay_launcher = os.environ.get('vkplay_launcher', '') hoyoplay_launcher = os.environ.get('hoyoplay_launcher', '') gamejolt_launcher = os.environ.get('gamejolt_launcher', '') +minecraft_launcher = os.environ.get('minecraft_launcher', '') #Variables of the Launchers # Define the path of the Launchers @@ -1827,6 +1828,67 @@ else: +#Minecraft Legacy Launcher Scanner + +# Path to the JSON file +file_path = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{minecraft_launcher}/pfx/drive_c/users/deck/AppData/Roaming/.minecraft/launcher_settings.json" + +# Function to convert Windows path to Unix path dynamically +def convert_to_unix_path(windows_path, home_dir): + unix_path = windows_path.replace('\\', '/') + + if len(windows_path) > 2 and windows_path[1] == ":": + unix_path = unix_path[2:] + unix_path = os.path.join(home_dir, unix_path.lstrip('/')) + + return unix_path + +# Check if the JSON file exists +if os.path.exists(file_path): + try: + with open(file_path, 'r') as file: + # Parse the JSON data + data = json.load(file) + + # Extract the productLibraryDir + product_library_dir = data.get('productLibraryDir') + + if product_library_dir: + home_dir = os.path.expanduser("~") + unix_product_library_dir = convert_to_unix_path(product_library_dir, home_dir) + + # Define the target file path + target_file = os.path.join(unix_product_library_dir, 'dungeons', 'dungeons', 'Dungeons.exe') + + # Check if the file exists + if os.path.exists(target_file): + print(f"File exists: {target_file}") + else: + print(f"File does not exist: {target_file}") + + # Set the display name to the game shortcut name from the JSON + display_name = "Minecraft Dungeons" + launch_options = f"STEAM_COMPAT_DATA_PATH=\"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{minecraft_launcher}/\" %command%" + exe_path = f"\"{target_file}\"" + start_dir = f"\"{os.path.dirname(target_file)}\"" + + + # 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) + + else: + print("Key 'productLibraryDir' not found in the JSON.") + except json.JSONDecodeError: + print("Error decoding the JSON file.") +else: + print("Skipping Minecraft Legacy Launcher Scanner") + +# End of the Minecraft Legacy Launcher + + + + + # Only write back to the shortcuts.vdf and config.vdf files if new shortcuts were added or compattools changed # Function to send a notification with an optional icon