Play your Steam library's Windows games on a jailbroken PS5.
C++
Upload every game's saves to a new account at once
Leonardo Lobato34f5f475121d
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cppindex a010ed7..b1df788 100644--- a/src/homebrew/simulation.cpp+++ b/src/homebrew/simulation.cpp@@ -437,6 +437,7 @@ std::string action_label(const std::string& key) {{"log-launch", "Launch log"}, {"log-cloud", "Cloud saves log"}, {"logs-refresh", "Refresh"},{"cloud-sync", "Cloud saves"}, {"cloud-choose", "Cloud saves"}, {"cloud-use-cloud", "Use Cloud saves"},{"cloud-use-local", "Use console saves"}, {"cloud-confirm-account", "Use this account"},+ {"cloud-confirm-account-all", "Upload all"},{"saves-delete-confirm", "Delete saves"}, {"manage-saves", "Manage saves"}, {"saves-leftover-confirm", "Remove"}, {"saves-quit-anyway", "Play without syncing"},{"install-confirm", "Install"}, {"storage-picker", "Change storage"},{"value-edit", "Edit…"}, {"value-reset", "Reset to recipe"}, {"override-add", "Add an override…"},@@ -3329,6 +3330,8 @@ void Simulation::rebuild_view() {chip.value = std::to_string(counts[index]);chip.selected = static_cast<int>(index) == state_.navigation.saves_filter;}+ if (const auto awaiting = saves_awaiting_account(); job.kind == SavesJobKind::None && !awaiting.empty())+ row("saves-upload-all", RowKind::Action, "Upload all", "saves-upload-all").value = std::to_string(awaiting.size());auto& sync_all = row("saves-sync-all", RowKind::Action, job.kind == SavesJobKind::None ? "Sync all" : "Stop", "saves-sync-all");sync_all.selected = job.kind != SavesJobKind::None;sync_all.enabled = !job.stopping && (job.kind != SavesJobKind::None || counts[0] > counts[3]);@@ -3369,6 +3372,8 @@ void Simulation::rebuild_view() {if (view_.rows.size() == kSavesFilters.size() + 1)row("saves-empty", RowKind::Status, all.empty() ? "No saves on this console yet" : "Nothing here", "").enabled = false;view_.legends = {"Cross Open", job.kind == SavesJobKind::None ? "Triangle Sync all" : "Triangle Stop", "Circle Back", "L1/R1 Sections"};+ if (job.kind == SavesJobKind::None && !saves_awaiting_account().empty())+ view_.legends.insert(view_.legends.begin() + 2, "Square Upload all");} else if (state_.navigation.route == Route::SaveDetails) {const auto id = state_.navigation.save_id;const auto* game = find_game(state_, id);@@ -3992,6 +3997,30 @@ void Simulation::open_saves() {if (live()) pending_cloud_requests_.push_back({CloudRequestKind::QuickCheck, 0});}+// Games whose saves were never uploaded to this Steam account and wait only for the player to+// confirm it ("Not in Cloud yet"); Upload all confirms them together.+std::vector<GameId> Simulation::saves_awaiting_account() const {+ std::vector<GameId> out;+ for (const auto id : save_games(false)) {+ const auto cloud = state_.cloud.find(id);+ if (cloud != state_.cloud.end() && cloud->second.status == CloudStatus::NeedsAccount && !cloud->second.queued &&+ !cloud->second.after_play)+ out.push_back(id);+ }+ return out;+}++void Simulation::ask_upload_all() {+ const auto count = saves_awaiting_account().size();+ if (count == 0 || state_.saves_job.kind != SavesJobKind::None) return;+ ModalEntry confirm{"confirmation", count == 1 ? "Upload saves to this Steam account?" : "Upload all saves to this Steam account?",+ state_.navigation.focus_key, {"cloud-confirm-account-all", "cancel"}, 0, false};+ confirm.body = "Playden has not synced " + (count == 1 ? std::string("1 game's saves") : std::to_string(count) + " games' saves") ++ " for " + (state_.account.display_name.empty() ? std::string("this account") : state_.account.display_name) ++ " before. Confirm to upload this console's saves to its Steam Cloud.";+ open_modal(std::move(confirm));+}+std::vector<GameId> Simulation::save_games(bool filtered) const {std::set<GameId> ids;for (const auto& installation : state_.installations) ids.insert(installation.game_id);@@ -4029,7 +4058,9 @@ std::vector<GameId> Simulation::save_games(bool filtered) const {// reaches the tab bar.bool Simulation::move_saves(int delta_x, int delta_y) {if (view_.rows.empty()) return true;- const auto chip = [](const ViewRow& item) { return item.key.rfind("saves-filter-", 0) == 0 || item.key == "saves-sync-all"; };+ const auto chip = [](const ViewRow& item) {+ return item.key.rfind("saves-filter-", 0) == 0 || item.key == "saves-upload-all" || item.key == "saves-sync-all";+ };const int current = std::clamp(view_.focused_row, 0, static_cast<int>(view_.rows.size()) - 1);int chips = 0;while (chips < static_cast<int>(view_.rows.size()) && chip(view_.rows[static_cast<std::size_t>(chips)])) ++chips;@@ -4390,6 +4421,11 @@ void Simulation::activate() {} else if (live() && action_name == "saves-sync-all") {pending_cloud_requests_.push_back({state_.saves_job.kind == SavesJobKind::None ? CloudRequestKind::SyncAll: CloudRequestKind::StopJob, 0});+ } else if (live() && action_name == "saves-upload-all") {+ ask_upload_all();+ } else if (live() && action_name == "cloud-confirm-account-all") {+ for (const auto id : saves_awaiting_account()) pending_cloud_requests_.push_back({CloudRequestKind::ConfirmAccount, id});+ close_modal();} else if (live() && action_name == "manage-saves") {const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);state_.navigation.modals.clear();@@ -5509,6 +5545,8 @@ bool Simulation::action(const std::string& logical_action) {if (state_.library.favorites.contains(state_.navigation.selected_game_id)) state_.library.favorites.erase(state_.navigation.selected_game_id);else state_.library.favorites.insert(state_.navigation.selected_game_id);save_profile();+ } else if (live() && state_.navigation.modals.empty() && state_.navigation.route == Route::Saves) {+ ask_upload_all();}} else if (logical_action.rfind("inject:", 0) == 0) {auto injected = logical_action.substr(7);diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hppindex 33df41a..685022c 100644--- a/src/homebrew/simulation.hpp+++ b/src/homebrew/simulation.hpp@@ -782,6 +782,8 @@ private:bool move_saves(int delta_x, int delta_y);// The Saves tab's games, in name order, after the filter when `filtered`.[[nodiscard]] std::vector<GameId> save_games(bool filtered) const;+ [[nodiscard]] std::vector<GameId> saves_awaiting_account() const;+ void ask_upload_all();void open_saves();void settle_quit_sync(GameId id, std::optional<CloudStatus> status);void change_route(int delta);diff --git a/src/homebrew/view.cpp b/src/homebrew/view.cppindex fee288b..e236006 100644--- a/src/homebrew/view.cpp+++ b/src/homebrew/view.cpp@@ -965,6 +965,18 @@ class Render::Impl}}+ // An arrow rising from a tray: upload.+ void upload_icon(float cx, float cy, float size, float width, gfx::Color ink)+ {+ const float half = size * 0.5F;+ scene_.line(cx, cy + half * 0.4F, cx, cy - half, width, ink);+ scene_.line(cx, cy - half, cx - half * 0.6F, cy - half * 0.4F, width, ink);+ scene_.line(cx, cy - half, cx + half * 0.6F, cy - half * 0.4F, width, ink);+ scene_.line(cx - half, cy + half * 0.3F, cx - half, cy + half, width, ink);+ scene_.line(cx - half, cy + half, cx + half, cy + half, width, ink);+ scene_.line(cx + half, cy + half, cx + half, cy + half * 0.3F, width, ink);+ }+// The macOS `ActionButton`: primary is filled with the accent, the others are outlined;// focus adds the ring and glow and lifts the button slightly.void mac_button(gfx::DrawList &list, const gfx::Rect &rect, std::string_view label, bool primary,@@ -2187,8 +2199,12 @@ class Render::Implstats_.focused_control_key = row.key;return control_focus(row.key, focused);};- // Chips, then Sync all at the right.+ // Chips, then Upload all (when games wait for the account) and Sync all at the right.float x = kSafeX;+ float sync_left = 1824.0F;+ for (const ViewRow &row : view.rows)+ if (row.key == "saves-sync-all")+ sync_left = 1824.0F - fonts_.display.measure(row.title, 26.0F) - 74.0F;std::vector<const ViewRow *> games;for (const ViewRow &row : view.rows){@@ -2210,6 +2226,20 @@ class Render::Implpill_focus_ring(chip, amount);x += chip.w + 12.0F;}+ else if (row.key == "saves-upload-all")+ {+ const float label = fonts_.display.measure(row.title, 26.0F);+ const float count = fonts_.semibold.measure(row.value, 20.0F);+ const gfx::Rect button{sync_left - 12.0F - label - count - 86.0F, 186.0F, label + count + 86.0F, 48.0F};+ const float amount = focus_of(row);+ focus_glow(scene_, button, amount, true);+ scene_.bordered_rect(button, 8.0F, kText.with_alpha(0.06F), 1.5F, kText.with_alpha(0.5F));+ upload_icon(button.x + 26.0F, button.cy(), 18.0F, 2.0F, kText);+ ui::text(scene_, fonts_.display, row.title, button.x + 48.0F, button.cy() + 9.0F, 26.0F, kText);+ ui::text(scene_, fonts_.semibold, row.value, button.x + 48.0F + label + 12.0F, button.cy() + 7.0F, 20.0F,+ kSecondary);+ focus_ring(scene_, button, amount, true);+ }else if (row.key == "saves-sync-all"){const float label = fonts_.display.measure(row.title, 26.0F);diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cppindex 1c5413d..36812c6 100644--- a/tests/homebrew_library_model_test.cpp+++ b/tests/homebrew_library_model_test.cpp@@ -59,6 +59,11 @@ bool has_row(const Simulation& model, const std::string& key) {[&key](const auto& row) { return row.key == key; });}+bool has_legend(const Simulation& model, const std::string& legend) {+ const auto& legends = model.view().legends;+ return std::find(legends.begin(), legends.end(), legend) != legends.end();+}+void activate(Simulation& model, const std::string& key) {check(model.action("focus:" + key), "requested row exists");check(model.action("cross"), "requested row activates");@@ -1271,6 +1276,59 @@ const playden::homebrew::ViewRow* saves_row(const Simulation& model, const std::return nullptr;}+// Games never uploaded to this Steam account are confirmed together; choices stay per game.+void live_saves_upload_all() {+ using playden::homebrew::LiveCloudGame;+ using playden::homebrew::LiveSavesJob;+ using playden::homebrew::SavesJobKind;+ auto model = make_live();+ model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});+ check(model.UpdateLibrary({{game(42, "Alpha"), game(43, "Beta"), game(44, "Gamma")}, false, {}, false, false, {}}),+ "upload all: library loaded");+ model.UpdateInstalls({}, {{42, 600'000'000}, {43, 100'000'000}, {44, 100'000'000}});+ model.action("l1");+ model.action("l1");+ model.TakeCloudRequests();++ LiveCloudGame conflict{42, CloudStatus::Conflict, "Both changed."};+ LiveCloudGame synced{43, CloudStatus::Synced, "1 save uploaded"};+ model.UpdateCloud({conflict, synced});+ check(!saves_row(model, "saves-upload-all") && !has_legend(model, "Square Upload all"),+ "upload all: hidden while no game waits for the account");++ LiveCloudGame first{43, CloudStatus::NeedsAccount, "Confirm this Steam account."};+ LiveCloudGame second{44, CloudStatus::NeedsAccount, "Confirm this Steam account."};+ model.UpdateCloud({first, second});+ check(saves_row(model, "saves-upload-all") && saves_row(model, "saves-upload-all")->value == "2" &&+ has_legend(model, "Square Upload all"),+ "upload all: offered with the number of games");+ check(model.action("focus:saves-filter-4"), "upload all: focus the last filter");+ model.action("right");+ check(model.state().navigation.focus_key == "saves-upload-all", "upload all: sits between the chips and Sync all");+ model.action("right");+ check(model.state().navigation.focus_key == "saves-sync-all", "upload all: Sync all follows it");++ // One confirmation, then one request per waiting game; the conflict is left for the player.+ model.action("square");+ check(!model.state().navigation.modals.empty() &&+ model.state().navigation.modals.back().title == "Upload all saves to this Steam account?" &&+ model.state().navigation.modals.back().body.find("2 games' saves for Synthetic") != std::string::npos,+ "upload all: Square asks once for every game");+ check(model.TakeCloudRequests().empty(), "upload all: nothing is sent before the confirmation");+ activate(model, "cloud-confirm-account-all");+ auto requests = model.TakeCloudRequests();+ check(requests.size() == 2 && requests[0].kind == CloudRequestKind::ConfirmAccount && requests[0].game_id == 43 &&+ requests[1].kind == CloudRequestKind::ConfirmAccount && requests[1].game_id == 44,+ "upload all: confirms each waiting game");+ check(model.state().navigation.modals.empty(), "upload all: the dialog closes");++ // Not while Sync all runs.+ model.UpdateSavesJob({SavesJobKind::SyncAll, 0, 3, 42, false});+ check(!saves_row(model, "saves-upload-all"), "upload all: hidden while Sync all runs");+ model.action("square");+ check(model.state().navigation.modals.empty(), "upload all: Square does nothing while Sync all runs");+}+void live_saves_tab() {using playden::homebrew::LiveCloudGame;using playden::homebrew::LiveSavesJob;@@ -1538,6 +1596,7 @@ int main() {live_log_viewer();live_cloud_saves();live_saves_tab();+ live_saves_upload_all();live_filters_only_use_available_facts();live_empty_filter_keeps_the_signed_in_account();projects_only_owned_facts_and_delivery_status();