mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 04:46:08 +00:00
Games: revamped add games feature (#492)
Adding and managing your own (non-Steam) games moves out of the Steam settings into the Games tab, and works like Steam's own non-Steam Properties. - A + beside "Games N" opens a compact in-app picker: the storage first, then that storage's root, every folder, .exe files only. Picking an exe adds the game with its name, art, Custom badge and Steam shortcut. - "Add all games in this folder" adds every game folder inside at once. A summary opens immediately and fills in as each game is found, with a "?" where the exe was a close call and a red X to remove a game. - An edit button on each Custom game opens its editor: Name, Target (ranked exes, Other exe…), Start in, Launch options, the four pieces of art with thumbnails, and Remove. Edits go through the same Steam shortcut, so the appid never changes and nothing duplicates. - Art chooser per piece: images in the game folder, Steam's official art, SteamGridDB alternatives, your own image, or back to automatic. - Finding the exe: up to five folders deep, every exe scored (name match, Unreal -Shipping builds, bin folders and size up; launchers, crash reporters, installers, redistributables and depth down). - Real titles from the game's files (Steam manifest, GOG info, the exe's version info), keeping the folder's spacing when both spell the same title, underscores read as spaces. - Art: the exact Steam appid when the game names one, strict name matches otherwise, Steam's hashed asset paths for newer games, SteamGridDB as a fallback (built-in key from the SGDB_API_KEY secret, optional own key in Setup, sealed with the Keystore), and a cover made from the exe's icon when nothing else has one. - Removing a game is instant and keeps its files; adding it again brings it back. Steam's shortcut list is rewritten once, in the background. - The Games section is gone from Steam settings; folders added before keep listing their games. Artwork switch and SteamGridDB key are in Setup.
This commit is contained in:
1 parent
d99ed8e00b
commit
d250b43eb9
45 files changed
+4175
-295
No files matched your search
@@ -97,7 +97,7 @@ def write(obj):
|
||||
return bytes(out)
|
||||
|
||||
|
||||
def shortcut(game, launch_options=""):
|
||||
def shortcut(game, launch_options=None):
|
||||
appid = int(game["appid"]) & 0xFFFFFFFF
|
||||
return {
|
||||
"appid": struct.unpack("<i", struct.pack("<I", appid))[0],
|
||||
@@ -106,7 +106,7 @@ def shortcut(game, launch_options=""):
|
||||
"StartDir": '"%s"' % game["dir"],
|
||||
"icon": (game.get("art") or {}).get("icon", "") or "",
|
||||
"ShortcutPath": "",
|
||||
"LaunchOptions": launch_options,
|
||||
"LaunchOptions": launch_options if launch_options is not None else (game.get("launch") or ""),
|
||||
"IsHidden": 0,
|
||||
"AllowDesktopConfig": 1,
|
||||
"AllowOverlay": 1,
|
||||
@@ -122,7 +122,10 @@ def shortcut(game, launch_options=""):
|
||||
|
||||
RECORD = ".droiddeck-shortcuts.json"
|
||||
AWAY_LIMIT = 256
|
||||
FIELDS = ("AppName", "Exe", "StartDir", "icon")
|
||||
FIELDS = ("AppName", "Exe", "StartDir", "icon", "LaunchOptions")
|
||||
# What the app may change after the shortcut exists. Each follows the app only while Steam still
|
||||
# has what the app last asked for; a value the user set in Steam's Properties stays.
|
||||
FOLLOWED = ("StartDir", "LaunchOptions")
|
||||
|
||||
|
||||
def unquoted(value):
|
||||
@@ -161,6 +164,14 @@ def merge(fresh, current, state, seen):
|
||||
for field in ("AppName", "icon"):
|
||||
if current.get(field) == base.get(field):
|
||||
entry[field] = fresh[field]
|
||||
# Start in and launch options the app sets: only once there is a record of what it asked for
|
||||
# before (a first run keeps whatever the shortcut already had), and an older record that did
|
||||
# not keep launch options means the app asked for none.
|
||||
if isinstance(state.get("app"), dict):
|
||||
for field in FOLLOWED:
|
||||
was = base.get(field, "" if field == "LaunchOptions" else current.get(field))
|
||||
if fresh[field] != was and current.get(field) == was:
|
||||
entry[field] = fresh[field]
|
||||
tags = dict(current["tags"]) if isinstance(current.get("tags"), dict) else {}
|
||||
if TAG not in tags.values():
|
||||
slot = 0
|
||||
@@ -215,7 +226,7 @@ def reconcile(existing, wanted, seen, record):
|
||||
entry = ours[index]
|
||||
state[str(appid & 0xFFFFFFFF)] = {
|
||||
"app": {field: wanted[appid][field] for field in FIELDS},
|
||||
"steam": {"Exe": entry.get("Exe", ""), "StartDir": entry.get("StartDir", "")},
|
||||
"steam": {field: entry.get(field, "") for field in ("AppName", "Exe", "StartDir", "LaunchOptions")},
|
||||
"rev": rev,
|
||||
}
|
||||
return kept, ours, {"games": state, "away": away}
|
||||
|
||||
@@ -165,5 +165,41 @@ class ShortcutsTest(unittest.TestCase):
|
||||
self.assertIn(str(0x80000000 + shortcuts.AWAY_LIMIT + 3), away)
|
||||
|
||||
|
||||
def test_name_start_in_and_launch_options_set_in_the_app_reach_the_shortcut(self):
|
||||
self.run_writer(self.game())
|
||||
game = dict(self.game(name='Example: Renamed'), dir=GUEST + '/data', launch='-dx11')
|
||||
entry = self.run_writer(game)[APPID]
|
||||
self.assertEqual('Example: Renamed', entry['AppName'])
|
||||
self.assertEqual('"%s/data"' % GUEST, entry['StartDir'])
|
||||
self.assertEqual('-dx11', entry['LaunchOptions'])
|
||||
# One shortcut, the same appid.
|
||||
self.assertEqual([APPID], list(self.run_writer(game)))
|
||||
|
||||
def test_a_target_chosen_in_the_app_updates_the_same_shortcut(self):
|
||||
self.run_writer(self.game())
|
||||
entries = self.run_writer(self.game('bin/Example64.exe'))
|
||||
self.assertEqual([APPID], list(entries))
|
||||
self.assertEqual('"%s/bin/Example64.exe"' % GUEST, entries[APPID]['Exe'])
|
||||
self.assertEqual('"%s/bin"' % GUEST, entries[APPID]['StartDir'])
|
||||
|
||||
def test_launch_options_set_in_steam_stay_over_the_apps_old_value(self):
|
||||
self.run_writer(dict(self.game(), launch='-dx11'))
|
||||
self.steam_edits(LaunchOptions='-vulkan', AppName='Mine')
|
||||
entry = self.run_writer(dict(self.game(), launch='-dx11'))[APPID]
|
||||
self.assertEqual('-vulkan', entry['LaunchOptions'])
|
||||
self.assertEqual('Mine', entry['AppName'])
|
||||
steam = self.record()['games'][str(APPID)]['steam']
|
||||
self.assertEqual('-vulkan', steam['LaunchOptions'])
|
||||
self.assertEqual('Mine', steam['AppName'])
|
||||
|
||||
def test_an_older_record_without_launch_options_still_takes_the_apps(self):
|
||||
self.run_writer(self.game())
|
||||
record = self.record()
|
||||
del record['games'][str(APPID)]['app']['LaunchOptions']
|
||||
(self.config / shortcuts.RECORD).write_text(json.dumps(record))
|
||||
entry = self.run_writer(dict(self.game(), launch='-safe'))[APPID]
|
||||
self.assertEqual('-safe', entry['LaunchOptions'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user