Skip to content

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

C++

Offer Uninstall for a game that couldn't be prepared

Leonardo Lobatof7d3eb43dbd5
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index 766908a..f54d5b6 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -4787,6 +4787,28 @@ bool Simulation::scenario(const std::string& name) {
manage_tabs_[ManageTab::Uninstall].selected = {state_.games[1].id, state_.games[2].id};
state_.navigation.focus_key = "manage-toggle-" + ToKey(state_.games[2].id);
}
+ } else if (name == "queue-refused") {
+ // A downloaded game Playden refused to prepare (SteamStub it can't unpack), in Queue's Preparation with its
+ // actions open: Try again, Game details and Uninstall.
+ if (state_.games.size() < 5) return false;
+ const auto id = state_.games[4].id;
+ state_.account().authentication = AuthState::SignedIn;
+ state_.navigation.route = Route::Downloads;
+ state_.navigation.modals.clear();
+ state_.jobs.clear();
+ state_.runtime_games.clear();
+ state_.preparation_queue = {};
+ state_.queue_expanded.clear();
+ if (!is_installed(state_, id)) state_.installations.push_back({id, "internal", 1'900'000'000});
+ LiveRuntimeGame runtime;
+ runtime.game_id = id;
+ runtime.status = "Not prepared";
+ runtime.can_prepare = true;
+ state_.runtime_games[id] = runtime;
+ state_.preparation_queue.refused[id] = "This game's program has Steam DRM in a form Playden can't unpack yet.";
+ state_.navigation.focus_key = "prep-attn-" + ToKey(id);
+ rebuild_view();
+ activate();
} else if (name.rfind("queue-", 0) == 0) {
// Queue in the states of its mockup: each workflow empty, one game, or one running and three waiting,
// with or without finished entries.
@@ -8545,6 +8567,18 @@ void Simulation::activate() {
else if (runtime != state_.runtime_games.end() && runtime->second.can_prepare && !runtime->second.awaiting_registration)
actions.push_back("prep-retry-" + id);
actions.push_back("prep-open-" + id);
+ // A game that can't be prepared (SteamStub Playden can't unpack) goes from here too, as from its page's
+ // More: Uninstall, or Remove from library for an imported game playing from its folder. Both act on the
+ // selected game; Remove from library on the page's game, and goes back to Queue once confirmed.
+ const bool in_place = external_game(selected.game_id) != nullptr;
+ if (in_place || is_installed(state_, selected.game_id)) {
+ state_.navigation.selected_game_id = selected.game_id;
+ if (in_place) {
+ state_.navigation.detail_id = selected.game_id;
+ state_.navigation.detail_origin = Route::Downloads;
+ }
+ actions.push_back(in_place ? "import-remove" : "uninstall");
+ }
} else if (key.rfind("prep-active-", 0) == 0) {
actions.push_back("prep-open-" + id);
} else {
@@ -8888,6 +8922,8 @@ void Simulation::activate() {
state_.navigation.route = Route::Downloads;
} else if (action_name == "uninstall" || action_name == "reset-confirm" || action_name == "signout-confirm" || action_name == "quit-confirm" || action_name == "quit-game") {
pending_destructive_action_ = action_name;
+ // The game is fixed now: the selection can change under the dialog (an organization load picks another).
+ if (action_name == "uninstall") destructive_target_ = state_.navigation.selected_game_id;
std::string title;
if (action_name == "uninstall") title = "Uninstall this fixture game? Saves are preserved.";
else if (action_name == "reset-confirm") title = "Reset preferences and organization? Installs, saves, and history remain.";
@@ -9091,6 +9127,7 @@ void Simulation::activate() {
const auto* game = find_game(state_, id);
if (!game || !external_game(id)) return;
pending_destructive_action_ = action_name;
+ destructive_target_ = id;
ModalEntry confirmation{"confirmation", "Remove " + game->title + " from the library?", state_.navigation.focus_key,
{"cancel", "confirm-destructive"}, 0, true};
confirmation.body = "The game's folder and files stay where they are, and Import games can add it again. Its PS5 "
@@ -9203,7 +9240,8 @@ void Simulation::activate() {
request_maintenance(state_.navigation.selected_game_id, kind);
}
} else if (action_name == "confirm-destructive" && pending_destructive_action_ == "import-remove") {
- const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);
+ const auto id = destructive_target_.value_or(state_.navigation.detail_id.value_or(state_.navigation.selected_game_id));
+ destructive_target_.reset();
pending_destructive_action_.clear();
state_.navigation.modals.clear();
RequestImport({ImportRequestKind::Remove, id});
@@ -9227,7 +9265,8 @@ void Simulation::activate() {
} else if (action_name == "confirm-destructive" && live() &&
(pending_destructive_action_.rfind("job-cancel-", 0) == 0 || pending_destructive_action_ == "uninstall")) {
if (pending_destructive_action_ == "uninstall") {
- request_uninstall(state_.navigation.selected_game_id, uninstall_delete_saves_, false);
+ request_uninstall(destructive_target_.value_or(state_.navigation.selected_game_id), uninstall_delete_saves_, false);
+ destructive_target_.reset();
uninstall_delete_saves_ = false;
} else if (const auto* job = find_job(state_, pending_destructive_action_.substr(11))) {
pending_install_requests_.push_back({InstallRequestKind::Cancel, job->game_id});
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 6f12a7f..a88ce76 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -1107,6 +1107,8 @@ private:
ViewData route_view_;
std::string last_error_;
std::string pending_destructive_action_;
+ // The game a live Uninstall or Remove from library confirmation acts on, fixed when it opens.
+ std::optional<GameId> destructive_target_;
std::vector<std::string> self_update_requests_;
LiveDownloadServers download_servers_;
std::vector<DownloadServerRequest> download_server_requests_;
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index ed28206..5072f31 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -3119,6 +3119,58 @@ void live_queue_lists_preparations_needing_attention() {
"closed, it counts what needs attention apart from the queue");
}
+// A game Playden refused to prepare (SteamStub it can't unpack) is not stuck in Queue: its actions there uninstall it,
+// or take an imported game playing from its folder out of the library, after the same question as its page asks.
+void live_refused_preparation_offers_uninstall() {
+ using namespace playden::homebrew;
+ auto model = make_live();
+ model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
+ const auto local = playden::GameId::Local("6d1f3a52-0c55-4f3e-9b2a-5d1c7e0a9f11");
+ check(model.UpdateLibrary({{game(SteamId(36), "Doom 3"), game(SteamId(37), "Elsewhere")}, false, {}, false, false, {}}),
+ "library loaded");
+ LibraryUpdate imported{{game(local, "Rally")}, false, {}, false, false, {}};
+ imported.source = playden::Store::kLocal;
+ check(model.UpdateLibrary(imported), "imported library");
+ model.UpdateInstalls({}, {{SteamId(36), 600'000'000}});
+ model.UpdateExternalGames({{local, "usb0", true, ""}});
+ const std::string drm = "This game's program has Steam DRM in a form Playden can't unpack yet.";
+ LiveRuntimeGame doom; doom.game_id = SteamId(36); doom.status = "Not prepared"; doom.can_prepare = true;
+ LiveRuntimeGame rally; rally.game_id = local; rally.status = "Not prepared"; rally.can_prepare = true;
+ LiveRuntimeGame other; other.game_id = SteamId(37); other.status = "Not prepared"; other.can_prepare = true;
+ model.UpdateRuntime(RuntimeState::Ready, {doom, rally, other});
+ model.UpdatePreparationQueue({std::nullopt, {}, {}, {{SteamId(36), drm}, {local, drm}, {SteamId(37), drm}}});
+ model.action("r1");
+ model.action("r1");
+ activate(model, "prep-attn-36");
+ check(has_row(model, "prep-retry-36") && has_row(model, "prep-open-36") && has_row(model, "uninstall") &&
+ find_row(model, "uninstall")->title == "Uninstall" && find_row(model, "uninstall")->enabled,
+ "a refused installed game can be uninstalled from Queue");
+ activate(model, "uninstall");
+ check(model.state().navigation.modals.size() == 2 && model.state().navigation.modals.back().title == "Uninstall this game?",
+ "it asks first, as the game page does");
+ while (!model.state().navigation.modals.empty()) model.action("circle");
+ check(model.state().navigation.route == Route::Downloads && model.TakeInstallRequests().empty(), "Cancel asks for nothing");
+ activate(model, "prep-attn-36");
+ activate(model, "uninstall");
+ activate(model, "confirm-destructive");
+ const auto requests = model.TakeInstallRequests();
+ check(requests.size() == 1 && requests[0].kind == InstallRequestKind::Uninstall && requests[0].game_id == SteamId(36) &&
+ model.state().navigation.modals.empty() && model.state().navigation.route == Route::Downloads,
+ "confirmed, that game is uninstalled and Queue stays open");
+ // An imported game playing from its folder leaves the library instead.
+ activate(model, "prep-attn-" + playden::ToKey(local));
+ check(has_row(model, "import-remove") && !has_row(model, "uninstall"), "an imported game is removed from the library");
+ activate(model, "import-remove");
+ activate(model, "confirm-destructive");
+ const auto removed = model.TakeImportRequests();
+ check(removed.size() == 1 && removed[0].kind == ImportRequestKind::Remove && removed[0].game_id == local &&
+ model.state().navigation.route == Route::Downloads,
+ "confirmed, that game leaves the library and Queue stays open");
+ // A game without files on this console has nothing to uninstall.
+ activate(model, "prep-attn-37");
+ check(!has_row(model, "uninstall") && !has_row(model, "import-remove"), "nothing to remove without its files");
+}
+
// A setup an earlier kit left (its title or bottle from that kit) can't be finished by Try again: Queue and the
// game page offer Recreate bottle instead, say so in plain words, and ask before it runs.
void live_setup_from_an_earlier_kit_offers_recreate() {
@@ -3990,6 +4042,7 @@ int main() {
live_queue_counts_copies();
live_queue_history_and_empty_states();
live_queue_lists_preparations_needing_attention();
+ live_refused_preparation_offers_uninstall();
live_setup_from_an_earlier_kit_offers_recreate();
live_queue_lists_uninstalls();
live_details_prepare_next();
diff --git a/tests/homebrew_simulation_test.cpp b/tests/homebrew_simulation_test.cpp
index 1deed82..4bd3126 100644
--- a/tests/homebrew_simulation_test.cpp
+++ b/tests/homebrew_simulation_test.cpp
@@ -1470,6 +1470,18 @@ void synthetic_download_servers(const std::filesystem::path& fixtures, const std
for (const auto& item : restarted.view().rows)
if (item.key == "settings-download-server") check(item.value == "Fastest", "the row shows Fastest");
// Queue: the download names its server before the rate.
+ // Queue: a game Playden refused to prepare offers Uninstall beside Try again.
+ check(restarted.scenario("queue-refused"), "refused preparation scenario exists");
+ {
+ const auto& modals = restarted.state().navigation.modals;
+ check(!modals.empty() && modals.back().id == "prep-actions" &&
+ std::find(modals.back().action_keys.begin(), modals.back().action_keys.end(), "uninstall") !=
+ modals.back().action_keys.end(),
+ "the refused game's actions include Uninstall");
+ check(restarted.action("focus:uninstall") && restarted.action("cross") &&
+ restarted.state().navigation.modals.back().id == "confirmation",
+ "Uninstall asks first");
+ }
check(restarted.scenario("queue-one-download"), "queue scenario exists");
check(restarted.state().jobs.front().server_name == "Fastly" &&
playden::homebrew::FormatDownloadRate(restarted.state().jobs.front().bytes_per_second,