Play your Steam library's Windows games on a jailbroken PS5.
C++
Filter Uninstall in Manage installed games by drive
Leonardo Lobatoe50405085e4d
diff --git a/COMPATIBILITY.md b/COMPATIBILITY.mdindex 2ec4de5..2333f6a 100644--- a/COMPATIBILITY.md+++ b/COMPATIBILITY.md@@ -45,6 +45,7 @@ uses: Direct3D 8–11 goes through DXVK to Vulkan, and Direct3D 12 through vkd3d| [BioShock Remastered](https://store.steampowered.com/app/409710) | ✅ Works | 0.13 | — | Default settings, DualSense. ([#248](https://github.com/leolobato/playden-ps5/issues/248), firmware 13.60) || [Blades of Time](https://store.steampowered.com/app/208670) | ✅ Works | 0.10 | Dagor · D3D9 · 32-bit | Intro, main menu and Story with the controller. Playden removes its old Steam DRM (SteamStub 2.1). || [BLUE REVOLVER](https://store.steampowered.com/app/439490) | ✅ Works | 0.10 | LÖVE · OpenGL · 64-bit | Default settings. The intro, the language menu and the story opening work with the controller. The earlier PhysFS start-up failure no longer happens; its cause is unknown. Gameplay not tested on r6. |+| [Braid Anniversary Edition](https://store.steampowered.com/app/499180) | ✅ Works | 0.16 | — | Default settings. ([#333](https://github.com/leolobato/playden-ps5/pull/333)) || [BRAZILIAN DRUG DEALER BEFORE 4](https://store.steampowered.com/app/4241920) | ✅ Works | 0.13 | — · OpenGL · 64-bit | Default settings. ([#157](https://github.com/leolobato/playden-ps5/pull/157), firmware 13.00) || [Bread & Fred Demo](https://store.steampowered.com/app/1763200) | ✅ Works | 0.13 | — | Default settings. || [Broforce](https://store.steampowered.com/app/274190) | ✅ Works | 0.12 | — | Default settings, DualSense. Menus and play. ([#107](https://github.com/leolobato/playden-ps5/issues/107), firmware 13.42) |diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cppindex df8fa62..fd3d3b0 100644--- a/src/homebrew/simulation.cpp+++ b/src/homebrew/simulation.cpp@@ -1474,6 +1474,8 @@ std::vector<GameId> Simulation::manage_list(ManageTab tab) const {// Move: imported games have their own Copy/Move into Playden; Move from lists one drive's games.if (tab == ManageTab::Move && id.store == Store::kLocal) continue;if (tab == ManageTab::Move && !manage_move_from_id_.empty() && installation.volume_id != manage_move_from_id_) continue;+ if (tab == ManageTab::Uninstall && !manage_uninstall_from_id_.empty() && installation.volume_id != manage_uninstall_from_id_)+ continue;// Updates: installed Steam games whose update or new DLC Steam told of; their size is the download (an// unknown one sorts last).if (updates) {@@ -1535,8 +1537,8 @@ const Volume* volume_of(const State& state, const std::string& id) {// Where a row of Manage installed games sits: 0 the toolbar, 1 the games, 2 the footer, -1 not a stop.int manage_part(const ViewRow& row) {- if (row.key == "manage-move-from" || row.key == "manage-move-to" || row.key == "manage-select-all" || row.key == "manage-sort" ||- row.key == "manage-check")+ if (row.key == "manage-move-from" || row.key == "manage-move-to" || row.key == "manage-uninstall-from" ||+ row.key == "manage-select-all" || row.key == "manage-sort" || row.key == "manage-check")return 0;if (row.key.rfind("manage-toggle-", 0) == 0) return 1;if (row.key == "manage-primary") return 2;@@ -1558,6 +1560,7 @@ void Simulation::open_manage_games(ManageTab tab) {manage_message_.clear();manage_move_volume_id_.clear();manage_move_from_id_.clear();+ manage_uninstall_from_id_.clear();manage_return_focus_ = state_.navigation.focus_key;manage_return_route_ = state_.navigation.route == Route::ManageGames ? manage_return_route_ : state_.navigation.route;state_.navigation.route = Route::ManageGames;@@ -1807,6 +1810,28 @@ void Simulation::cycle_manage_move_from() {refresh_manage_games();}+// The drives Uninstall can narrow its list to: each connected drive with installed games, when there are two or more.+std::vector<const Volume*> Simulation::uninstall_from_volumes() const {+ std::vector<const Volume*> volumes;+ for (const auto& volume : state_.volumes)+ if (volume.available && std::any_of(state_.installations.begin(), state_.installations.end(), [&](const Installation& installation) {+ return installation.volume_id == volume.id;+ }))+ volumes.push_back(&volume);+ if (volumes.size() < 2) volumes.clear();+ return volumes;+}++// All drives, then each drive with games, then All drives again.+void Simulation::cycle_manage_uninstall_from() {+ const auto volumes = uninstall_from_volumes();+ const auto at = std::find_if(volumes.begin(), volumes.end(), [this](const Volume* volume) { return volume->id == manage_uninstall_from_id_; });+ if (manage_uninstall_from_id_.empty() && !volumes.empty()) manage_uninstall_from_id_ = volumes.front()->id;+ else if (at == volumes.end() || at + 1 == volumes.end()) manage_uninstall_from_id_.clear();+ else manage_uninstall_from_id_ = (*(at + 1))->id;+ refresh_manage_games();+}+// The old copy stays until the new one is checked, so the destination needs room for every checked game,// with the margin the install service keeps.Simulation::ManageMoves Simulation::manage_moves() const {@@ -1898,6 +1923,9 @@ void Simulation::refresh_manage_games() {if (state_.navigation.route != Route::ManageGames) return;// A drive that went or became read-only is no longer the Move tab's destination.choose_manage_move_volume();+ // A drive that went no longer narrows Uninstall's list; one whose games are all gone stays, and says so.+ if (const auto* chosen = volume_of(state_, manage_uninstall_from_id_); !chosen || !chosen->available)+ manage_uninstall_from_id_.clear();for (const auto tab : kManageTabs) {auto& state = manage_tabs_[tab];const auto games = manage_list(tab);@@ -2023,6 +2051,11 @@ void Simulation::build_manage_games_view() {auto& move_to = row("manage-move-to", RowKind::Action, "Move to", "manage-move-to");move_to.enabled = move_volumes().size() >= 2;move_to.value = !move_to.enabled ? "No other drive" : destination ? destination->label : "No drive";+ } else if (!updates && (!uninstall_from_volumes().empty() || volume_of(state_, manage_uninstall_from_id_))) {+ // Drive narrows the list to one drive's games, to free room on that drive.+ auto& drive = row("manage-uninstall-from", RowKind::Action, "Drive", "manage-uninstall-from");+ const auto* source = volume_of(state_, manage_uninstall_from_id_);+ drive.value = source ? source->label : "All drives";}row("manage-select-all", RowKind::Action, select_title, "manage-select-all").enabled = choosable > 0;auto& sort = row("manage-sort", RowKind::Action, "Sort", "manage-sort");@@ -2088,6 +2121,9 @@ void Simulation::build_manage_games_view() {} else if (moves) {empty.title = "Nothing to move";empty.subtitle = "Games installed from Steam can move here. Imported games use Copy or Move into Playden.";+ } else if (!updates && volume_of(state_, manage_uninstall_from_id_)) {+ empty.title = "Nothing installed";+ empty.subtitle = "No games on " + volume_of(state_, manage_uninstall_from_id_)->label + ".";} else if (!updates) {empty.title = "Nothing installed";} else if (check.failed) {@@ -2124,6 +2160,7 @@ void Simulation::build_manage_games_view() {view_.footer += " · " + (*plan.free > plan.bytes ? format_bytes(*plan.free - plan.bytes) : std::string("0 GB")) + " free after";} else if (!updates) {view_.footer = std::to_string(count) + " selected · frees " + format_bytes(bytes);+ if (const auto* source = volume_of(state_, manage_uninstall_from_id_)) view_.footer += " on " + source->label;} else {// Each drive's free space, or the drive that lacks room for its games: Update warns when pressed.const auto plan = manage_updates();@@ -9070,6 +9107,8 @@ void Simulation::activate() {if (move_volumes().size() >= 2) open_move_picker({});} else if (action_name == "manage-move-from") {cycle_manage_move_from();+ } else if (action_name == "manage-uninstall-from") {+ cycle_manage_uninstall_from();} else if (action_name == "confirm-destructive" && pending_destructive_action_ == "manage-update-anyway") {pending_destructive_action_.clear();close_modal();diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hppindex a3efc03..4cbca37 100644--- a/src/homebrew/simulation.hpp+++ b/src/homebrew/simulation.hpp@@ -1235,6 +1235,7 @@ private:std::string manage_move_volume_id_;GameId move_picker_game_;std::string manage_move_from_id_; // Move: only the games on this drive are listed; empty lists every drive+ std::string manage_uninstall_from_id_; // Uninstall: only the games on this drive are listed; empty lists every drivebool rebuilding_overlay_ = false; // rebuild_view is building the screen under an open sheetstruct 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@@ -1474,6 +1475,8 @@ private:// them after All drives.[[nodiscard]] std::vector<const Volume*> move_from_volumes() const;void cycle_manage_move_from();+ [[nodiscard]] std::vector<const Volume*> uninstall_from_volumes() const;+ void cycle_manage_uninstall_from();void open_move_picker(GameId game);void choose_move_volume(const std::string& volume_id);// Why a game can't move to `volume_id` now (empty when it can).diff --git a/src/homebrew/view.cpp b/src/homebrew/view.cppindex 591a105..59caa5c 100644--- a/src/homebrew/view.cpp+++ b/src/homebrew/view.cpp@@ -2810,14 +2810,14 @@ class Render::Implui::text(scene_, fonts_.regular, fit(fonts_.regular, view.subtitle, 23.0F, 1728.0F), kSafeX, 230.0F, 23.0F,kSecondary);- // The toolbar: Move from and Move to (on Move), Select all and Sort at the left, Check for updates at the right.+ // The toolbar: Move from and Move to (on Move), Drive (on Uninstall), Select all and Sort at the left, Check for updates at the right.float tool_x = kSafeX;std::vector<const ViewRow *> games, notes;const ViewRow *primary = nullptr;for (const ViewRow &row : view.rows){- if (row.key == "manage-move-from" || row.key == "manage-move-to" || row.key == "manage-select-all" ||- row.key == "manage-sort" || row.key == "manage-check")+ if (row.key == "manage-move-from" || row.key == "manage-move-to" || row.key == "manage-uninstall-from" ||+ row.key == "manage-select-all" || row.key == "manage-sort" || row.key == "manage-check"){const bool picker = row.key == "manage-move-to";const float label = fonts_.regular.measure(row.title, 22.0F);diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cppindex c3cd124..d1103c9 100644--- a/tests/homebrew_live_model_test.cpp+++ b/tests/homebrew_live_model_test.cpp@@ -1895,6 +1895,91 @@ void live_settings_manage_rows(const std::filesystem::path& base) {}+// Uninstall's Drive narrows the list to one drive's games (imported ones too), to free room on that drive: All+// drives, then each connected drive with games, then All drives again. Games off the list leave the selection.+void live_manage_uninstall_drive(const std::filesystem::path& base) {+ using playden::homebrew::ManageTab;+ constexpr std::int64_t kNow = 1'800'000'000;+ constexpr std::uint64_t gb = 1'000'000'000;+ auto model = make_live(base);+ model.SetWallClock(kNow);+ model.UpdateAccount({AuthState::SignedIn, "76561198000000002", "Owner", {}, {}, false});+ check(model.UpdateLibrary({{{SteamId(10), "Portal", "", "", ""}, {SteamId(20), "Stray", "", "", ""},+ {SteamId(30), "Tunic", "", "", ""}},+ false, {}, false, true, kNow}),+ "uninstall drive: library delivered");+ const auto imported = playden::GameId::Local("6d1f3a52-0c55-4f3e-9b2a-5d1c7e0a9f11");+ model.UpdateVolumes({{"internal", "Console storage", true, 800 * gb, 80 * gb},+ {"m2", "M.2 SSD", true, 1000 * gb, 100 * gb},+ {"usb", "USB Drive", true, 1000 * gb, 0}}, "internal");+ model.UpdateInstalls({}, {{SteamId(10), 10 * gb, "internal"}, {SteamId(20), 20 * gb, "m2"},+ {SteamId(30), 30 * gb, "internal"}, {imported, 5 * gb, "m2"}});+ for (int i = 0; i < 6 && model.state().navigation.route != Route::Settings; ++i) model.action("r1");+ activate(model, "settings-installed");+ const auto& navigation = model.state().navigation;+ check(navigation.route == Route::ManageGames && navigation.manage_tab == ManageTab::Uninstall, "uninstall drive: opens on Uninstall");+ const auto* drive = find_row(model, "manage-uninstall-from");+ check(drive && drive->enabled && drive->value == "All drives" && find_row(model, "manage-toggle-10") &&+ find_row(model, "manage-toggle-20"),+ "uninstall drive: Drive starts on All drives and lists every game");+ check(!find_row(model, "manage-move-from") && !find_row(model, "manage-move-to"), "uninstall drive: no Move rows");++ // Checked games on another drive leave the selection when Drive narrows the list.+ activate(model, "manage-toggle-10");+ activate(model, "manage-toggle-20");+ activate(model, "manage-uninstall-from");+ check(find_row(model, "manage-uninstall-from")->value == "Console storage" && find_row(model, "manage-toggle-10") &&+ find_row(model, "manage-toggle-30") && !find_row(model, "manage-toggle-20"),+ "uninstall drive: Console storage lists only its games");+ check(navigation.focus_key == "manage-uninstall-from", "uninstall drive: focus stays on Drive");+ check(model.view().footer == "1 selected · frees 10.0 GB on Console storage", "uninstall drive: the footer names the drive");+ activate(model, "manage-uninstall-from");+ check(find_row(model, "manage-uninstall-from")->value == "M.2 SSD" && find_row(model, "manage-toggle-20") &&+ find_row(model, "manage-toggle-" + playden::ToKey(imported)) && !find_row(model, "manage-toggle-10") &&+ !find_row(model, "manage-toggle-20")->selected,+ "uninstall drive: M.2 SSD lists its games, imported ones too; the earlier choices are gone");+ activate(model, "manage-uninstall-from");+ check(find_row(model, "manage-uninstall-from")->value == "All drives" && find_row(model, "manage-toggle-10") &&+ find_row(model, "manage-toggle-20"),+ "uninstall drive: an empty drive is skipped and the cycle goes back to All drives");++ // Select all checks only the listed drive's games.+ activate(model, "manage-uninstall-from");+ activate(model, "manage-uninstall-from");+ check(find_row(model, "manage-uninstall-from")->value == "M.2 SSD", "uninstall drive: M.2 SSD again");+ model.action("square");+ check(find_row(model, "manage-toggle-20")->selected && find_row(model, "manage-toggle-" + playden::ToKey(imported))->selected &&+ model.view().footer == "2 selected · frees 25.0 GB on M.2 SSD",+ "uninstall drive: Select all checks the drive's games only");+ model.action("square");++ // Another drive going doesn't change the chosen one.+ model.UpdateVolumes({{"internal", "Console storage", true, 800 * gb, 80 * gb},+ {"m2", "M.2 SSD", true, 1000 * gb, 100 * gb}}, "internal");+ check(find_row(model, "manage-uninstall-from")->value == "M.2 SSD" && !find_row(model, "manage-toggle-10"),+ "uninstall drive: another drive going keeps the filter");++ // The drive's last games uninstalled: the filter stays and says the drive is empty.+ model.UpdateInstalls({}, {{SteamId(10), 10 * gb, "internal"}, {SteamId(30), 30 * gb, "internal"}});+ check(find_row(model, "manage-uninstall-from") && find_row(model, "manage-uninstall-from")->value == "M.2 SSD" &&+ find_row(model, "manage-empty") && find_row(model, "manage-empty")->subtitle == "No games on M.2 SSD." &&+ !find_row(model, "manage-toggle-10"),+ "uninstall drive: an emptied drive stays chosen and says it has no games");+ activate(model, "manage-uninstall-from");+ check(!find_row(model, "manage-uninstall-from") && find_row(model, "manage-toggle-10") && find_row(model, "manage-toggle-30"),+ "uninstall drive: Drive goes back to All drives, then hides with one drive of games");++ // A chosen drive that goes lists every drive again.+ model.UpdateInstalls({}, {{SteamId(10), 10 * gb, "internal"}, {SteamId(20), 20 * gb, "m2"}});+ activate(model, "manage-uninstall-from");+ activate(model, "manage-uninstall-from");+ check(find_row(model, "manage-uninstall-from")->value == "M.2 SSD", "uninstall drive: M.2 SSD chosen");+ model.UpdateVolumes({{"internal", "Console storage", true, 800 * gb, 80 * gb},+ {"m2", "M.2 SSD", false, 1000 * gb, 100 * gb}}, "internal");+ check(!find_row(model, "manage-uninstall-from") && find_row(model, "manage-toggle-10") && find_row(model, "manage-toggle-20"),+ "uninstall drive: the chosen drive going lists every game again, the disconnected drive's too");+}+// Move: the checked games go to the chosen drive, each from where it is. Imported games aren't listed, games// already there or running can't be picked, a selection the drive hasn't room for is refused, and a game's// Maintenance queues the same move for that game.@@ -2126,6 +2211,7 @@ int main() {live_manage_games_tabs(base / "manage-games");live_manage_update_selected(base / "update-selected");live_manage_move(base / "manage-move");+ live_manage_uninstall_drive(base / "manage-uninstall-drive");live_manage_queue_full(base / "queue-full");live_settings_manage_rows(base / "settings-manage-rows");