@@ -2370,29 +2370,43 @@ def add_steam_shortcut(self, game, steam_shortcut_state, icon_temp, icon_final):
2370
2370
def add_game_to_steam (title , game_directory , icon , command ):
2371
2371
# Load existing shortcuts
2372
2372
shortcuts = load_shortcuts (title )
2373
- remove_shortcuts (shortcuts , title )
2374
-
2375
- # Generate a new ID for the game
2376
- new_app_id = max ([int (k ) for k in shortcuts ["shortcuts" ].keys ()] or [0 ]) + 1
2377
-
2378
- # Add the new game
2379
- shortcuts ["shortcuts" ][str (new_app_id )] = {
2380
- "appid" : new_app_id ,
2381
- "AppName" : title ,
2382
- "Exe" : f'"{ faugus_run } "' ,
2383
- "StartDir" : game_directory ,
2384
- "icon" : icon ,
2385
- "ShortcutPath" : "" ,
2386
- "LaunchOptions" : f'"{ command } "' ,
2387
- "IsHidden" : 0 ,
2388
- "AllowDesktopConfig" : 1 ,
2389
- "AllowOverlay" : 1 ,
2390
- "OpenVR" : 0 ,
2391
- "Devkit" : 0 ,
2392
- "DevkitGameID" : "" ,
2393
- "LastPlayTime" : 0 ,
2394
- "FlatpakAppID" : "" ,
2395
- }
2373
+
2374
+ # Check if the game already exists
2375
+ existing_app_id = None
2376
+ for app_id , game_info in shortcuts ["shortcuts" ].items ():
2377
+ if game_info ["AppName" ] == title :
2378
+ existing_app_id = app_id
2379
+ break
2380
+
2381
+ if existing_app_id :
2382
+ # Update only the necessary fields without replacing the entire entry
2383
+ game_info = shortcuts ["shortcuts" ][existing_app_id ]
2384
+ game_info ["Exe" ] = f'"{ faugus_run } "'
2385
+ game_info ["StartDir" ] = game_directory
2386
+ game_info ["icon" ] = icon
2387
+ game_info ["LaunchOptions" ] = f'"{ command } "'
2388
+ else :
2389
+ # Generate a new ID for the game
2390
+ new_app_id = max ([int (k ) for k in shortcuts ["shortcuts" ].keys ()] or [0 ]) + 1
2391
+
2392
+ # Add the new game
2393
+ shortcuts ["shortcuts" ][str (new_app_id )] = {
2394
+ "appid" : new_app_id ,
2395
+ "AppName" : title ,
2396
+ "Exe" : f'"{ faugus_run } "' ,
2397
+ "StartDir" : game_directory ,
2398
+ "icon" : icon ,
2399
+ "ShortcutPath" : "" ,
2400
+ "LaunchOptions" : f'"{ command } "' ,
2401
+ "IsHidden" : 0 ,
2402
+ "AllowDesktopConfig" : 1 ,
2403
+ "AllowOverlay" : 1 ,
2404
+ "OpenVR" : 0 ,
2405
+ "Devkit" : 0 ,
2406
+ "DevkitGameID" : "" ,
2407
+ "LastPlayTime" : 0 ,
2408
+ "FlatpakAppID" : "" ,
2409
+ }
2396
2410
2397
2411
# Save shortcuts back to the file
2398
2412
save_shortcuts (shortcuts )
0 commit comments