mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
Stores: GOG and Epic cloud saves
Ported from Bannerlator's cloud-save managers. Before every launch the cloud copy comes down where it is newer: droiddeck-store-launch asks the app and waits up to 15 s. For a store game with cloud saves it tells the compat tool so, and the tool waits for Proton instead of exec'ing it, then asks for the upload without waiting. Newest wins per file, with an MD5 check so a file the game only touched is not sent again; a download first copies the folder to the app's storage (last three kept). The save folder is GOG's remote-config location template (by the game's Galaxy client id) or Epic's CloudSaveFolder catalog attribute, expanded inside the game's Proton prefix or install folder by CloudSavePaths, which refuses a path that leaves its boundary. GOG uploads with a token issued to the game's own client (its secret is kept at install from now on), Epic with signed write links. The GOG and Epic cards get a Cloud saves switch kept in the sidecar; Manage saves shows the last sync with Upload and Download, or No cloud saves.
This commit is contained in:
1 parent
935b70c585
commit
1580e3ee64
17 files changed
+853
-41
No files matched your search
@@ -219,37 +219,71 @@ def provision_prefix(compat_data, wait=SERVER_WAIT):
|
||||
return state + (" server-running" if busy else "")
|
||||
|
||||
|
||||
CLOUD_TIMEOUT = 15.0
|
||||
CLOUD_STORES = ("gog", "epic")
|
||||
# Exit status that tells droiddeck-proton this was a store game with cloud saves: it then waits for
|
||||
# Proton instead of exec'ing it, and runs `droiddeck-store-launch --exited` after.
|
||||
STORE_GAME = 10
|
||||
|
||||
|
||||
def cloud_on(sidecar):
|
||||
"""Cloud saves for this game (the game card's switch; on unless turned off)."""
|
||||
return str(sidecar.get("store")) in CLOUD_STORES and sidecar.get("cloud", True) is not False
|
||||
|
||||
|
||||
def exited(argv):
|
||||
"""After the game: ask the app to upload what changed, without waiting for it."""
|
||||
found = find_store_game(argv)
|
||||
launch_dir = os.environ.get("BL_LAUNCH_DIR", "")
|
||||
if found is None or not launch_dir or not cloud_on(found[1]):
|
||||
return 0
|
||||
store, game = str(found[1].get("store")), str(found[1].get("id"))
|
||||
ask(Path(launch_dir) / "stores", {"op": "cloud-up", "store": store, "id": game}, timeout=1.0)
|
||||
log("cloud %s %s up requested" % (store, game))
|
||||
return 0
|
||||
|
||||
|
||||
def main(argv):
|
||||
if argv and argv[0] == "--exited":
|
||||
return exited(argv[1:])
|
||||
found = find_store_game(argv)
|
||||
if found is None:
|
||||
return 0
|
||||
folder, sidecar = found
|
||||
store, game = str(sidecar.get("store")), str(sidecar.get("id"))
|
||||
if store != "epic":
|
||||
return 0
|
||||
drop_stale(folder)
|
||||
choice = options(sidecar)
|
||||
compat_data = os.environ.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/")
|
||||
prefix_id = os.path.basename(compat_data) if compat_data else ""
|
||||
launch_dir = os.environ.get("BL_LAUNCH_DIR", "")
|
||||
if not (choice["eos"] and not choice["offline"]):
|
||||
# Sign-in off, or offline: no code, and none left over from before.
|
||||
try:
|
||||
(folder / EPIC_CODE).unlink()
|
||||
except OSError:
|
||||
pass
|
||||
log("epic launch id=%s code=no reason=%s" % (game, "offline" if choice["offline"] else "eos-off"))
|
||||
elif not launch_dir:
|
||||
log("epic launch id=%s code=no reason=no-channel" % game)
|
||||
else:
|
||||
answer = ask(Path(launch_dir) / "stores", {"op": "epic-code", "store": store, "id": game, "prefix": prefix_id})
|
||||
if answer is None:
|
||||
log("epic launch id=%s code=no reason=timeout" % game)
|
||||
if store == "epic":
|
||||
drop_stale(folder)
|
||||
choice = options(sidecar)
|
||||
if not (choice["eos"] and not choice["offline"]):
|
||||
# Sign-in off, or offline: no code, and none left over from before.
|
||||
try:
|
||||
(folder / EPIC_CODE).unlink()
|
||||
except OSError:
|
||||
pass
|
||||
log("epic launch id=%s code=no reason=%s" % (game, "offline" if choice["offline"] else "eos-off"))
|
||||
elif not launch_dir:
|
||||
log("epic launch id=%s code=no reason=no-channel" % game)
|
||||
else:
|
||||
got = bool(answer.get("code"))
|
||||
log("epic launch id=%s code=%s reason=%s" % (game, "yes" if got else "no", answer.get("reason", "")))
|
||||
log("epic prefix=%s %s" % (prefix_id or "?", provision_prefix(compat_data)))
|
||||
return 0
|
||||
answer = ask(Path(launch_dir) / "stores", {"op": "epic-code", "store": store, "id": game, "prefix": prefix_id})
|
||||
if answer is None:
|
||||
log("epic launch id=%s code=no reason=timeout" % game)
|
||||
else:
|
||||
got = bool(answer.get("code"))
|
||||
log("epic launch id=%s code=%s reason=%s" % (game, "yes" if got else "no", answer.get("reason", "")))
|
||||
log("epic prefix=%s %s" % (prefix_id or "?", provision_prefix(compat_data)))
|
||||
if not cloud_on(sidecar):
|
||||
return 0
|
||||
if launch_dir:
|
||||
# The cloud copy where it is newer, before the game reads its saves; bounded, then on regardless.
|
||||
answer = ask(Path(launch_dir) / "stores", {"op": "cloud-down", "store": store, "id": game}, timeout=CLOUD_TIMEOUT)
|
||||
if answer is None:
|
||||
log("cloud %s %s down result=timeout" % (store, game))
|
||||
else:
|
||||
log("cloud %s %s down files=%s result=%s" % (store, game, answer.get("files", 0), answer.get("reason", "")))
|
||||
return STORE_GAME
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -117,7 +117,22 @@ bl_store_launch() {
|
||||
WINEDEBUG="${WINEDEBUG:+$WINEDEBUG,}+shell,+winebrowser"; export WINEDEBUG
|
||||
fi
|
||||
[ -x /usr/local/bin/droiddeck-store-launch ] || return 0
|
||||
/usr/local/bin/droiddeck-store-launch "$@" || true
|
||||
/usr/local/bin/droiddeck-store-launch "$@"
|
||||
# 10: a store game with cloud saves - the launch waits for Proton and uploads after (bl_run).
|
||||
[ $? -eq 10 ] && BL_STORE_EXIT=1
|
||||
return 0
|
||||
}
|
||||
|
||||
# Runs Proton: exec'd as always, except for a store game with cloud saves, where the wrapper stays
|
||||
# to tell the app the game has exited so it can upload what changed.
|
||||
bl_run() {
|
||||
if [ -n "${BL_STORE_EXIT:-}" ]; then
|
||||
"$@"
|
||||
rc=$?
|
||||
/usr/local/bin/droiddeck-store-launch --exited "${BL_STORE_ARGS[@]}" || true
|
||||
exit $rc
|
||||
fi
|
||||
exec "$@"
|
||||
}
|
||||
"""
|
||||
|
||||
@@ -358,7 +373,8 @@ if [ -n "$depot" ]; then
|
||||
bl_idtech3 "$@"
|
||||
bl_libpath
|
||||
bl_store_launch "$@"
|
||||
exec ${BL_TASKSET:-} /usr/local/bin/droiddeck-game-env "$depot/proton" "$verb" "$@" "${BL_EXTRA_ARGS[@]}"
|
||||
BL_STORE_ARGS=("$@")
|
||||
bl_run ${BL_TASKSET:-} /usr/local/bin/droiddeck-game-env "$depot/proton" "$verb" "$@" "${BL_EXTRA_ARGS[@]}"
|
||||
fi
|
||||
echo "droiddeck-proton: no ARM64 Proton depot yet - the client downloads one as this tool's dependency; retry the launch once it has" >&2
|
||||
exit 1
|
||||
@@ -417,9 +433,10 @@ bl_game_cpus
|
||||
bl_idtech3 "$@"
|
||||
bl_libpath
|
||||
bl_store_launch "$@"
|
||||
BL_STORE_ARGS=("$@")
|
||||
# Proton takes its base directory from dirname(sys.argv[0]) without resolving it, so it has to be
|
||||
# started from its own tree.
|
||||
exec ${BL_TASKSET:-} /usr/local/bin/droiddeck-game-env "$here/%s" "$verb" "$@" "${BL_EXTRA_ARGS[@]}"
|
||||
bl_run ${BL_TASKSET:-} /usr/local/bin/droiddeck-game-env "$here/%s" "$verb" "$@" "${BL_EXTRA_ARGS[@]}"
|
||||
"""
|
||||
EXTRA_COMPAT_TOOL_VDF = """"compatibilitytools"
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user