Skip to content

Commit

Permalink
Update NSLGameScanner.py
Browse files Browse the repository at this point in the history
  • Loading branch information
moraroy committed Jul 16, 2024
1 parent a7299d1 commit ad72a3f
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions NSLGameScanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,11 @@ def check_if_shortcut_exists(shortcut_id, display_name, exe_path, start_dir, lau
# Create an empty dictionary to store the app IDs
app_ids = {}

# Get the highest existing key
if shortcuts['shortcuts']:
highest_key = max(int(key) for key in shortcuts['shortcuts'].keys())
else:
highest_key = -1

# Start the counter from the next available number
counter = highest_key + 1
def get_next_available_key(shortcuts):
key = 0
while str(key) in shortcuts['shortcuts']:
key += 1
return str(key)

def create_new_entry(shortcutdirectory, appname, launchoptions, startingdir):
global new_shortcuts_added
Expand Down Expand Up @@ -466,14 +463,12 @@ def create_new_entry(shortcutdirectory, appname, launchoptions, startingdir):
'Logo': logo64,
}
# Add the new entry to the shortcuts dictionary and add proton
# Use the counter for the key
shortcuts['shortcuts'][str(counter)] = new_entry # Use the counter as the key
decky_shortcuts[appname] = decky_entry
key = get_next_available_key(shortcuts)
shortcuts['shortcuts'][key] = new_entry
print(f"Added new entry for {appname} to shortcuts.")
new_shortcuts_added = True
created_shortcuts.append(appname)

counter += 1 # Increment the counter after adding the new entry
add_compat_tool(unsigned_shortcut_id, launchoptions)



Expand Down Expand Up @@ -1277,10 +1272,6 @@ def dbpath_to_game(paths):
except IOError as e:
print(f"Error writing to shortcuts.vdf: {e}")

# Reset the flags
new_shortcuts_added = False
shortcuts_updated = False

# Print the created shortcuts
if created_shortcuts:
print("Created Shortcuts:")
Expand Down

0 comments on commit ad72a3f

Please sign in to comment.