Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Add a Storage section with batch uninstall

Leonardo Lobato124465860c12
diff --git a/README.md b/README.md
index 0cbb1e9..55ad67a 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,8 @@ private Windows environment and its own tile on the PS5 Home screen.
- **Your whole Steam library.** Search, sort, favorites, collections, ratings and notes, with cover art and store
details. The library works offline from a cache.
- **Downloads from Steam.** Queue games and watch progress.
+- **Storage at a glance.** Settings › Storage shows how much space is used and lists installed games by size or
+ last played. Select several games and uninstall them together; saves are kept unless you choose otherwise.
- **Each game is its own PS5 app.** It gets a tile on the Home screen, so you can start it without Playden.
- **A private Windows environment per game** ("bottle"), so games do not share settings or files.
- **Steam Cloud saves.** Playden checks your Cloud saves before a game starts and syncs them after it ends. If the
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index b1df788..2687892 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -205,6 +205,10 @@ Installation* find_installation(State& state, GameId id) {
return found == state.installations.end() ? nullptr : &*found;
}
+const Installation* find_installation(const State& state, GameId id) {
+ return find_installation(const_cast<State&>(state), id);
+}
+
bool is_installed(const State& state, GameId id) {
const auto found = std::find_if(state.installations.begin(), state.installations.end(),
[id](const Installation& installation) { return installation.game_id == id; });
@@ -299,6 +303,9 @@ constexpr const char* uninstall_body_kept = "The game's files and its PS5 title
"settings are kept, and installing the game again brings them back.";
constexpr const char* uninstall_body_deleted = "The game's files, its PS5 title and its saves and settings on this console are "
"deleted.";
+constexpr const char* uninstall_batch_body_kept = "Their files and PS5 titles are removed from this console. Their saves and "
+ "settings are kept, and installing a game again brings them back.";
+constexpr const char* uninstall_batch_body_deleted = "Their files, PS5 titles and saves and settings on this console are deleted.";
// The name kept game data is shown with: the game's name, else the library's, else its app id.
std::string kept_name(const State& state, const LiveKeptBottle& kept) {
@@ -439,7 +446,7 @@ std::string action_label(const std::string& key) {
{"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"},
+ {"install-confirm", "Install"}, {"storage-picker", "Change storage"}, {"installed-close", "Close"}, {"installed-show-all", "Show all games"},
{"value-edit", "Edit…"}, {"value-reset", "Reset to recipe"}, {"override-add", "Add an override…"},
{"unlock-setting", "Change anyway"}, {"export-recipe", "Export as recipe"}, {"program-scan", "Looking for programs…"},
{"preset-picker", "Preset"}, {"game-settings", "Game settings"}, {"game-maintenance", "Maintenance"}, {"runtime-check-again", "Check again"}, {"reset-settings", "Reset all to preset"}, {"clear-shader-cache", "Clear shader cache"},
@@ -762,6 +769,133 @@ std::vector<std::string> Simulation::kept_manager_actions() const {
return actions;
}
+std::vector<GameId> Simulation::installed_list() const {
+ struct Entry { GameId id; std::uint64_t bytes; std::optional<std::int64_t> played; std::string title; };
+ std::vector<Entry> entries;
+ const auto add = [&](GameId id, std::uint64_t bytes) {
+ const auto* game = find_game(state_, id);
+ entries.push_back({id, bytes, game ? game->last_played : std::nullopt,
+ game ? (game->folded_title.empty() ? game->title : game->folded_title) : std::to_string(id)});
+ };
+ for (const auto& installation : state_.installations) add(installation.game_id, installation.installed_bytes);
+ // As on macOS: largest first, or never played first and then the longest unplayed; ties by title.
+ std::sort(entries.begin(), entries.end(), [this](const Entry& left, const Entry& right) {
+ if (installed_by_played_) {
+ if (left.played.has_value() != right.played.has_value()) return !left.played.has_value();
+ if (left.played && *left.played != *right.played) return *left.played < *right.played;
+ } else if (left.bytes != right.bytes) {
+ return left.bytes > right.bytes;
+ }
+ return left.title != right.title ? left.title < right.title : left.id < right.id;
+ });
+ std::vector<GameId> ids;
+ for (const auto& entry : entries) ids.push_back(entry.id);
+ return ids;
+}
+
+std::string Simulation::installed_blocker(GameId id) const {
+ const auto runtime = state_.runtime_games.find(id);
+ const LiveRuntimeGame* game = runtime == state_.runtime_games.end() ? nullptr : &runtime->second;
+ if (game && !game->uninstall_status.empty()) return game->uninstall_status;
+ if (pending_uninstalls_.contains(id)) return "Uninstalling…";
+ if (game && (game->activity == TitleActivity::Running || game->play_status == "Playing" || game->play_status == "Starting…"))
+ return "Playing";
+ if (std::any_of(state_.jobs.begin(), state_.jobs.end(), [id](const Job& job) {
+ return job.game_id == id && job.state != JobState::Downloaded && job.state != JobState::Cancelled;
+ }))
+ return "In Downloads";
+ if (game && (game->status == "Preparing" || game->maintenance_running)) return "Busy";
+ return {};
+}
+
+bool Simulation::uninstall_batch_done() const {
+ return uninstall_batch_ && uninstall_batch_->uninstalled.size() + uninstall_batch_->stopped.size() >= uninstall_batch_->ids.size();
+}
+
+// The list: Sort and Select all, the games, then the footer's Uninstall selected and Close. While
+// a batch runs it lists only the batch's games, with Close (and Show all games once all are done).
+std::vector<std::string> Simulation::installed_manager_actions() const {
+ std::vector<std::string> actions;
+ if (uninstall_batch_) {
+ for (const auto id : uninstall_batch_->ids) actions.push_back("installed-step-" + std::to_string(id));
+ if (uninstall_batch_done()) actions.push_back("installed-show-all");
+ actions.push_back("installed-close");
+ return actions;
+ }
+ actions = {"installed-sort", "installed-select-all"};
+ for (const auto id : installed_list()) actions.push_back("installed-toggle-" + std::to_string(id));
+ actions.push_back("installed-selection-uninstall");
+ actions.push_back("installed-close");
+ return actions;
+}
+
+// Where a key of the Installed games list sits: 0 Sort and Select all, 1 the games, 2 the footer.
+static int installed_part(const std::string& key) {
+ if (key == "installed-sort" || key == "installed-select-all") return 0;
+ if (key.rfind("installed-toggle-", 0) == 0 || key.rfind("installed-step-", 0) == 0) return 1;
+ return 2;
+}
+
+// The footer's buttons go side by side: Left/Right move between them, Up returns to the game the
+// focus left, and Down from the last game reaches them.
+void Simulation::move_installed_manager(int delta_x, int delta_y) {
+ auto& modal = state_.navigation.modals.back();
+ const auto& keys = modal.action_keys;
+ const int current = std::clamp(modal.focused_action, 0, static_cast<int>(keys.size()) - 1);
+ const int part = installed_part(keys[static_cast<std::size_t>(current)]);
+ int first_footer = static_cast<int>(keys.size());
+ for (int index = 0; index < static_cast<int>(keys.size()); ++index)
+ if (installed_part(keys[static_cast<std::size_t>(index)]) == 2) { first_footer = index; break; }
+ int target = current;
+ if (part == 2) {
+ if (delta_x != 0) target = std::clamp(current + (delta_x > 0 ? 1 : -1), first_footer, static_cast<int>(keys.size()) - 1);
+ else if (delta_y < 0 && first_footer > 0) {
+ const auto back = std::find(keys.begin(), keys.end(), installed_list_focus_);
+ target = back != keys.end() ? static_cast<int>(back - keys.begin()) : first_footer - 1;
+ }
+ } else if (delta_y != 0) {
+ target = current + delta_y;
+ if (target >= first_footer) {
+ installed_list_focus_ = keys[static_cast<std::size_t>(current)];
+ target = current == first_footer - 1 ? first_footer : first_footer - 1;
+ }
+ target = std::clamp(target, 0, static_cast<int>(keys.size()) - 1);
+ }
+ modal.focused_action = target;
+ state_.navigation.focus_key = keys[static_cast<std::size_t>(target)];
+}
+
+// The open Installed games list follows the installs, jobs and runtime: games that are gone or
+// can't be picked now leave the selection, and with no game left the list closes.
+void Simulation::refresh_installed_manager() {
+ std::erase_if(installed_selected_, [this](GameId id) { return !find_installation(state_, id) || !installed_blocker(id).empty(); });
+ auto& modals = state_.navigation.modals;
+ for (std::size_t index = 0; index < modals.size(); ++index) {
+ auto& modal = modals[index];
+ if (modal.id != "installed-games") continue;
+ auto actions = installed_manager_actions();
+ if (!uninstall_batch_ && actions.size() == 4) {
+ if (index + 1 == modals.size()) close_modal();
+ break;
+ }
+ const auto focused = modal.action_keys[static_cast<std::size_t>(modal.focused_action)];
+ modal.action_keys = std::move(actions);
+ const auto found = std::find(modal.action_keys.begin(), modal.action_keys.end(), focused);
+ if (found != modal.action_keys.end()) {
+ modal.focused_action = static_cast<int>(found - modal.action_keys.begin());
+ } else {
+ // The focused game went away: the nearest game left takes the focus, else Close.
+ int first = -1, last = -1;
+ for (int key = 0; key < static_cast<int>(modal.action_keys.size()); ++key)
+ if (installed_part(modal.action_keys[static_cast<std::size_t>(key)]) == 1) { if (first < 0) first = key; last = key; }
+ const auto close = std::find(modal.action_keys.begin(), modal.action_keys.end(), "installed-close");
+ modal.focused_action = first >= 0 ? std::clamp(modal.focused_action, first, last)
+ : static_cast<int>(close - modal.action_keys.begin());
+ }
+ if (index + 1 == modals.size()) state_.navigation.focus_key = modal.action_keys[static_cast<std::size_t>(modal.focused_action)];
+ }
+}
+
std::vector<GameId> Simulation::TakeKeptDeleteRequests() {
auto requests = std::move(pending_kept_delete_requests_);
pending_kept_delete_requests_.clear();
@@ -781,6 +915,15 @@ std::vector<GameId> Simulation::TakeActivityRequests() {
}
void Simulation::NotifyUninstallStopped(GameId id, const std::string& reason) {
+ // A game the open Installed games list uninstalls says why in its row instead.
+ if (uninstall_batch_ && installed_list_open() &&
+ std::find(uninstall_batch_->ids.begin(), uninstall_batch_->ids.end(), id) != uninstall_batch_->ids.end()) {
+ uninstall_batch_->stopped[id] = reason;
+ pending_uninstalls_.erase(id);
+ refresh_installed_manager();
+ rebuild_view();
+ return;
+ }
const auto* game = find_game(state_, id);
push_notice({"uninstall-" + std::to_string(id), "Uninstall stopped", "", false, kLiveNoticeSeconds * 2, true,
(game ? game->title : std::string("A game")) + " · " + reason});
@@ -1034,6 +1177,7 @@ void Simulation::UpdateRuntime(RuntimeState runtime, const std::vector<LiveRunti
}
show_ready_prompt();
open_settings_after_prepare();
+ refresh_installed_manager();
rebuild_view();
}
@@ -1156,8 +1300,15 @@ void Simulation::UpdateInstalls(const std::vector<LiveInstallJob>& jobs, const s
push_notice({"install-" + std::to_string(job.game_id), "Download failed", "", false, kLiveNoticeSeconds * 2, true,
title(job.game_id) + (job.failure.empty() ? std::string() : " · " + job.failure), false});
}
+ const bool batch_open = uninstall_batch_ && installed_list_open();
for (const auto id : live_installed_ids_) {
if (installed_ids.contains(id) || job_states.contains(id) || !pending_uninstalls_.contains(id)) continue;
+ // The open Installed games list says so in the game's row.
+ if (batch_open && std::find(uninstall_batch_->ids.begin(), uninstall_batch_->ids.end(), id) != uninstall_batch_->ids.end()) {
+ uninstall_batch_->stopped.erase(id);
+ uninstall_batch_->uninstalled.insert(id);
+ continue;
+ }
push_notice({"install-" + std::to_string(id), "Game uninstalled", "", false, kLiveNoticeSeconds, false, title(id)});
}
}
@@ -1208,6 +1359,7 @@ void Simulation::UpdateInstalls(const std::vector<LiveInstallJob>& jobs, const s
sync_self_update_job();
state_.installations = std::move(installations);
apply_live_volume_usage();
+ refresh_installed_manager();
rebuild_view();
}
@@ -2505,7 +2657,14 @@ std::vector<const Game*> Simulation::visible_games() const {
return filtered_games(state_);
}
+bool Simulation::installed_list_open() const {
+ return std::any_of(state_.navigation.modals.begin(), state_.navigation.modals.end(),
+ [](const ModalEntry& modal) { return modal.id == "installed-games"; });
+}
+
void Simulation::rebuild_view() {
+ // An uninstall batch lives while its list is open; later stops are notices again.
+ if (!rebuilding_overlay_ && uninstall_batch_ && !installed_list_open()) uninstall_batch_.reset();
const bool has_overlay = state_.editor.active || !state_.navigation.modals.empty();
if (has_overlay) {
const auto editor = state_.editor;
@@ -2514,8 +2673,14 @@ void Simulation::rebuild_view() {
const int selected_index = state_.navigation.selected_index;
const GameId selected_game_id = state_.navigation.selected_game_id;
state_.editor.active = false;
+ // Settings under a sheet shows the section of the row that opened it.
+ if (state_.navigation.route == Route::Settings && !modals.empty() &&
+ modals.front().opener_focus_key.rfind("settings-", 0) == 0)
+ state_.navigation.focus_key = modals.front().opener_focus_key;
state_.navigation.modals.clear();
+ rebuilding_overlay_ = true;
rebuild_view();
+ rebuilding_overlay_ = false;
route_view_ = view_;
state_.editor = editor;
state_.navigation.modals = modals;
@@ -2631,6 +2796,33 @@ void Simulation::rebuild_view() {
const auto* fallback = find_volume(state_, selected_volume_id_);
view_.subtitle = "For this game only." + (fallback ? " Other games still install to " + fallback->label + "." : std::string());
}
+ if (modal.id == "installed-games") {
+ if (!uninstall_batch_) {
+ view_.subtitle = !installed_message_.empty() ? installed_message_
+ : "Choose games to uninstall. Their saves and settings are kept unless you choose to delete them.";
+ std::uint64_t bytes = 0;
+ for (const auto& installation : state_.installations)
+ if (installed_selected_.contains(installation.game_id)) bytes += installation.installed_bytes;
+ view_.footer = installed_selected_.empty() ? std::string("Select games to uninstall")
+ : std::to_string(installed_selected_.size()) + " selected · " + format_bytes(bytes);
+ } else {
+ view_.subtitle = uninstall_batch_done() ? "Finished uninstalling." : "Uninstalling the selected games.";
+ const auto& batch = *uninstall_batch_;
+ const auto ended = batch.uninstalled.size() + batch.stopped.size();
+ if (ended < batch.ids.size()) {
+ view_.footer = "Uninstalling " + std::to_string(ended + 1) + " of " + std::to_string(batch.ids.size()) + "…";
+ } else {
+ std::uint64_t freed = 0;
+ for (const auto id : batch.uninstalled) freed += batch.bytes.at(id);
+ std::vector<std::string> parts;
+ if (!batch.uninstalled.empty())
+ parts.push_back(std::to_string(batch.uninstalled.size()) + " uninstalled" +
+ (freed > 0 ? " · about " + format_bytes(freed) + " freed" : std::string()));
+ if (!batch.stopped.empty()) parts.push_back(std::to_string(batch.stopped.size()) + " stopped");
+ for (const auto& part : parts) view_.footer += (view_.footer.empty() ? "" : " · ") + part;
+ }
+ }
+ }
if (modal.id == "kept-data")
view_.subtitle = "Saves and settings kept when a game was uninstalled. Installing a game again brings its saves "
"back. Saves in Steam Cloud stay in Steam Cloud.";
@@ -2880,6 +3072,76 @@ void Simulation::rebuild_view() {
}
else if (action_key == "quit-to-home") item.dangerous = true; // the dialog's primary action
else if (action_key == "saves-delete-confirm" || action_key == "saves-leftover-confirm") item.dangerous = true;
+ else if (action_key == "installed-sort") {
+ item.title = "Sort by";
+ item.value = installed_by_played_ ? "Last played" : "Size";
+ }
+ else if (action_key == "installed-select-all") {
+ std::size_t choosable = 0, chosen = 0;
+ for (const auto id : installed_list())
+ if (find_installation(state_, id) && installed_blocker(id).empty()) {
+ ++choosable;
+ chosen += installed_selected_.contains(id) ? 1 : 0;
+ }
+ item.title = choosable > 0 && chosen == choosable ? "Clear selection" : "Select all";
+ item.enabled = choosable > 0;
+ }
+ else if (action_key.rfind("installed-toggle-", 0) == 0) {
+ const auto id = static_cast<GameId>(std::strtoull(action_key.c_str() + 17, nullptr, 10));
+ const auto* game = find_game(state_, id);
+ const auto* installation = find_installation(state_, id);
+ item.kind = RowKind::Toggle;
+ item.game_id = id;
+ item.title = game && !game->title.empty() ? game->title : "Steam app " + std::to_string(id);
+ item.selected = installed_selected_.contains(id);
+ item.value = installation ? format_bytes(installation->installed_bytes) : std::string();
+ const auto blocker = installed_blocker(id);
+ const auto stopped = installed_stops_.find(id);
+ if (!blocker.empty()) {
+ item.subtitle = blocker;
+ item.enabled = false;
+ } else if (stopped != installed_stops_.end()) {
+ // Stopped in the batch just shown: the reason stays until the list closes.
+ item.subtitle = "Stopped: " + stopped->second;
+ item.tone = "problem";
+ } else {
+ const auto when = game && game->last_played ? time_ago(state_.clock_ticks, *game->last_played) : std::string();
+ item.subtitle = !game || !game->last_played ? "Never played" : when.empty() ? "Played" : "Played " + when;
+ // With games on more than one drive, each row names its drive.
+ std::set<std::string> drives;
+ for (const auto& other : state_.installations) drives.insert(other.volume_id);
+ if (drives.size() > 1 && installation)
+ if (const auto* volume = find_volume(state_, installation->volume_id))
+ item.subtitle = volume->label + " · " + item.subtitle;
+ }
+ }
+ else if (action_key.rfind("installed-step-", 0) == 0 && uninstall_batch_) {
+ // A game of the running batch: how far its uninstall is, then how it ended.
+ const auto id = static_cast<GameId>(std::strtoull(action_key.c_str() + 15, nullptr, 10));
+ const auto* game = find_game(state_, id);
+ const auto& batch = *uninstall_batch_;
+ item.kind = RowKind::Status;
+ item.game_id = id;
+ item.title = game && !game->title.empty() ? game->title : "Steam app " + std::to_string(id);
+ item.value = format_bytes(batch.bytes.count(id) ? batch.bytes.at(id) : 0);
+ const auto runtime = state_.runtime_games.find(id);
+ if (batch.uninstalled.contains(id)) {
+ item.subtitle = "Uninstalled";
+ item.tone = "good";
+ } else if (const auto stopped = batch.stopped.find(id); stopped != batch.stopped.end()) {
+ item.subtitle = "Stopped: " + stopped->second;
+ item.tone = "problem";
+ } else if (runtime != state_.runtime_games.end() && !runtime->second.uninstall_status.empty()) {
+ item.subtitle = runtime->second.uninstall_status;
+ } else {
+ item.subtitle = "Waiting";
+ }
+ }
+ else if (action_key == "installed-selection-uninstall") {
+ item.title = "Uninstall selected";
+ item.dangerous = true;
+ item.enabled = !installed_selected_.empty();
+ }
else if (action_key == "kept-select-all") {
const bool all = !state_.kept_bottles.empty() && kept_selected_.size() == state_.kept_bottles.size();
item.title = all ? "Clear selection" : "Select all";
@@ -3023,6 +3285,11 @@ void Simulation::rebuild_view() {
else if (modal.id == "preset-picker") view_.legends = {"Cross Use this preset", "L1/R1 Jump", "Circle Back"};
else if (modal.id == "button-mapping") view_.legends = {"Cross Change", "L1/R1 Jump", "Circle Back"};
else if (modal.id == "game-maintenance") view_.legends = {"Cross Select", "L1/R1 Jump", "Circle Cancel"};
+ else if (modal.id == "installed-games")
+ // The batch's rows only report; Cross does something only on its buttons.
+ view_.legends = !uninstall_batch_ ? std::vector<std::string>{"Cross Select", "Triangle Uninstall", "Circle Close"}
+ : installed_part(state_.navigation.focus_key) == 2 ? std::vector<std::string>{"Cross Choose", "Circle Close"}
+ : std::vector<std::string>{"Circle Close"};
else if (!modal.setting_id.empty()) view_.legends = {"Cross Select", "Triangle Reset", "L1/R1 Jump", "Circle Back"};
} else if (state_.navigation.route == Route::Startup) {
view_.title = "Welcome to Playden";
@@ -3431,20 +3698,6 @@ void Simulation::rebuild_view() {
if (state_.account.authentication != AuthState::SignedOut)
add("settings-signout", RowKind::Action, "Sign out", "signout-confirm").dangerous = true;
section = "Library";
- auto& storage = add("settings-storage", RowKind::Action, "Library and storage", "storage-manager");
- if (live()) {
- const auto* volume = find_volume(state_, selected_volume_id_);
- storage.title = "Games storage";
- storage.value = volume ? volume->label : "";
- storage.subtitle = "Where new games are installed";
- if (state_.volumes.empty()) { storage.kind = RowKind::Status; storage.action.clear(); storage.enabled = false; storage.subtitle = "Storage is unavailable"; }
- }
- auto& runtime = add("settings-runtime", RowKind::Action, "Runtime status", "settings-runtime");
- runtime.value = state_.runtime == RuntimeState::Ready ? (live() ? "Ready" : "Ready — simulated") : state_.runtime == RuntimeState::Checking ? (live() ? "Checking" : "Checking — simulated") : state_.runtime == RuntimeState::Failed ? (live() ? "Failed" : "Failed — simulated") : (live() ? "Unavailable" : "Unavailable — simulated");
- if (live()) {
- runtime.subtitle = state_.runtime_problem.empty() ? "Games run through prospero-win" : state_.runtime_problem;
- runtime.kind = RowKind::Status; runtime.action.clear(); runtime.enabled = false;
- }
if (live()) {
auto& suffix = add("settings-title-store", RowKind::Toggle, "Store name in PS5 titles", "toggle-title-store");
suffix.selected = state_.title_store_suffix;
@@ -3454,6 +3707,28 @@ void Simulation::rebuild_view() {
cloud.subtitle = state_.cloud_saves_auto ? "Before Play, after each game and when Playden starts."
: "Off: saves move only when you choose Sync in Saves.";
}
+ section = "Storage";
+ auto& storage = add("settings-storage", RowKind::Action, "Library and storage", "storage-picker");
+ if (live()) {
+ const auto* volume = find_volume(state_, selected_volume_id_);
+ storage.title = "Games storage";
+ storage.value = volume ? volume->label : "";
+ storage.subtitle = "Where new games are installed";
+ if (state_.volumes.empty()) { storage.kind = RowKind::Status; storage.action.clear(); storage.enabled = false; storage.subtitle = "Storage is unavailable"; }
+ }
+ if (live()) {
+ // Installed games: one row that opens the list, sorted by size or last played, where
+ // the player picks games to uninstall together.
+ auto& installed = add("settings-installed", RowKind::Action, "Installed games", "installed-manage");
+ installed.subtitle = "Uninstall games you no longer play to free up space";
+ if (state_.installations.empty()) {
+ installed.kind = RowKind::Status; installed.action.clear(); installed.enabled = false; installed.value = "None";
+ } else {
+ std::uint64_t bytes = 0;
+ for (const auto& item : state_.installations) bytes += item.installed_bytes;
+ installed.value = kept_count(state_.installations.size()) + " · " + format_bytes(bytes);
+ }
+ }
if (live()) {
// Saves and settings kept from uninstalled games: one row that opens the manager,
// where the player picks which to delete to reclaim their space.
@@ -3473,6 +3748,12 @@ void Simulation::rebuild_view() {
leftovers.value = std::to_string(state_.runtime_leftover_requests);
leftovers.subtitle = "Left by interrupted or finished preparations. Clean up removes only what no game is using.";
}
+ auto& runtime = add("settings-runtime", RowKind::Action, "Runtime status", "settings-runtime");
+ runtime.value = state_.runtime == RuntimeState::Ready ? (live() ? "Ready" : "Ready — simulated") : state_.runtime == RuntimeState::Checking ? (live() ? "Checking" : "Checking — simulated") : state_.runtime == RuntimeState::Failed ? (live() ? "Failed" : "Failed — simulated") : (live() ? "Unavailable" : "Unavailable — simulated");
+ if (live()) {
+ runtime.subtitle = state_.runtime_problem.empty() ? "Games run through prospero-win" : state_.runtime_problem;
+ runtime.kind = RowKind::Status; runtime.action.clear(); runtime.enabled = false;
+ }
section = "Display";
auto& motion = add("settings-motion", RowKind::Toggle, "Reduced motion", "toggle-motion");
motion.selected = state_.reduced_motion;
@@ -3879,6 +4160,7 @@ void Simulation::move(int delta_x, int delta_y) {
state_.log_offset = std::clamp(state_.log_offset + delta, 0, std::max(0, static_cast<int>(state_.log_lines.size()) - 8));
return;
}
+ if (modal.id == "installed-games") { move_installed_manager(delta_x, delta_y); return; }
const int delta = delta_y != 0 ? delta_y : delta_x;
modal.focused_action = std::clamp(modal.focused_action + delta, 0, static_cast<int>(modal.action_keys.size()) - 1);
state_.navigation.focus_key = modal.action_keys[static_cast<std::size_t>(modal.focused_action)];
@@ -3945,16 +4227,25 @@ void Simulation::move_content(int delta_x, int delta_y) {
// Settings sections, as on macOS: Left moves to the section rail, Up/Down there switches
// section (focusing its first row), Right or Cross returns to the rows. Up/Down on the rows
-// crosses into the next section so every row stays reachable in order.
+// stay in the focused section; Up on its first row goes to the tab bar.
bool Simulation::move_settings(int delta_x, int delta_y) {
if (view_.rows.empty()) return true;
const int current = std::clamp(view_.focused_row, 0, static_cast<int>(view_.rows.size()) - 1);
if (!state_.navigation.settings_rail_focused) {
if (delta_x < 0) { state_.navigation.settings_rail_focused = true; return true; }
- // A rail-only section (Quit Playden) has no card to move onto from the rows.
+ // Up and Down stay in the focused section: the rail (or the tab bar above the first row)
+ // is the way to another one. A rail-only section (Quit Playden) has no card to move onto.
if (delta_y != 0) {
- const int target = std::clamp(current + delta_y, 0, static_cast<int>(view_.rows.size()) - 1);
- if (view_.rows[static_cast<std::size_t>(target)].rail_only) return true;
+ const auto& section = view_.rows[static_cast<std::size_t>(current)].section;
+ int first = current, last = current;
+ while (first > 0 && view_.rows[static_cast<std::size_t>(first - 1)].section == section) --first;
+ while (last + 1 < static_cast<int>(view_.rows.size()) && view_.rows[static_cast<std::size_t>(last + 1)].section == section) ++last;
+ const int target = std::clamp(current + delta_y, first, last);
+ if (target != current && !view_.rows[static_cast<std::size_t>(target)].rail_only) {
+ state_.navigation.selected_index = target;
+ state_.navigation.focus_key = view_.rows[static_cast<std::size_t>(target)].key;
+ }
+ return true;
}
return delta_x > 0;
}
@@ -4321,9 +4612,9 @@ void Simulation::activate() {
}
} else if (action_name == "context") open_modal({"context", "Game actions", "details-more", details_context_actions(), 0, false});
else if (action_name == "install") open_modal({"install", "Install game", "details-install", {"install-confirm", "install-estimate-retry", "storage-picker", "cancel"}, 0, false});
- else if (action_name == "storage-picker" || action_name == "storage-manager") {
+ else if (action_name == "storage-picker") {
// From the install sheet the choice is for that install only; Settings changes the default.
- picking_install_volume_ = live() && action_name == "storage-picker";
+ picking_install_volume_ = live() && !state_.navigation.modals.empty() && state_.navigation.modals.back().id == "install";
std::vector<std::string> actions;
for (const auto& volume : state_.volumes) actions.push_back("volume-" + volume.id);
actions.push_back("cancel");
@@ -4710,8 +5001,11 @@ void Simulation::activate() {
// The dialog says what happens to the saves with the current choice.
if (!state_.navigation.modals.empty()) {
auto& body = state_.navigation.modals.back().body;
- const std::string_view from = uninstall_delete_saves_ ? uninstall_body_kept : uninstall_body_deleted;
- const std::string_view to = uninstall_delete_saves_ ? uninstall_body_deleted : uninstall_body_kept;
+ const bool batch = pending_destructive_action_ == "installed-selection-uninstall";
+ const std::string_view kept = batch ? uninstall_batch_body_kept : uninstall_body_kept;
+ const std::string_view deleted = batch ? uninstall_batch_body_deleted : uninstall_body_deleted;
+ const std::string_view from = uninstall_delete_saves_ ? kept : deleted;
+ const std::string_view to = uninstall_delete_saves_ ? deleted : kept;
if (const auto at = body.find(from); at != std::string::npos) body.replace(at, from.size(), to);
}
} else if (live() && action_name == "quit-to-home") {
@@ -4743,6 +5037,107 @@ void Simulation::activate() {
state_.navigation.selected_game_id = game;
open_game_settings();
}
+ } else if (live() && action_name == "installed-manage") {
+ if (state_.installations.empty()) return;
+ installed_selected_.clear();
+ uninstall_batch_.reset();
+ installed_message_.clear();
+ installed_stops_.clear();
+ installed_list_focus_.clear();
+ auto actions = installed_manager_actions();
+ // Focus starts on the first game; Sort and Select all are above it.
+ open_modal({"installed-games", "Installed games", state_.navigation.focus_key, std::move(actions), 2, false});
+ } else if (action_name == "installed-close") {
+ close_modal();
+ } else if (live() && action_name == "installed-show-all") {
+ // The finished batch gives way to the list of what is installed now; a stopped game keeps
+ // its reason there and can be chosen again.
+ if (uninstall_batch_) installed_stops_ = uninstall_batch_->stopped;
+ uninstall_batch_.reset();
+ refresh_installed_manager();
+ if (!state_.navigation.modals.empty() && state_.navigation.modals.back().id == "installed-games") {
+ auto& list = state_.navigation.modals.back();
+ const auto game = std::find_if(list.action_keys.begin(), list.action_keys.end(),
+ [](const std::string& key) { return key.rfind("installed-toggle-", 0) == 0; });
+ list.focused_action = game == list.action_keys.end() ? 0 : static_cast<int>(game - list.action_keys.begin());
+ state_.navigation.focus_key = list.action_keys[static_cast<std::size_t>(list.focused_action)];
+ }
+ } else if (live() && action_name == "installed-sort") {
+ installed_by_played_ = !installed_by_played_;
+ refresh_installed_manager();
+ } else if (live() && action_name == "installed-select-all") {
+ std::vector<GameId> choosable;
+ for (const auto id : installed_list())
+ if (find_installation(state_, id) && installed_blocker(id).empty()) choosable.push_back(id);
+ const bool all = !choosable.empty() && std::all_of(choosable.begin(), choosable.end(),
+ [this](GameId id) { return installed_selected_.contains(id); });
+ if (all) installed_selected_.clear();
+ else installed_selected_.insert(choosable.begin(), choosable.end());
+ } else if (live() && action_name.rfind("installed-toggle-", 0) == 0) {
+ const auto id = static_cast<GameId>(std::strtoull(action_name.c_str() + 17, nullptr, 10));
+ if (find_installation(state_, id) && installed_blocker(id).empty() && !installed_selected_.erase(id)) installed_selected_.insert(id);
+ } else if (live() && action_name == "installed-selection-uninstall") {
+ if (installed_selected_.empty()) return;
+ std::vector<std::string> names;
+ std::uint64_t bytes = 0;
+ bool any_title = false;
+ for (const auto id : installed_list()) {
+ if (!installed_selected_.contains(id)) continue;
+ const auto* game = find_game(state_, id);
+ names.push_back(game && !game->title.empty() ? game->title : "Steam app " + std::to_string(id));
+ if (const auto* installation = find_installation(state_, id)) bytes += installation->installed_bytes;
+ const auto runtime_game = state_.runtime_games.find(id);
+ any_title = any_title || (runtime_game != state_.runtime_games.end() && runtime_game->second.has_title);
+ }
+ // "A, B and C", or "A, B, C and 2 more".
+ std::string listed;
+ const auto shown = names.size() > 3 ? std::size_t{3} : names.size();
+ for (std::size_t index = 0; index < shown; ++index)
+ listed += (index == 0 ? "" : index + 1 == shown && names.size() <= 3 ? " and " : ", ") + names[index];
+ if (names.size() > 3) listed += " and " + std::to_string(names.size() - 3) + " more";
+ pending_destructive_action_ = action_name;
+ uninstall_delete_saves_ = false;
+ ModalEntry confirmation{"confirmation", "Uninstall " + kept_count(names.size()) + "?", state_.navigation.focus_key,
+ any_title ? std::vector<std::string>{"cancel", "uninstall-delete-saves", "confirm-destructive"}
+ : std::vector<std::string>{"cancel", "confirm-destructive"},
+ 0, true};
+ confirmation.body = listed + ". Frees about " + format_bytes(bytes) + ". ";
+ confirmation.body += any_title ? uninstall_batch_body_kept
+ : "Their files are removed from this console. You can install them again from Steam.";
+ confirmation.body += " Steam Cloud saves are synced first. If that fails for a game, that game stays installed and its row says why.";
+ open_modal(std::move(confirmation));
+ } else if (action_name == "confirm-destructive" && live() && pending_destructive_action_ == "installed-selection-uninstall") {
+ GameId first = 0;
+ installed_message_.clear();
+ for (const auto id : installed_list()) {
+ if (!installed_selected_.contains(id) || !installed_blocker(id).empty()) continue;
+ const auto* installation = find_installation(state_, id);
+ if (!installation) continue;
+ if (!uninstall_batch_) uninstall_batch_.emplace();
+ auto& batch = *uninstall_batch_;
+ pending_install_requests_.push_back({InstallRequestKind::Uninstall, id, {}, uninstall_delete_saves_});
+ pending_uninstalls_.insert(id);
+ if (std::find(batch.ids.begin(), batch.ids.end(), id) == batch.ids.end()) batch.ids.push_back(id);
+ batch.bytes[id] = installation->installed_bytes;
+ batch.stopped.erase(id);
+ installed_stops_.erase(id);
+ if (first == 0) first = id;
+ }
+ // Every checked game started running or downloading while the dialog was open.
+ if (first == 0) installed_message_ = "None of the selected games can be uninstalled now.";
+ installed_selected_.clear();
+ uninstall_delete_saves_ = false;
+ pending_destructive_action_.clear();
+ close_modal(); // back to the list, which shows how each game goes
+ refresh_installed_manager();
+ if (first != 0 && !state_.navigation.modals.empty() && state_.navigation.modals.back().id == "installed-games") {
+ auto& list = state_.navigation.modals.back();
+ const auto found = std::find(list.action_keys.begin(), list.action_keys.end(), "installed-step-" + std::to_string(first));
+ if (found != list.action_keys.end()) {
+ list.focused_action = static_cast<int>(found - list.action_keys.begin());
+ state_.navigation.focus_key = *found;
+ }
+ }
} else if (live() && action_name == "kept-manage") {
if (state_.kept_bottles.empty()) return;
kept_selected_.clear();
@@ -5478,6 +5873,26 @@ bool Simulation::action(const std::string& logical_action) {
pending_cloud_requests_.push_back({state_.saves_job.kind == SavesJobKind::None ? CloudRequestKind::SyncAll
: CloudRequestKind::StopJob, 0});
else if (logical_action == "search") { if (!state_.editor.active && state_.navigation.route == Route::Library && state_.navigation.modals.empty()) start_editor("Search", state_.library.query); }
+ else if (logical_action == "triangle" && !state_.editor.active && !state_.navigation.modals.empty() &&
+ state_.navigation.modals.back().id == "installed-games") {
+ // Triangle is Uninstall selected from anywhere in the list; the batch view has nothing to start.
+ auto& list = state_.navigation.modals.back();
+ const auto at = std::find(list.action_keys.begin(), list.action_keys.end(), "installed-selection-uninstall");
+ if (live() && at != list.action_keys.end() && !installed_selected_.empty()) {
+ const int was = list.focused_action;
+ const auto key = state_.navigation.focus_key;
+ list.focused_action = static_cast<int>(at - list.action_keys.begin());
+ state_.navigation.focus_key = *at;
+ rebuild_view();
+ activate();
+ // The dialog returns to the row the player was on.
+ auto& modals = state_.navigation.modals;
+ const auto list_at = std::find_if(modals.begin(), modals.end(), [](const ModalEntry& modal) { return modal.id == "installed-games"; });
+ if (list_at != modals.end()) list_at->focused_action = was;
+ if (modals.back().id == "confirmation") modals.back().opener_focus_key = key;
+ else state_.navigation.focus_key = key;
+ }
+ }
else if (logical_action == "triangle" && !state_.editor.active && !state_.navigation.modals.empty() &&
(state_.navigation.modals.back().id == "game-settings" || !state_.navigation.modals.back().setting_id.empty())) {
// Triangle returns the focused setting (or the open picker's setting) to the preset value.
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 685022c..825ffca 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -492,6 +492,7 @@ struct ViewData {
};
std::vector<Shelf> shelves;
std::vector<std::string> legends;
+ std::string footer; // a sheet's pinned footer note (Installed games: the selection or the batch)
int focused_row = 0;
int focused_action = 0;
std::size_t total_count = 0;
@@ -709,6 +710,22 @@ private:
std::vector<GameId> pending_activity_requests_;
bool uninstall_delete_saves_ = false; // the uninstall dialog's choice
std::set<GameId> kept_selected_; // the kept game data manager's checked games
+ // Installed games (Settings > Storage): the checked games and the list's order.
+ std::set<GameId> installed_selected_;
+ bool installed_by_played_ = false; // false: largest first; true: never played, then the oldest
+ // The games the player uninstalled together from the list, while the list stays open: their
+ // size when confirmed and how each ended ("" while it runs, "Uninstalled" or the stop reason).
+ struct UninstallBatch {
+ std::vector<GameId> ids;
+ std::map<GameId, std::uint64_t> bytes;
+ std::map<GameId, std::string> stopped;
+ std::set<GameId> uninstalled;
+ };
+ std::optional<UninstallBatch> uninstall_batch_;
+ std::map<GameId, std::string> installed_stops_; // why games stopped in the batch last shown
+ std::string installed_list_focus_; // the game row the focus left for the footer
+ std::string installed_message_; // the list's note when a confirmed uninstall could not start
+ bool rebuilding_overlay_ = false; // rebuild_view is building the screen under an open sheet
struct StoreFacts { std::string description; std::vector<std::string> genres; std::string controller_support; };
std::map<GameId, StoreFacts> store_facts_; // live: from the Steam store, applied over library refreshes
std::vector<GameId> ready_prompts_; // games to announce as ready to play, oldest first
@@ -794,6 +811,15 @@ private:
void advance_jobs();
[[nodiscard]] std::vector<std::string> game_settings_actions() const;
[[nodiscard]] std::vector<std::string> kept_manager_actions() const;
+ // Installed games list: its games in the chosen order (those a running batch uninstalled
+ // included), why a game cannot be picked now (empty when it can), and the list's refresh.
+ [[nodiscard]] std::vector<GameId> installed_list() const;
+ [[nodiscard]] std::string installed_blocker(GameId id) const;
+ [[nodiscard]] std::vector<std::string> installed_manager_actions() const;
+ void refresh_installed_manager();
+ [[nodiscard]] bool installed_list_open() const;
+ [[nodiscard]] bool uninstall_batch_done() const;
+ void move_installed_manager(int delta_x, int delta_y);
[[nodiscard]] std::vector<std::string> collection_sheet_actions(const std::string& sheet) const;
void refresh_collection_sheets(const std::string& focus = {});
void refresh_game_settings();
diff --git a/src/homebrew/uninstall_flow.cpp b/src/homebrew/uninstall_flow.cpp
index ca2b1cf..db05eb1 100644
--- a/src/homebrew/uninstall_flow.cpp
+++ b/src/homebrew/uninstall_flow.cpp
@@ -79,6 +79,9 @@ UninstallAction UninstallFlow::Advance(GameId id, const UninstallFacts& facts) {
} else {
// Saves must not move, and the title must not run, while it is removed.
if (facts.saves_moving || facts.session_active) return {};
+ // The runtime counts removals for all games together, so only one may be in flight to tell whose finished.
+ for (const auto& [other_id, other] : entries_)
+ if (other_id != id && other.remove_sent) return {};
entry.remove_sent = true;
entry.removals_before = facts.removals_handled;
return {UninstallAction::Kind::kRemoveTitle, entry.delete_saves, {}};
diff --git a/src/homebrew/view.cpp b/src/homebrew/view.cpp
index e236006..37faf76 100644
--- a/src/homebrew/view.cpp
+++ b/src/homebrew/view.cpp
@@ -1948,50 +1948,7 @@ class Render::Impl
break;
}
++drawn;
- const std::uint64_t unused = volume.capacity_bytes - std::min(volume.used_bytes, volume.capacity_bytes);
- const std::uint64_t free = unused - std::min(volume.reserved_bytes, unused);
- const float fraction = volume.capacity_bytes == 0 ? 0.0F :
- static_cast<float>(volume.used_bytes) / static_cast<float>(volume.capacity_bytes);
- const float reserved = volume.capacity_bytes == 0 ? 0.0F :
- static_cast<float>(volume.reserved_bytes) / static_cast<float>(volume.capacity_bytes);
- ui::text(scene_, fonts_.display, volume.label, 1200.0F, y, 30.0F, kText);
- const bool is_default = !state.simulation_mode && volume.id == state.default_volume_id;
- ui::text(scene_, fonts_.regular,
- volume.available ? (volume.writable ? (is_default ? "Default · Available" : "Available") : "No write access")
- : "Disconnected",
- 1784.0F, y, 22.0F, volume.available && volume.writable ? kSecondary : kAmber,
- gfx::Align::right);
- if (!volume.capacity_known)
- {
- // A failed space query leaves capacity unknown: show only what Playden knows.
- ui::text(scene_, fonts_.regular, "Used by games " + short_size(volume.games_bytes),
- 1200.0F, y + 42.0F, 22.0F, kSecondary);
- // Space held for queued downloads, only when there is some.
- if (volume.reserved_bytes > 0)
- ui::text(scene_, fonts_.regular, "Reserved by queue " + short_size(volume.reserved_bytes),
- 1784.0F, y + 42.0F, 22.0F, kSecondary, gfx::Align::right);
- y += step;
- continue;
- }
- const float bar_x = 1200.0F;
- const float bar_y = y + 28.0F;
- const float bar_w = 584.0F;
- scene_.rounded_rect({bar_x, bar_y, bar_w, 12.0F}, 6.0F, kText.with_alpha(0.14F));
- scene_.rounded_rect({bar_x, bar_y, bar_w * std::clamp(fraction, 0.0F, 1.0F), 12.0F},
- 5.0F, volume.available ? kAccent : kMuted);
- scene_.rounded_rect({bar_x + bar_w * std::clamp(fraction, 0.0F, 1.0F), bar_y,
- bar_w * std::clamp(reserved, 0.0F, 1.0F - std::clamp(fraction, 0.0F, 1.0F)), 12.0F},
- 5.0F, volume.available ? kAmber : kMuted);
- ui::text(scene_, fonts_.regular, "Capacity " + short_size(volume.capacity_bytes),
- 1200.0F, y + 76.0F, 22.0F, kSecondary);
- ui::text(scene_, fonts_.regular, "Used " + short_size(volume.used_bytes),
- 1200.0F, y + 106.0F, 22.0F, kSecondary);
- if (volume.reserved_bytes > 0)
- ui::text(scene_, fonts_.regular, "Reserved " + short_size(volume.reserved_bytes),
- 1784.0F, y + 76.0F, 22.0F, kSecondary, gfx::Align::right);
- ui::text(scene_, fonts_.semibold, "Free " + short_size(free),
- 1784.0F, y + 106.0F, 22.0F, volume.available ? kText : kMuted,
- gfx::Align::right);
+ draw_volume_usage(volume, !state.simulation_mode && volume.id == state.default_volume_id, 1200.0F, y, 584.0F);
y += step;
}
if (any_unreported)
@@ -1999,6 +1956,54 @@ class Render::Impl
1200.0F, 912.0F, 22.0F, kMuted);
}
+ // A drive's bar: used space, then space reserved for queued downloads, over its capacity.
+ void draw_usage_bar(const Volume &volume, float x, float y, float width)
+ {
+ const float fraction = volume.capacity_bytes == 0 ? 0.0F :
+ static_cast<float>(volume.used_bytes) / static_cast<float>(volume.capacity_bytes);
+ const float reserved = volume.capacity_bytes == 0 ? 0.0F :
+ static_cast<float>(volume.reserved_bytes) / static_cast<float>(volume.capacity_bytes);
+ scene_.rounded_rect({x, y, width, 12.0F}, 6.0F, kText.with_alpha(0.14F));
+ scene_.rounded_rect({x, y, width * std::clamp(fraction, 0.0F, 1.0F), 12.0F}, 5.0F,
+ volume.available ? kAccent : kMuted);
+ scene_.rounded_rect({x + width * std::clamp(fraction, 0.0F, 1.0F), y,
+ width * std::clamp(reserved, 0.0F, 1.0F - std::clamp(fraction, 0.0F, 1.0F)), 12.0F},
+ 5.0F, volume.available ? kAmber : kMuted);
+ }
+
+ // One drive's usage: its name and state, then a bar of used and reserved space with the
+ // figures under it; without a space report only what Playden knows. `y` is the name's baseline.
+ void draw_volume_usage(const Volume &volume, bool is_default, float x, float y, float width)
+ {
+ const float right = x + width;
+ ui::text(scene_, fonts_.display, volume.label, x, y, 30.0F, kText);
+ ui::text(scene_, fonts_.regular,
+ volume.available ? (volume.writable ? (is_default ? "Default · Available" : "Available") : "No write access")
+ : "Disconnected",
+ right, y, 22.0F, volume.available && volume.writable ? kSecondary : kAmber, gfx::Align::right);
+ if (!volume.capacity_known)
+ {
+ // A failed space query leaves capacity unknown: show only what Playden knows.
+ ui::text(scene_, fonts_.regular, "Used by games " + short_size(volume.games_bytes), x, y + 42.0F, 22.0F,
+ kSecondary);
+ // Space held for queued downloads, only when there is some.
+ if (volume.reserved_bytes > 0)
+ ui::text(scene_, fonts_.regular, "Reserved by queue " + short_size(volume.reserved_bytes), right,
+ y + 42.0F, 22.0F, kSecondary, gfx::Align::right);
+ return;
+ }
+ const std::uint64_t unused = volume.capacity_bytes - std::min(volume.used_bytes, volume.capacity_bytes);
+ const std::uint64_t free = unused - std::min(volume.reserved_bytes, unused);
+ draw_usage_bar(volume, x, y + 28.0F, width);
+ ui::text(scene_, fonts_.regular, "Capacity " + short_size(volume.capacity_bytes), x, y + 76.0F, 22.0F, kSecondary);
+ ui::text(scene_, fonts_.regular, "Used " + short_size(volume.used_bytes), x, y + 106.0F, 22.0F, kSecondary);
+ if (volume.reserved_bytes > 0)
+ ui::text(scene_, fonts_.regular, "Reserved " + short_size(volume.reserved_bytes), right, y + 76.0F, 22.0F,
+ kSecondary, gfx::Align::right);
+ ui::text(scene_, fonts_.semibold, "Free " + short_size(free), right, y + 106.0F, 22.0F,
+ volume.available ? kText : kMuted, gfx::Align::right);
+ }
+
// The macOS Settings screen: a rail of sections, then the focused section's rows, each
// with its title and summary and a toggle or a button on the right.
void draw_settings(ui::Canvas &, const ViewData &view, const State &state)
@@ -2040,7 +2045,18 @@ class Render::Impl
if (view.rows[static_cast<std::size_t>(index)].section == current &&
!view.rows[static_cast<std::size_t>(index)].rail_only)
rows.push_back(index);
- const auto height = [&](const ViewRow &row) { return row.subtitle.empty() ? 92.0F : 118.0F; };
+ // Games storage carries the default drive's usage under its title.
+ const Volume *usage = nullptr;
+ if (current == "Storage" && !state.volumes.empty())
+ {
+ const auto found = std::find_if(state.volumes.begin(), state.volumes.end(),
+ [&state](const Volume &volume) { return volume.id == state.default_volume_id; });
+ usage = found != state.volumes.end() ? &*found : &state.volumes.front();
+ }
+ const auto drive_row = [&](const ViewRow &row) { return usage != nullptr && row.key == "settings-storage"; };
+ const auto height = [&](const ViewRow &row) {
+ return drive_row(row) ? (usage->capacity_known ? 186.0F : 160.0F) : row.subtitle.empty() ? 92.0F : 118.0F;
+ };
float offset = 0.0F;
{
// Eased to the focused row like Home; with the focus on the rail the list stays where it was.
@@ -2068,6 +2084,8 @@ class Render::Impl
const ViewRow &row = view.rows[static_cast<std::size_t>(index)];
const float h = height(row);
const gfx::Rect card{left, y, width, h};
+ // The title, summary and control sit in the row's usual height; the drive's bar goes below.
+ const gfx::Rect head{left, y, width, drive_row(row) ? 118.0F : h};
const bool is_focused = route_focus_ && !rail && index == focused;
if (is_focused)
stats_.focused_control_key = row.key;
@@ -2078,7 +2096,7 @@ class Render::Impl
if (row.dangerous)
scene_.bordered_rect(card, 8.0F, kBackground.with_alpha(0.0F), 2.0F, kRed.with_alpha(0.35F));
const gfx::Color title_ink = !row.enabled ? kMuted : row.dangerous ? kRed : kText;
- const float title_y = row.subtitle.empty() ? card.cy() + 11.0F : card.y + 50.0F;
+ const float title_y = row.subtitle.empty() ? head.cy() + 11.0F : card.y + 50.0F;
ui::text(scene_, fonts_.display, fit(fonts_.display, row.title, 30.0F, 760.0F), card.x + 30.0F, title_y,
30.0F, title_ink);
if (!row.subtitle.empty())
@@ -2087,7 +2105,7 @@ class Render::Impl
const float right = card.x + card.w - 30.0F;
if (row.kind == RowKind::Toggle)
{
- const gfx::Rect track{right - 84.0F, card.cy() - 22.0F, 84.0F, 44.0F};
+ const gfx::Rect track{right - 84.0F, head.cy() - 22.0F, 84.0F, 44.0F};
scene_.rounded_rect(track, 22.0F, row.selected ? kAccent : kText.with_alpha(0.15F));
scene_.circle(row.selected ? track.x + track.w - 22.0F : track.x + 22.0F, track.cy(), 18.0F,
row.selected ? kBackground : kSecondary);
@@ -2095,7 +2113,7 @@ class Render::Impl
else if (!row.enabled || row.kind == RowKind::Status)
{
if (!row.value.empty())
- ui::text(scene_, fonts_.display, row.value, right, card.cy() + 9.0F, 26.0F, kMuted,
+ ui::text(scene_, fonts_.display, row.value, right, head.cy() + 9.0F, 26.0F, kMuted,
gfx::Align::right);
}
else
@@ -2103,13 +2121,40 @@ class Render::Impl
// "Manage ›" on macOS; the chevron is drawn, as the console fonts lack it.
const std::string label = row.value.empty() ? std::string(row.dangerous ? "Review" : "Open") : row.value;
const float pill = fonts_.display.measure(label, 26.0F) + 64.0F;
- const gfx::Rect button{right - pill, card.cy() - 28.0F, pill, 56.0F};
+ const gfx::Rect button{right - pill, head.cy() - 28.0F, pill, 56.0F};
scene_.bordered_rect(button, 8.0F, kBackground.with_alpha(0.0F), 2.0F, kText.with_alpha(0.2F));
ui::text(scene_, fonts_.display, label, button.x + 22.0F, button.cy() + 9.0F, 26.0F, kText);
const float chevron = button.x + button.w - 26.0F;
scene_.line(chevron - 3.0F, button.cy() - 6.0F, chevron + 2.5F, button.cy(), 2.2F, kText);
scene_.line(chevron + 2.5F, button.cy(), chevron - 3.0F, button.cy() + 6.0F, 2.2F, kText);
}
+ if (drive_row(row))
+ {
+ const float bar_x = card.x + 30.0F, bar_w = card.w - 60.0F;
+ float line_y = card.y + 132.0F;
+ std::string line;
+ if (usage->capacity_known)
+ {
+ const std::uint64_t unused = usage->capacity_bytes - std::min(usage->used_bytes, usage->capacity_bytes);
+ const std::uint64_t free = unused - std::min(usage->reserved_bytes, unused);
+ draw_usage_bar(*usage, bar_x, card.y + 116.0F, bar_w);
+ line = short_size(usage->used_bytes) + " used · " +
+ (usage->reserved_bytes > 0 ? short_size(usage->reserved_bytes) + " reserved · " : std::string()) +
+ short_size(free) + " free of " + short_size(usage->capacity_bytes);
+ line_y = card.y + 162.0F;
+ }
+ else
+ {
+ // Without a space report, only what Playden knows (as in Downloads).
+ line = short_size(usage->games_bytes) + " used by games" +
+ (usage->reserved_bytes > 0 ? " · " + short_size(usage->reserved_bytes) + " reserved" : std::string());
+ }
+ ui::text(scene_, fonts_.regular, line, bar_x, line_y, 22.0F, kSecondary);
+ // A drive that is gone or read-only says so, as in Downloads.
+ if (!usage->available || !usage->writable)
+ ui::text(scene_, fonts_.regular, usage->available ? "No write access" : "Disconnected", bar_x + bar_w,
+ line_y, 22.0F, kAmber, gfx::Align::right);
+ }
focus_ring(scene_, card, amount);
y += h + 24.0F;
}
@@ -3031,7 +3076,7 @@ class Render::Impl
{
static const std::map<std::string, std::string> names = {
{"choice-picker", "Game settings"}, {"preset-picker", "Game settings"}, {"button-mapping", "Game settings"},
- {"game-settings", "Playden"}, {"game-maintenance", "Playden"}, {"kept-data", "Settings"},
+ {"game-settings", "Playden"}, {"game-maintenance", "Playden"}, {"kept-data", "Settings"}, {"installed-games", "Settings"},
{"job-actions", "Downloads"}, {"context", "Game"}, {"compatibility", "Game"}, {"collections", "Game"}, {"collections-manage", "Library"},
{"filters", "Library"}, {"logs-controls", "Logs"}, {"setting-value", "Settings"}, {"diagnostics", "Settings"},
{"notices", "Notifications"}, {"qr-controls", "Sign in"}, {"session-controls", "Simulation"},
@@ -3053,7 +3098,8 @@ class Render::Impl
view.surface == "choice-picker" || view.surface == "preset-picker" ||
view.surface == "button-mapping" || view.surface == "game-maintenance" ||
view.surface == "controller" || view.surface == "logs" ||
- view.surface == "storage" || view.surface == "install" || view.surface == "kept-data";
+ view.surface == "storage" || view.surface == "install" || view.surface == "kept-data" ||
+ view.surface == "installed-games";
const float width = overlay_transition_.panel_width(wide ? 960.0F : 640.0F);
const gfx::Rect panel{kWidth - width + (1.0F - ease) * width, 0.0F, width, kHeight};
overlay_.shadow({panel.x - 18.0F, 0.0F, panel.w + 18.0F, panel.h}, 0.0F, 36.0F,
@@ -3071,6 +3117,8 @@ class Render::Impl
draw_log_overlay(view, {panel.x + 40.0F, 246.0F, panel.w - 80.0F, 710.0F});
else if (view.surface == "controller")
draw_controller_overlay(view, {panel.x + 40.0F, 236.0F, panel.w - 80.0F, 720.0F});
+ else if (view.surface == "installed-games")
+ draw_installed_games_sheet(view, panel);
else
draw_overlay_rows(view, {panel.x + 40.0F, view.surface == "install" ? 414.0F : 292.0F,
panel.w - 80.0F, view.surface == "install" ? 528.0F : 650.0F});
@@ -3413,7 +3461,77 @@ class Render::Impl
return {};
}
- void draw_overlay_rows(const ViewData &view, const gfx::Rect &bounds)
+ // Installed games: Sort and Select all pinned on top, the games scrolling under them, and a
+ // footer with the selection (or the batch) and Uninstall selected / Show all games / Close.
+ void draw_installed_games_sheet(const ViewData &view, const gfx::Rect &panel)
+ {
+ ViewData head = view, list = view;
+ head.rows.clear();
+ list.rows.clear();
+ head.focused_row = list.focused_row = -1;
+ std::vector<const ViewRow *> footer;
+ int footer_focus = -1;
+ for (int index = 0; index < static_cast<int>(view.rows.size()); ++index)
+ {
+ const ViewRow &row = view.rows[static_cast<std::size_t>(index)];
+ const bool focused = index == view.focused_row;
+ if (row.key == "installed-sort" || row.key == "installed-select-all")
+ {
+ if (focused) head.focused_row = static_cast<int>(head.rows.size());
+ head.rows.push_back(row);
+ }
+ else if (row.key.rfind("installed-toggle-", 0) == 0 || row.key.rfind("installed-step-", 0) == 0)
+ {
+ if (focused) list.focused_row = static_cast<int>(list.rows.size());
+ list.rows.push_back(row);
+ }
+ else
+ {
+ if (focused) footer_focus = static_cast<int>(footer.size());
+ footer.push_back(&row);
+ }
+ }
+ const float x = panel.x + 40.0F, w = panel.w - 80.0F;
+ const float head_h = head.rows.empty() ? 0.0F : head.rows.size() * 84.0F;
+ if (!head.rows.empty())
+ draw_overlay_rows(head, {x, 292.0F, w, head_h - 12.0F}, false);
+ // The list scrolls between the pinned rows and the footer and never draws under either.
+ constexpr float footer_top = 934.0F;
+ const float list_top = 292.0F + head_h + (head.rows.empty() ? 0.0F : 12.0F);
+ const float clip_top = head.rows.empty() ? list_top - 32.0F : list_top - 10.0F;
+ overlay_.push_clip({panel.x, clip_top, panel.w, footer_top - 8.0F - clip_top});
+ draw_overlay_rows(list, {x, list_top, w, footer_top - 40.0F - list_top});
+ overlay_.pop_clip();
+ overlay_.rounded_rect({panel.x, footer_top - 8.0F, panel.w, 1.0F}, 0.0F, kText.with_alpha(0.10F));
+ // Buttons from the right edge, in order; the note fills the space left of them.
+ float right = x + w;
+ std::vector<gfx::Rect> buttons(footer.size());
+ for (int index = static_cast<int>(footer.size()) - 1; index >= 0; --index)
+ {
+ const float button_w = fonts_.display.measure(footer[static_cast<std::size_t>(index)]->title, 26.0F) + 56.0F;
+ buttons[static_cast<std::size_t>(index)] = {right - button_w, footer_top + 14.0F, button_w, 60.0F};
+ right -= button_w + 16.0F;
+ }
+ if (!view.footer.empty())
+ ui::text(overlay_, fonts_.regular, fit(fonts_.regular, view.footer, 23.0F, right - x - 16.0F), x + 8.0F,
+ footer_top + 52.0F, 23.0F, kSecondary);
+ for (std::size_t index = 0; index < footer.size(); ++index)
+ {
+ const ViewRow &row = *footer[index];
+ const gfx::Rect &rect = buttons[index];
+ const float amount = control_focus("sheet-" + row.key, static_cast<int>(index) == footer_focus);
+ focus_glow(overlay_, rect, amount);
+ overlay_.rounded_rect(rect, 8.0F, kPanel);
+ overlay_.bordered_rect(rect, 8.0F, kText.with_alpha(0.04F), 2.0F,
+ (row.dangerous && row.enabled ? kRed : kText).with_alpha(row.enabled ? 0.35F : 0.12F));
+ ui::text(overlay_, fonts_.display, row.title, rect.cx(), rect.cy() + 10.0F, 26.0F,
+ !row.enabled ? kMuted : row.dangerous ? kRed : kText, gfx::Align::center);
+ focus_ring(overlay_, rect, amount);
+ }
+ }
+
+ // `scrolls` false: rows pinned in place (a sheet's fixed header), leaving the list's scroll alone.
+ void draw_overlay_rows(const ViewData &view, const gfx::Rect &bounds, bool scrolls = true)
{
const bool settings_sheet = view.surface == "game-settings" || view.surface == "choice-picker" ||
view.surface == "preset-picker" || view.surface == "button-mapping" ||
@@ -3425,9 +3543,9 @@ class Render::Impl
return 54.0F + 12.0F;
if (row.kind == RowKind::Heading || row.kind == RowKind::Separator)
return 54.0F;
- const bool checkbox = (view.surface == "kept-data" || (view.surface == "collections" && row.action.rfind("collection-toggle-", 0) == 0)) &&
+ const bool checkbox = (view.surface == "kept-data" || view.surface == "installed-games" || (view.surface == "collections" && row.action.rfind("collection-toggle-", 0) == 0)) &&
row.kind == RowKind::Toggle;
- const bool described = (settings_sheet || checkbox) && !row.subtitle.empty();
+ const bool described = (settings_sheet || checkbox || view.surface == "installed-games") && !row.subtitle.empty();
return (described ? 96.0F : 72.0F) + 12.0F;
};
std::vector<float> tops;
@@ -3438,13 +3556,13 @@ class Render::Impl
total += pitch(row);
}
const std::string scroll_key = view.surface + "\n" + view.title;
- if (scroll_key != sheet_scroll_key_)
+ if (scrolls && scroll_key != sheet_scroll_key_)
{
sheet_scroll_key_ = scroll_key;
sheet_scroll_ = sheet_scroll_target_ = 0.0F;
}
const float limit = std::max(0.0F, total - 12.0F - bounds.h);
- if (view.focused_row >= 0 && static_cast<std::size_t>(view.focused_row) < view.rows.size())
+ if (scrolls && view.focused_row >= 0 && static_cast<std::size_t>(view.focused_row) < view.rows.size())
{
const auto focused = static_cast<std::size_t>(view.focused_row);
const float context = 48.0F; // part of the next row stays visible
@@ -3455,11 +3573,15 @@ class Render::Impl
else if (bottom > sheet_scroll_target_ + bounds.h)
sheet_scroll_target_ = bottom - bounds.h;
}
- sheet_scroll_target_ = std::clamp(sheet_scroll_target_, 0.0F, limit);
- sheet_scroll_ = current_state_ && current_state_->reduced_motion ? sheet_scroll_target_
- : sheet_scroll_ + (sheet_scroll_target_ - sheet_scroll_) * std::min(1.0F, frame_dt_ * 14.0F);
- if (std::fabs(sheet_scroll_target_ - sheet_scroll_) < 0.5F)
- sheet_scroll_ = sheet_scroll_target_;
+ if (scrolls)
+ {
+ sheet_scroll_target_ = std::clamp(sheet_scroll_target_, 0.0F, limit);
+ sheet_scroll_ = current_state_ && current_state_->reduced_motion ? sheet_scroll_target_
+ : sheet_scroll_ + (sheet_scroll_target_ - sheet_scroll_) * std::min(1.0F, frame_dt_ * 14.0F);
+ if (std::fabs(sheet_scroll_target_ - sheet_scroll_) < 0.5F)
+ sheet_scroll_ = sheet_scroll_target_;
+ }
+ const float scroll = scrolls ? sheet_scroll_ : 0.0F;
// The clip reaches the panel's edges (the rows sit 40 px in) so a focused row's glow and
// zoom are never cut; above and below it leaves room for the glow too.
overlay_.push_clip({bounds.x - 40.0F, bounds.y - 32.0F, bounds.w + 80.0F, bounds.h + 64.0F});
@@ -3467,7 +3589,7 @@ class Render::Impl
for (int index = 0; index < static_cast<int>(view.rows.size()); ++index)
{
const ViewRow &row = view.rows[static_cast<std::size_t>(index)];
- float y = bounds.y + tops[static_cast<std::size_t>(index)] - sheet_scroll_;
+ float y = bounds.y + tops[static_cast<std::size_t>(index)] - scroll;
if (y + pitch(row) < bounds.y - 32.0F || y > bounds.y + bounds.h + 32.0F)
continue;
if (settings_sheet && row.kind == RowKind::Heading)
@@ -3494,9 +3616,9 @@ class Render::Impl
// Game settings rows carry an effect line under the name (or the reason a row is
// disabled), an accent dot when the player changed the value, and a tag.
// Kept game data: each game is a checkbox row with its kept date under the name.
- const bool checkbox = (view.surface == "kept-data" || (view.surface == "collections" && row.action.rfind("collection-toggle-", 0) == 0)) &&
+ const bool checkbox = (view.surface == "kept-data" || view.surface == "installed-games" || (view.surface == "collections" && row.action.rfind("collection-toggle-", 0) == 0)) &&
row.kind == RowKind::Toggle;
- const bool described = (settings_sheet || checkbox) && !row.subtitle.empty() && row.kind != RowKind::Heading;
+ const bool described = (settings_sheet || checkbox || view.surface == "installed-games") && !row.subtitle.empty() && row.kind != RowKind::Heading;
const gfx::Rect rect{bounds.x, y, bounds.w, described ? 96.0F : 72.0F};
const float amount = control_focus("sheet-" + row.key, index == view.focused_row);
focus_glow(overlay_, rect, amount);
@@ -3518,7 +3640,7 @@ class Render::Impl
overlay_.line(box.x + 12.0F, box.y + 20.0F, box.x + 22.0F, box.y + 8.0F, 3.0F, theme_.on_primary);
}
else
- overlay_.bordered_rect(box, 6.0F, kPanel.with_alpha(0.0F), 2.0F, kText.with_alpha(0.45F));
+ overlay_.bordered_rect(box, 6.0F, kPanel.with_alpha(0.0F), 2.0F, kText.with_alpha(row.enabled ? 0.45F : 0.18F));
name_x += 44.0F;
}
if (row.modified)
@@ -3526,11 +3648,13 @@ class Render::Impl
overlay_.circle(name_x + 5.0F, name_y - 9.0F, 5.0F, kAccent);
name_x += 20.0F;
}
- const std::string label = fit(fonts_.display, overlay_label(row), 28.0F, rect.w - 64.0F - value_width);
- ui::text(overlay_, fonts_.display, label, name_x, name_y, 28.0F, ink);
+ // Game names may need a fallback face (Greek, CJK, Arabic).
+ const ui::FontRef &face = font_for(overlay_label(row), fonts_.display);
+ const std::string label = fit(face, overlay_label(row), 28.0F, rect.w - 64.0F - value_width);
+ ui::text(overlay_, face, label, name_x, name_y, 28.0F, ink);
if (settings_sheet && !row.badge.empty() && row.kind != RowKind::Heading)
{
- const float tag_x = name_x + fonts_.display.measure(label, 28.0F) + 14.0F;
+ const float tag_x = name_x + face.measure(label, 28.0F) + 14.0F;
const float tag_w = fonts_.semibold.measure(ui::upper(row.badge), 13.0F) + 16.0F;
if (tag_x + tag_w < rect.x + rect.w - 40.0F - value_width)
{
@@ -3540,7 +3664,8 @@ class Render::Impl
}
if (described)
ui::text(overlay_, fonts_.regular, fit(fonts_.regular, row.subtitle, 19.0F, rect.w - 72.0F - value_width),
- checkbox ? name_x : rect.x + 24.0F, rect.y + 74.0F, 19.0F, row.enabled ? kSecondary : kMuted);
+ checkbox ? name_x : rect.x + 24.0F, rect.y + 74.0F, 19.0F,
+ row.tone == "problem" ? kRed : row.tone == "good" ? kGreen : row.enabled ? kSecondary : kMuted);
if (!value.empty())
ui::text(overlay_, fonts_.regular, fit(fonts_.regular, value, 22.0F, value_width), rect.x + rect.w - 24.0F,
described ? rect.y + 52.0F : rect.cy() + 8.0F, 22.0F,
diff --git a/tests/homebrew_controller_tour_test.cpp b/tests/homebrew_controller_tour_test.cpp
index 91807e3..b613bd9 100644
--- a/tests/homebrew_controller_tour_test.cpp
+++ b/tests/homebrew_controller_tour_test.cpp
@@ -16,11 +16,27 @@ static void require(bool okay, const char* message) {
static void press(Simulation& simulation, const char* key) {
require(simulation.action(key), key);
}
+// Settings: Up and Down stay in a section; another section is reached through the rail.
+static void enter_settings_section(playden::homebrew::Simulation& model, int index) {
+ using playden::homebrew::Route;
+ if (model.state().navigation.route != Route::Settings || !model.state().navigation.modals.empty()) return;
+ const auto& rows = model.view().rows;
+ const std::string wanted = rows[static_cast<std::size_t>(index)].section;
+ const auto here = [&] { return rows[static_cast<std::size_t>(model.view().focused_row)].section; };
+ if (here() == wanted) return;
+ std::vector<std::string> order;
+ for (const auto& row : rows) if (order.empty() || order.back() != row.section) order.push_back(row.section);
+ const auto position = [&](const std::string& section) { return std::find(order.begin(), order.end(), section) - order.begin(); };
+ model.action("left");
+ for (int step = 0; step < 16 && here() != wanted; ++step) model.action(position(here()) < position(wanted) ? "down" : "up");
+ model.action("right");
+}
static void choose(Simulation& simulation, const std::string& key) {
const auto& rows = simulation.view().rows;
const auto target = std::find_if(rows.begin(), rows.end(), [&](const ViewRow& row) { return row.key == key; });
if (target == rows.end()) { std::fprintf(stderr, "Unreachable controller row %s in %s\n", key.c_str(), simulation.view().surface.c_str()); std::exit(1); }
const int index = static_cast<int>(std::distance(rows.begin(), target));
+ enter_settings_section(simulation, index);
for (int count = 0; count < 100 && simulation.view().focused_row != index; ++count)
press(simulation, simulation.view().focused_row < index ? "down" : "up");
require(simulation.state().navigation.focus_key == key, "navigation reaches requested visible row");
diff --git a/tests/homebrew_library_graphical_test.cpp b/tests/homebrew_library_graphical_test.cpp
index 78db072..97a849e 100644
--- a/tests/homebrew_library_graphical_test.cpp
+++ b/tests/homebrew_library_graphical_test.cpp
@@ -41,6 +41,21 @@ struct Cache final : LibraryRepository {
};
}
+// Settings: Up and Down stay in a section; another section is reached through the rail.
+static void enter_settings_section(playden::homebrew::Simulation& model, int index) {
+ using playden::homebrew::Route;
+ if (model.state().navigation.route != Route::Settings || !model.state().navigation.modals.empty()) return;
+ const auto& rows = model.view().rows;
+ const std::string wanted = rows[static_cast<std::size_t>(index)].section;
+ const auto here = [&] { return rows[static_cast<std::size_t>(model.view().focused_row)].section; };
+ if (here() == wanted) return;
+ std::vector<std::string> order;
+ for (const auto& row : rows) if (order.empty() || order.back() != row.section) order.push_back(row.section);
+ const auto position = [&](const std::string& section) { return std::find(order.begin(), order.end(), section) - order.begin(); };
+ model.action("left");
+ for (int step = 0; step < 16 && here() != wanted; ++step) model.action(position(here()) < position(wanted) ? "down" : "up");
+ model.action("right");
+}
int main(int argc,char** argv) {
using namespace playden::homebrew;
if(argc!=2) return 2;
@@ -212,6 +227,68 @@ int main(int argc,char** argv) {
assert(live.action("cross"));
assert(live.action("focus:kept-toggle-43") && live.action("cross"));
capture_live("kept-manager.png");
+ // Settings > Storage: the default drive's usage above the rows, then the installed games list.
+ while(!live.state().navigation.modals.empty()) assert(live.action("circle"));
+ live.UpdateVolumes({{"internal","Console storage",true,825'000'000'000ull,512'000'000'000ull}}, "internal");
+ live.UpdateInstalls({}, {{42, 62'700'000'000ull, "internal"}, {43, 8'400'000'000ull, "internal"},
+ {44, 1'200'000'000ull, "internal"}});
+ LiveRuntimeGame playing; playing.game_id=44; playing.status="Ready"; playing.ready=true; playing.play_status="Playing";
+ LiveRuntimeGame titled=ready; titled.uninstall_status.clear();
+ live.UpdateRuntime(RuntimeState::Ready, {titled, playing});
+ assert(live.action("focus:settings-storage"));
+ capture_live("settings-storage-drive.png");
+ assert(live.action("focus:settings-installed"));
+ capture_live("settings-storage.png");
+ assert(live.action("cross"));
+ assert(live.action("focus:installed-toggle-43") && live.action("cross"));
+ capture_live("installed-games.png");
+ // A batch: one game stops on Cloud, the other is uninstalled; the list shows how each went.
+ assert(live.action("focus:installed-toggle-42") && live.action("cross"));
+ assert(live.action("focus:installed-selection-uninstall") && live.action("cross"));
+ capture_live("installed-games-confirm.png");
+ assert(live.action("focus:confirm-destructive") && live.action("cross"));
+ titled.uninstall_status="Removing PS5 title…";
+ live.UpdateRuntime(RuntimeState::Ready, {titled, playing});
+ capture_live("installed-games-progress.png");
+ live.NotifyUninstallStopped(43, "Cloud saves could not be synced. Fix them in Saves, then try again.");
+ titled.uninstall_status.clear();
+ live.UpdateRuntime(RuntimeState::Ready, {playing});
+ live.UpdateInstalls({}, {{43, 8'400'000'000ull, "internal"}, {44, 1'200'000'000ull, "internal"}});
+ capture_live("installed-games-done.png");
+ // With every Storage row shown the list scrolls; back on the first row the usage card shows again.
+ while(!live.state().navigation.modals.empty()) assert(live.action("circle"));
+ live.SetRuntimeLeftovers(1);
+ assert(live.action("focus:settings-runtime"));
+ capture_live("settings-storage-bottom.png");
+ while(live.state().navigation.focus_key!="settings-storage") assert(live.action("up"));
+ capture_live("settings-storage-top-again.png");
+ // A drive without a space report that is disconnected: one line and its state.
+ live.UpdateVolumes({{"internal","USB drive",false,{},{}}}, "internal");
+ capture_live("settings-storage-unknown.png");
+ }
+ {
+ // A long list: Sort and Select all stay on top and the footer stays visible mid-list.
+ Simulation many({}, {}, ModelMode::Live);
+ many.SetWallClock(1700000000);
+ many.UpdateAccount({AuthState::SignedIn,"123","Synthetic account",{},{},true});
+ std::vector<playden::GameSummary> summaries;
+ std::vector<LiveInstalledGame> installed;
+ for(int index=0; index<56; ++index) {
+ playden::GameSummary summary{static_cast<playden::GameId>(5000+index),"Synthetic game "+std::to_string(index+1),{},{},{}};
+ if(index%3) summary.last_played_unix_seconds=1700000000-static_cast<std::uint64_t>(index)*86400*5;
+ summaries.push_back(summary);
+ installed.push_back({static_cast<playden::GameId>(5000+index), (60ull-index)*700'000'000ull, "internal"});
+ }
+ assert(many.UpdateLibrary({summaries,false,{},false,false,{}}));
+ many.UpdateVolumes({{"internal","M.2 SSD",true,1'000'200'000'000ull,90'300'000'000ull}}, "internal");
+ many.UpdateInstalls({}, installed);
+ while(many.state().navigation.route!=Route::Settings) assert(many.action("r1"));
+ assert(many.action("focus:settings-installed") && many.action("cross"));
+ assert(many.action("focus:installed-toggle-5003") && many.action("cross"));
+ assert(many.action("focus:installed-toggle-5005") && many.action("cross"));
+ for(int step=0; step<14; ++step) assert(many.action("down"));
+ for(int i=0;i<24;++i) renderer.draw(many,1920,1080);
+ assert(renderer.capture_png(output/"installed-games-long.png",1920,1080));
}
{
// Rate and remaining time share the downloaded-size baseline, aligned to the card's right edge.
@@ -258,6 +335,7 @@ int main(int argc,char** argv) {
const auto& rows=model.view().rows;
const auto target=std::find_if(rows.begin(),rows.end(),[](const ViewRow& row){return row.action=="toggle-motion";});
assert(target!=rows.end());const int index=static_cast<int>(target-rows.begin());
+ enter_settings_section(model,index);
for(int n=0;n<80 && model.view().focused_row!=index;++n)assert(model.action(model.view().focused_row<index?"down":"up"));
assert(model.view().focused_row==index && model.action("cross"));
bridge.FlushAndShutdown();
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index 36812c6..ffd6499 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -1003,11 +1003,319 @@ void live_uninstall_removes_title_and_keeps_saves() {
check(model.state().navigation.focus_key == "settings-kept", "focus stays on the row");
}
+std::vector<std::string> installed_order(const Simulation& model) {
+ std::vector<std::string> order;
+ for (const auto& key : model.state().navigation.modals.back().action_keys)
+ if (key.rfind("installed-toggle-", 0) == 0) order.push_back(key.substr(17));
+ return order;
+}
+
+void live_storage_section_and_installed_games() {
+ using playden::homebrew::InstallRequestKind;
+ using playden::homebrew::JobState;
+ using playden::homebrew::LiveInstallJob;
+ using playden::homebrew::LiveRuntimeGame;
+ using playden::homebrew::RuntimeState;
+ constexpr std::int64_t now = 1'800'000'000;
+ constexpr std::int64_t day = 86'400;
+ constexpr std::uint64_t gb = 1'000'000'000;
+ auto model = make_live();
+ model.SetWallClock(now);
+ model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
+ model.UpdateVolumes({{"internal", "Console storage", true, 800 * gb, 500 * gb}}, "internal");
+
+ // Nothing installed: the Storage rows say so, and leftovers stay hidden.
+ model.action("l1");
+ check(model.state().navigation.route == Route::Settings, "Settings opens");
+ const auto section_of = [&model](const std::string& key) {
+ const auto* row = find_row(model, key);
+ return row ? row->section : std::string("missing");
+ };
+ for (const auto* key : {"settings-storage", "settings-installed", "settings-kept", "settings-runtime"})
+ check(section_of(key) == "Storage", "the storage rows are in the Storage section");
+ check(section_of("settings-title-store") == "Library" && section_of("settings-cloud-saves") == "Library",
+ "Library keeps its two toggles");
+ check(find_row(model, "settings-storage")->action == "storage-picker", "Games storage opens the drive picker");
+ std::vector<std::string> order;
+ for (const auto& row : model.view().rows) if (row.section == "Storage") order.push_back(row.key);
+ check(order == std::vector<std::string>{"settings-storage", "settings-installed", "settings-kept", "settings-runtime"},
+ "Storage lists its rows in order, without the hidden cleanup row");
+ std::vector<std::string> sections;
+ for (const auto& row : model.view().rows)
+ if (sections.empty() || sections.back() != row.section) sections.push_back(row.section);
+ check(sections == std::vector<std::string>{"Account", "Library", "Storage", "Display", "About", "Quit Playden"},
+ "the rail order is Account, Library, Storage, Display, About, Quit");
+ const auto* empty = find_row(model, "settings-installed");
+ check(empty && !empty->enabled && empty->value == "None", "nothing installed says None");
+ check(find_row(model, "settings-kept")->value == "None" && !has_row(model, "settings-runtime-cleanup"),
+ "kept data says None and the cleanup row is hidden");
+ model.SetRuntimeLeftovers(1);
+ order.clear();
+ for (const auto& row : model.view().rows) if (row.section == "Storage") order.push_back(row.key);
+ check(order == std::vector<std::string>{"settings-storage", "settings-installed", "settings-kept",
+ "settings-runtime-cleanup", "settings-runtime"},
+ "unused settings data sits before Runtime status when there is some");
+ model.SetRuntimeLeftovers(0);
+ // The Settings drive picker changes the default, not one install's drive.
+ activate(model, "settings-storage");
+ check(model.state().navigation.modals.back().id == "storage" &&
+ model.state().navigation.modals.back().title == "Choose storage", "Games storage opens the default picker");
+ model.action("circle");
+ // Up and Down stay in the section; the rail moves to another one.
+ check(model.action("focus:settings-storage"), "Games storage is focused");
+ model.action("up");
+ check(model.state().navigation.focus_key == "settings-storage" &&
+ model.view().rows[static_cast<std::size_t>(model.view().focused_row)].section == "Storage",
+ "Up on Storage's first row does not leave the section");
+ if (model.state().navigation.tabs_focused) model.action("down");
+ check(model.action("focus:settings-runtime"), "Runtime status is focused");
+ model.action("down");
+ check(model.state().navigation.focus_key == "settings-runtime", "Down on Storage's last row stays on it");
+ model.action("left");
+ model.action("down");
+ model.action("right");
+ check(model.state().navigation.focus_key == "settings-motion", "the rail moves to the next section");
+
+ const auto played = [&](playden::GameId id, std::string title, std::optional<std::int64_t> days) {
+ auto summary = game(id, std::move(title));
+ if (days) summary.last_played_unix_seconds = static_cast<std::uint64_t>(now - *days * day);
+ return summary;
+ };
+ check(model.UpdateLibrary({{played(10, "Alpha", 10), played(11, "Beta", std::nullopt), played(12, "Gamma", 100),
+ played(13, "Delta", 1), played(14, "Echo", 50), played(15, "Foxtrot", 30),
+ played(16, "Golf", 20)}, false, {}, false, false, {}}), "library loaded");
+ model.UpdateInstalls({LiveInstallJob{15, JobState::Queued, 0, gb, {}, "internal"}},
+ {{10, 5 * gb, "internal"}, {11, 20 * gb, "internal"}, {12, 5 * gb, "internal"},
+ {13, 1 * gb, "internal"}, {14, 2 * gb, "internal"}, {15, 3 * gb, "internal"},
+ {16, 4 * gb, "internal"}});
+ LiveRuntimeGame titled; titled.game_id = 10; titled.status = "Ready"; titled.ready = true; titled.has_title = true;
+ LiveRuntimeGame running; running.game_id = 14; running.status = "Ready"; running.ready = true; running.play_status = "Playing";
+ LiveRuntimeGame preparing; preparing.game_id = 16; preparing.status = "Preparing";
+ model.UpdateRuntime(RuntimeState::Ready, {titled, running, preparing});
+ const auto* entry = find_row(model, "settings-installed");
+ check(entry && entry->enabled && entry->value == "7 games · 40.0 GB", "the row counts installed games and size");
+
+ // Largest first, ties by title; then never played first and the longest unplayed after.
+ activate(model, "settings-installed");
+ check(model.state().navigation.modals.back().id == "installed-games", "the row opens the installed games list");
+ check(model.state().navigation.focus_key == "installed-toggle-11", "focus starts on the first game");
+ check(installed_order(model) == std::vector<std::string>{"11", "10", "12", "16", "15", "14", "13"}, "sorted by size");
+ check(find_row(model, "installed-sort")->value == "Size", "the sort row names the order");
+ const auto* alpha = find_row(model, "installed-toggle-10");
+ check(alpha && alpha->kind == RowKind::Toggle && alpha->title == "Alpha" && alpha->value == "5.0 GB" &&
+ alpha->subtitle == "Played 10 days ago" && alpha->enabled && !alpha->selected,
+ "a game row shows its size and when it was last played");
+ check(find_row(model, "installed-toggle-11")->subtitle == "Never played", "a game never played says so");
+ activate(model, "installed-sort");
+ check(find_row(model, "installed-sort")->value == "Last played" && model.state().navigation.focus_key == "installed-sort",
+ "Sort switches to last played and keeps the focus");
+ check(installed_order(model) == std::vector<std::string>{"11", "12", "14", "15", "16", "10", "13"},
+ "never played first, then the oldest");
+ activate(model, "installed-sort");
+
+ // Games that can't go now say why and can't be checked.
+ const auto* echo = find_row(model, "installed-toggle-14");
+ const auto* foxtrot = find_row(model, "installed-toggle-15");
+ const auto* golf = find_row(model, "installed-toggle-16");
+ check(echo && !echo->enabled && echo->subtitle == "Playing", "a running game is blocked");
+ check(foxtrot && !foxtrot->enabled && foxtrot->subtitle == "In Downloads", "a game with a download is blocked");
+ check(golf && !golf->enabled && golf->subtitle == "Busy", "a game being prepared is blocked");
+ activate(model, "installed-toggle-14");
+ check(!find_row(model, "installed-toggle-14")->selected, "a blocked game can't be checked");
+ check(!find_row(model, "installed-selection-uninstall")->enabled, "nothing to uninstall until a game is checked");
+ activate(model, "installed-select-all");
+ for (const auto* key : {"installed-toggle-10", "installed-toggle-11", "installed-toggle-12", "installed-toggle-13"})
+ check(find_row(model, key)->selected, "Select all checks every game that can go");
+ for (const auto* key : {"installed-toggle-14", "installed-toggle-15", "installed-toggle-16"})
+ check(!find_row(model, key)->selected, "Select all skips blocked games");
+ check(find_row(model, "installed-select-all")->title == "Clear selection", "with all checked it clears instead");
+ check(model.view().footer == "4 selected · 31.0 GB", "the footer names how many and how much");
+ // A game that starts running leaves the selection.
+ running.game_id = 13;
+ model.UpdateRuntime(RuntimeState::Ready, {titled, running, preparing});
+ check(!find_row(model, "installed-toggle-13")->selected && find_row(model, "installed-toggle-13")->subtitle == "Playing",
+ "a game that becomes blocked leaves the selection");
+ running.game_id = 14;
+ model.UpdateRuntime(RuntimeState::Ready, {titled, running, preparing});
+ activate(model, "installed-select-all");
+ activate(model, "installed-select-all");
+ check(!find_row(model, "installed-toggle-10")->selected, "Clear selection unchecks every game");
+
+ // A batch of three: the confirmation names them and the space, with the saves choice.
+ activate(model, "installed-toggle-10");
+ activate(model, "installed-toggle-11");
+ activate(model, "installed-toggle-12");
+ activate(model, "installed-selection-uninstall");
+ const auto& confirm = model.state().navigation.modals.back();
+ check(confirm.destructive && confirm.title == "Uninstall 3 games?", "the confirmation counts the games");
+ check(confirm.body.find("Beta, Alpha and Gamma. Frees about 30.0 GB.") == 0, "it names them and the space freed");
+ check(confirm.body.find("Steam Cloud saves are synced first. If that fails for a game, that game stays installed and its "
+ "row says why.") != std::string::npos, "Cloud is synced first, and a failure keeps that game");
+ const auto* saves = find_row(model, "uninstall-delete-saves");
+ check(saves && !saves->selected, "deleting saves is a choice, off by default");
+ activate(model, "uninstall-delete-saves");
+ check(model.state().navigation.modals.back().body.find("saves and settings on this console are deleted") != std::string::npos,
+ "the dialog says the saves go when the choice is on");
+ activate(model, "cancel");
+ check(model.TakeInstallRequests().empty() && model.state().navigation.modals.back().id == "installed-games",
+ "Cancel uninstalls nothing and returns to the list");
+ activate(model, "installed-selection-uninstall");
+ activate(model, "confirm-destructive");
+ auto requests = model.TakeInstallRequests();
+ check(requests.size() == 3 && requests[0].game_id == 11 && requests[1].game_id == 10 && requests[2].game_id == 12 &&
+ std::all_of(requests.begin(), requests.end(), [](const auto& request) {
+ return request.kind == InstallRequestKind::Uninstall && !request.delete_saves;
+ }),
+ "each checked game is uninstalled, keeping its saves");
+ check(model.state().navigation.modals.size() == 1 && model.state().navigation.modals.back().id == "installed-games",
+ "the list stays open as the progress view");
+ // While the batch runs the list shows only its games, in the batch's order, as status rows.
+ check(model.state().navigation.modals.back().action_keys ==
+ std::vector<std::string>{"installed-step-11", "installed-step-10", "installed-step-12", "installed-close"},
+ "the batch view lists only the batch's games, then Close");
+ check(!has_row(model, "installed-sort") && !has_row(model, "installed-select-all") &&
+ !has_row(model, "installed-toggle-13"), "Sort, Select all and the other games are hidden");
+ check(model.state().navigation.focus_key == "installed-step-11", "focus is on the batch's first game");
+ check(model.view().footer == "Uninstalling 1 of 3…", "the footer says how far the batch is");
+ check(model.view().subtitle == "Uninstalling the selected games.", "the header says what the list shows");
+ const auto* waiting = find_row(model, "installed-step-12");
+ check(waiting && waiting->kind == RowKind::Status && waiting->subtitle == "Waiting" && waiting->value == "5.0 GB",
+ "a game not started yet waits, without a checkbox");
+ const auto batch_notices = model.state().notices.size();
+ check(!model.action("triangle") || model.TakeInstallRequests().empty(), "Triangle starts nothing in the batch view");
+ titled.uninstall_status = "Syncing saves…";
+ model.UpdateRuntime(RuntimeState::Ready, {titled, running, preparing});
+ check(find_row(model, "installed-step-10")->subtitle == "Syncing saves…", "a row shows its game's uninstall step");
+
+ // One stops on Cloud: its row says why, without a notice.
+ const auto notices = batch_notices;
+ model.NotifyUninstallStopped(12, "Cloud saves could not be synced.");
+ check(model.state().notices.size() == notices && model.state().navigation.modals.back().id == "installed-games",
+ "a stop in the batch posts no notice");
+ const auto* stopped = find_row(model, "installed-step-12");
+ check(stopped && stopped->subtitle == "Stopped: Cloud saves could not be synced." && stopped->tone == "problem",
+ "the stopped game shows the reason");
+ check(model.view().footer == "Uninstalling 2 of 3…", "a stop counts as done");
+ check(!has_row(model, "installed-show-all"), "Show all games waits for the batch to finish");
+
+ // The other two finish: their rows say so and the totals count only them.
+ titled.uninstall_status.clear();
+ model.UpdateRuntime(RuntimeState::Ready, {running, preparing});
+ model.UpdateInstalls({LiveInstallJob{15, JobState::Queued, 0, gb, {}, "internal"}},
+ {{12, 5 * gb, "internal"}, {13, 1 * gb, "internal"}, {14, 2 * gb, "internal"},
+ {15, 3 * gb, "internal"}, {16, 4 * gb, "internal"}});
+ check(model.state().notices.size() == notices, "the batch posts no Game uninstalled notices");
+ const auto* gone = find_row(model, "installed-step-11");
+ check(gone && gone->subtitle == "Uninstalled" && gone->tone == "good" && gone->value == "20.0 GB", "an uninstalled game says so");
+ check(model.view().footer == "2 uninstalled · about 25.0 GB freed · 1 stopped", "the totals count freed space and stops");
+ check(model.state().navigation.modals.back().action_keys.size() == 5 && has_row(model, "installed-show-all") &&
+ find_row(model, "installed-show-all")->title == "Show all games",
+ "a finished batch offers Show all games beside Close");
+ check(model.view().subtitle == "Finished uninstalling.", "the header says the batch is done");
+ check(model.view().legends == std::vector<std::string>{"Circle Close"}, "a status row offers no Cross");
+ check(model.action("focus:installed-show-all"), "Show all games is focused");
+ check(model.view().legends == std::vector<std::string>{"Cross Choose", "Circle Close"}, "a footer button offers Cross");
+
+ // Show all games returns to the installed games; the stopped one keeps its reason and can go again.
+ activate(model, "installed-show-all");
+ check(installed_order(model) == std::vector<std::string>{"12", "16", "15", "14", "13"},
+ "the full list shows what is installed now, without the uninstalled games");
+ check(model.state().navigation.focus_key == "installed-toggle-12", "focus is on the first game");
+ check(find_row(model, "installed-toggle-12")->enabled &&
+ find_row(model, "installed-toggle-12")->subtitle == "Stopped: Cloud saves could not be synced.",
+ "the stopped game says why and can be chosen");
+ activate(model, "installed-toggle-12");
+ check(model.view().footer == "1 selected · 5.0 GB", "the footer sums the selection");
+ activate(model, "installed-selection-uninstall");
+ check(model.state().navigation.modals.back().title == "Uninstall 1 game?", "the retry asks for the one game");
+ activate(model, "confirm-destructive");
+ requests = model.TakeInstallRequests();
+ check(requests.size() == 1 && requests[0].game_id == 12, "the stopped game is uninstalled again");
+ check(model.view().footer == "Uninstalling 1 of 1…" && find_row(model, "installed-step-12")->subtitle == "Waiting",
+ "the retry is a batch of its own");
+ model.UpdateInstalls({LiveInstallJob{15, JobState::Queued, 0, gb, {}, "internal"}},
+ {{13, 1 * gb, "internal"}, {14, 2 * gb, "internal"}, {15, 3 * gb, "internal"},
+ {16, 4 * gb, "internal"}});
+ check(model.view().footer == "1 uninstalled · about 5.0 GB freed", "the retry's totals");
+ activate(model, "installed-show-all");
+ check(!has_row(model, "installed-toggle-12"), "the uninstalled game leaves the list");
+
+ // The footer is reached from the last game and left again; Left/Right move between its buttons.
+ check(model.action("focus:installed-toggle-13"), "the last game is focused");
+ model.action("down");
+ check(model.state().navigation.focus_key == "installed-selection-uninstall", "Down from the last game reaches the footer");
+ model.action("right");
+ check(model.state().navigation.focus_key == "installed-close", "Right moves to Close");
+ model.action("down");
+ check(model.state().navigation.focus_key == "installed-close", "Down in the footer stays");
+ model.action("up");
+ check(model.state().navigation.focus_key == "installed-toggle-13", "Up returns to the game the focus left");
+ check(model.action("focus:installed-toggle-16"), "a game mid-list is focused");
+ model.action("up");
+ model.action("up");
+ check(model.state().navigation.focus_key == "installed-sort", "Up from the first game reaches the pinned Sort row");
+
+ // Triangle is Uninstall selected from anywhere in the list, and nothing without a selection.
+ check(model.action("focus:installed-toggle-16"), "a game is focused");
+ model.action("triangle");
+ check(model.state().navigation.modals.back().id == "installed-games" && model.TakeInstallRequests().empty(),
+ "Triangle does nothing with nothing checked");
+ activate(model, "installed-toggle-13");
+ check(model.action("focus:installed-toggle-16"), "a game is focused");
+ model.action("triangle");
+ check(model.state().navigation.modals.back().title == "Uninstall 1 game?", "Triangle opens the confirmation");
+ activate(model, "cancel");
+ check(model.state().navigation.focus_key == "installed-toggle-16", "cancelling returns to the row the player was on");
+ activate(model, "installed-toggle-13");
+
+ // Every checked game became blocked while the dialog was open: nothing goes, and the list says so.
+ model.action("circle");
+ activate(model, "settings-installed");
+ activate(model, "installed-toggle-13");
+ activate(model, "installed-selection-uninstall");
+ running.game_id = 13;
+ model.UpdateRuntime(RuntimeState::Ready, {running, preparing});
+ activate(model, "confirm-destructive");
+ check(model.TakeInstallRequests().empty() && model.view().subtitle == "None of the selected games can be uninstalled now.",
+ "without a batch the list says nothing could go");
+
+ // Closing the list ends the batch: later stops are notices again.
+ const auto* close = find_row(model, "installed-close");
+ check(close && close->title == "Close", "the list closes with Close");
+ activate(model, "installed-close");
+ check(model.state().navigation.modals.empty(), "the list closes");
+ check(find_row(model, "settings-installed")->value == "4 games · 10.0 GB", "the Settings row follows");
+ model.NotifyUninstallStopped(13, "Cloud saves could not be synced.");
+ check(!model.state().navigation.modals.empty() && model.state().navigation.modals.back().title == "Uninstall stopped",
+ "after the list closes a stop is told as before");
+ model.action("circle");
+
+ // Without a batch the list follows the installs, and closes when none is left.
+ model.UpdateRuntime(RuntimeState::Ready, {});
+ model.UpdateVolumes({{"internal", "Console storage", true, 800 * gb, 500 * gb}, {"usb0", "USB drive", true, {}, {}}},
+ "internal");
+ model.UpdateInstalls({}, {{12, 5 * gb, "internal"}, {13, 1 * gb, "usb0"}});
+ activate(model, "settings-installed");
+ check(installed_order(model) == std::vector<std::string>{"12", "13"}, "the list shows what is installed now");
+ check(find_row(model, "installed-toggle-13")->subtitle == "USB drive · Played yesterday" &&
+ find_row(model, "installed-toggle-12")->subtitle == "Console storage · Played 100 days ago",
+ "with games on two drives each row names its drive");
+ check(model.action("focus:installed-toggle-13"), "the last game is focused");
+ model.UpdateInstalls({}, {{12, 5 * gb, "internal"}});
+ check(installed_order(model) == std::vector<std::string>{"12"}, "the list follows an uninstall that finished");
+ check(model.state().navigation.focus_key == "installed-toggle-12", "focus moves to the nearest game, not the footer");
+ model.UpdateInstalls({}, {});
+ check(model.state().navigation.modals.empty(), "the list closes when nothing is installed");
+ entry = find_row(model, "settings-installed");
+ check(entry && entry->value == "None" && !entry->enabled, "nothing installed says None");
+}
+
void live_settings_focus_stays_near_a_removed_row() {
auto model = make_live();
model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
check(model.UpdateLibrary({{game(42, "Synthetic")}, false, {}, false, false, {}}), "library loaded");
model.SetRuntimeLeftovers(2);
+ model.UpdateVolumes({{"internal", "Console storage", true, {}, {}}}, "internal");
model.action("l1");
activate(model, "settings-runtime-cleanup");
check(!model.TakeRuntimeCleanupRequest() && !model.state().navigation.modals.empty() &&
@@ -1021,7 +1329,7 @@ void live_settings_focus_stays_near_a_removed_row() {
const auto& rows = model.view().rows;
const auto focused = rows[static_cast<std::size_t>(model.view().focused_row)];
check(!has_row(model, "settings-runtime-cleanup"), "the cleaned row is gone");
- check(focused.section == "Library" && !focused.rail_only && !model.state().navigation.settings_rail_focused,
+ check(focused.section == "Storage" && !focused.rail_only && !model.state().navigation.settings_rail_focused,
"focus moves to the nearest row in the same section, not the rail");
check(focused.enabled, "a row that can be chosen is preferred");
}
@@ -1584,6 +1892,7 @@ int main() {
live_ready_to_play_quits_to_home();
live_details_focus_moves_to_play_once_enabled();
live_settings_focus_stays_near_a_removed_row();
+ live_storage_section_and_installed_games();
preparation_steps_read_as_player_words();
live_install_requests_and_projection();
live_install_volumes();
diff --git a/tests/homebrew_persistence_integration_test.cpp b/tests/homebrew_persistence_integration_test.cpp
index 1e9cc54..bc7f2b3 100644
--- a/tests/homebrew_persistence_integration_test.cpp
+++ b/tests/homebrew_persistence_integration_test.cpp
@@ -48,10 +48,26 @@ template<class F> void Wait(Controller& controller,F predicate) {
do {controller.Tick();if(predicate())return;std::this_thread::sleep_for(1ms);}while(std::chrono::steady_clock::now()<until);
assert(false && "persistence integration deadline");
}
+// Settings: Up and Down stay in a section; another section is reached through the rail.
+static void enter_settings_section(playden::homebrew::Simulation& model, int index) {
+ using playden::homebrew::Route;
+ if (model.state().navigation.route != Route::Settings || !model.state().navigation.modals.empty()) return;
+ const auto& rows = model.view().rows;
+ const std::string wanted = rows[static_cast<std::size_t>(index)].section;
+ const auto here = [&] { return rows[static_cast<std::size_t>(model.view().focused_row)].section; };
+ if (here() == wanted) return;
+ std::vector<std::string> order;
+ for (const auto& row : rows) if (order.empty() || order.back() != row.section) order.push_back(row.section);
+ const auto position = [&](const std::string& section) { return std::find(order.begin(), order.end(), section) - order.begin(); };
+ model.action("left");
+ for (int step = 0; step < 16 && here() != wanted; ++step) model.action(position(here()) < position(wanted) ? "down" : "up");
+ model.action("right");
+}
void Choose(Simulation& model,const std::string& action) {
const auto& rows=model.view().rows;
const auto found=std::find_if(rows.begin(),rows.end(),[&](const ViewRow& r){return r.action==action;});assert(found!=rows.end());
const int index=static_cast<int>(found-rows.begin());
+ enter_settings_section(model,index);
for(int n=0;n<80 && model.view().focused_row!=index;++n)assert(model.action(model.view().focused_row<index?"down":"up"));
assert(model.view().focused_row==index && model.action("cross"));
}
diff --git a/tests/homebrew_simulation_test.cpp b/tests/homebrew_simulation_test.cpp
index 5979837..c83d31b 100644
--- a/tests/homebrew_simulation_test.cpp
+++ b/tests/homebrew_simulation_test.cpp
@@ -706,15 +706,27 @@ void t13_settings_sections_rail(const std::filesystem::path& fixtures, const std
simulation.action("left");
check(simulation.state().navigation.settings_rail_focused, "T13 Left moves to the section rail");
simulation.action("down");
- check(section() == "Library" && simulation.state().navigation.focus_key == "settings-storage",
+ check(section() == "Storage" && simulation.state().navigation.focus_key == "settings-storage",
"T13 Down on the rail switches to the next section's first row");
simulation.action("cross");
check(!simulation.state().navigation.settings_rail_focused && simulation.state().navigation.focus_key == "settings-storage",
"T13 Cross on the rail enters the section without activating its row");
simulation.action("down");
simulation.action("down");
+ check(section() == "Storage" && simulation.state().navigation.focus_key == "settings-runtime",
+ "T13 Down on a section's last row stays in the section");
+ simulation.action("up");
+ check(section() == "Storage" && simulation.state().navigation.focus_key == "settings-storage" &&
+ !simulation.state().navigation.tabs_focused, "T13 Up stops on the section's first row");
+ simulation.action("up");
+ check(simulation.state().navigation.focus_key == "settings-storage" && simulation.state().navigation.tabs_focused,
+ "T13 Up on a section's first row goes to the tab bar, not the previous section");
+ simulation.action("down");
+ simulation.action("left");
+ simulation.action("down");
+ simulation.action("right");
check(section() == "Display" && simulation.state().navigation.focus_key == "settings-motion",
- "T13 Down past a section's last row continues into the next section");
+ "T13 the rail moves to the next section");
simulation.action("left");
simulation.action("right");
check(!simulation.state().navigation.settings_rail_focused && simulation.state().navigation.focus_key == "settings-motion",
diff --git a/tests/homebrew_uninstall_flow_test.cpp b/tests/homebrew_uninstall_flow_test.cpp
index 974400a..b42729b 100644
--- a/tests/homebrew_uninstall_flow_test.cpp
+++ b/tests/homebrew_uninstall_flow_test.cpp
@@ -103,6 +103,59 @@ int main() {
flow.TakeSyncRequests();
flow.SyncDispatched(48);
CHECK(flow.CloudSettled(48, CloudStatus::Unsupported).kind == Kind::kNone && flow.Step(48) == UninstallStep::kRemoveTitle);
+
+ // Two uninstalls: one PS5 title removal at a time, because the runtime counts removals for all games together.
+ CHECK(flow.Begin(60, false, false) && flow.Begin(61, false, false));
+ UninstallFacts both;
+ both.has_title = true;
+ both.removals_handled = 5;
+ CHECK(flow.Advance(60, both).kind == Kind::kRemoveTitle);
+ CHECK(flow.Advance(61, both).kind == Kind::kNone && flow.Step(61) == UninstallStep::kRemoveTitle);
+ // The first removal finishes while the second game is still queued: it must not read that as its own result.
+ UninstallFacts first_done;
+ first_done.removals_handled = 6;
+ both.removals_handled = 6;
+ CHECK(flow.Advance(61, both).kind == Kind::kNone);
+ CHECK(flow.Advance(60, first_done).kind == Kind::kRemoveDownload);
+ // Now the second removal goes, and only its own completion moves it on.
+ action = flow.Advance(61, both);
+ CHECK(action.kind == Kind::kRemoveTitle);
+ CHECK(flow.Advance(61, both).kind == Kind::kNone && flow.Step(61) == UninstallStep::kRemoveTitle);
+ both.removing = true;
+ CHECK(flow.Advance(61, both).kind == Kind::kNone);
+ UninstallFacts second_done;
+ second_done.removals_handled = 7;
+ CHECK(flow.Advance(61, second_done).kind == Kind::kRemoveDownload);
+ CHECK(!flow.Step(60) && !flow.Step(61));
+
+ // A stopped removal frees the slot for the waiting game.
+ CHECK(flow.Begin(62, false, false) && flow.Begin(63, false, false));
+ UninstallFacts stuck;
+ stuck.has_title = true;
+ CHECK(flow.Advance(62, stuck).kind == Kind::kRemoveTitle);
+ CHECK(flow.Advance(63, stuck).kind == Kind::kNone);
+ stuck.removals_handled = 1;
+ CHECK(flow.Advance(62, stuck).kind == Kind::kStop);
+ stuck.removals_handled = 0;
+ CHECK(flow.Advance(63, stuck).kind == Kind::kRemoveTitle);
+ UninstallFacts done;
+ done.removals_handled = 1;
+ CHECK(flow.Advance(63, done).kind == Kind::kRemoveDownload);
+
+ // One game's Cloud conflict stops only that game; the other goes on to its removal.
+ CHECK(flow.Begin(64, false, true) && flow.Begin(65, false, true));
+ CHECK(flow.TakeSyncRequests() == std::vector<GameId>({64, 65}));
+ flow.SyncDispatched(64);
+ flow.SyncDispatched(65);
+ CHECK(flow.CloudSettled(64, CloudStatus::Conflict).kind == Kind::kStop);
+ CHECK(!flow.Step(64) && flow.Step(65) == UninstallStep::kSync);
+ CHECK(flow.CloudSettled(65, CloudStatus::Synced).kind == Kind::kNone);
+ UninstallFacts after_sync;
+ after_sync.has_title = true;
+ CHECK(flow.Advance(65, after_sync).kind == Kind::kRemoveTitle);
+ after_sync = {};
+ after_sync.removals_handled = 1;
+ CHECK(flow.Advance(65, after_sync).kind == Kind::kRemoveDownload && !flow.Step(65));
std::puts("uninstall flow tests passed");
return 0;
}
diff --git a/tests/persistence_controller_test.cpp b/tests/persistence_controller_test.cpp
index 878652c..43a0aaa 100644
--- a/tests/persistence_controller_test.cpp
+++ b/tests/persistence_controller_test.cpp
@@ -99,6 +99,21 @@ void Connect(Simulation& model, PersistenceController& controller,
controller.Activate(account);
}
+// Settings: Up and Down stay in a section; another section is reached through the rail.
+static void enter_settings_section(playden::homebrew::Simulation& model, int index) {
+ using playden::homebrew::Route;
+ if (model.state().navigation.route != Route::Settings || !model.state().navigation.modals.empty()) return;
+ const auto& rows = model.view().rows;
+ const std::string wanted = rows[static_cast<std::size_t>(index)].section;
+ const auto here = [&] { return rows[static_cast<std::size_t>(model.view().focused_row)].section; };
+ if (here() == wanted) return;
+ std::vector<std::string> order;
+ for (const auto& row : rows) if (order.empty() || order.back() != row.section) order.push_back(row.section);
+ const auto position = [&](const std::string& section) { return std::find(order.begin(), order.end(), section) - order.begin(); };
+ model.action("left");
+ for (int step = 0; step < 16 && here() != wanted; ++step) model.action(position(here()) < position(wanted) ? "down" : "up");
+ model.action("right");
+}
void Choose(Simulation& model, const std::string& action) {
const auto& rows = model.view().rows;
const auto found = std::find_if(rows.begin(), rows.end(),
@@ -107,6 +122,7 @@ void Choose(Simulation& model, const std::string& action) {
});
assert(found != rows.end());
const int target = static_cast<int>(found - rows.begin());
+ enter_settings_section(model, target);
for (int step = 0; step < 80 && model.view().focused_row != target; ++step)
assert(model.action(model.view().focused_row < target ? "down" : "up"));
assert(model.view().focused_row == target);