Skip to content

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

C++

List each uninstall once in Queue

Leonardo Lobato7fcc2fa95dc4
diff --git a/src/homebrew/queue_layout.cpp b/src/homebrew/queue_layout.cpp
index 991df73..ef364d8 100644
--- a/src/homebrew/queue_layout.cpp
+++ b/src/homebrew/queue_layout.cpp
@@ -213,7 +213,8 @@ QueueSection preparations(const State& state) {
finished.push_back(std::move(item));
}
for (const auto& ended : state.ended_uninstalls) {
- if (!ended.stopped.empty()) continue;
+ // A game shows once: while it is being uninstalled again, not also as done.
+ if (!ended.stopped.empty() || uninstalling(ended.game_id)) continue;
QueueEntry item;
item.key = "prep-unin-done-" + ToKey(ended.game_id) + "-" + std::to_string(ended.finished_at);
item.game_id = ended.game_id;
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index 01e43f4..2c453d7 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -1395,14 +1395,23 @@ void Simulation::request_uninstall(GameId id, bool delete_saves, bool batch) {
pending_install_requests_.push_back({InstallRequestKind::Uninstall, id, {}, delete_saves});
pending_uninstalls_.insert(id);
if (const auto* game = find_game(state_, id); game && !game->title.empty()) uninstall_titles_[id] = game->title;
- // Asked again: an earlier stop no longer applies.
- std::erase_if(state_.ended_uninstalls, [id](const EndedUninstall& ended) { return ended.game_id == id && !ended.stopped.empty(); });
+ // Asked again: how it ended before is no longer listed, so the game shows once, as it goes now.
+ std::erase_if(state_.ended_uninstalls, [id](const EndedUninstall& ended) { return ended.game_id == id; });
+ previous_account_uninstalls_.erase(id);
if (batch) batch_uninstalls_.insert(id);
else batch_uninstalls_.erase(id);
}
// Queue keeps how this session's uninstalls ended, newest first: a game's latest stop, and every finish.
void Simulation::end_uninstall(GameId id, const std::string& stopped) {
+ // It is no longer at work: Queue lists it as ended at once, not also as running until the
+ // controller's next list.
+ std::erase_if(state_.preparation_queue.uninstalls, [id](const LiveUninstall& item) { return item.game_id == id; });
+ pending_uninstalls_.erase(id);
+ if (previous_account_uninstalls_.erase(id)) {
+ uninstall_titles_.erase(id);
+ return;
+ }
auto& ended = state_.ended_uninstalls;
std::erase_if(ended, [id](const EndedUninstall& entry) { return entry.game_id == id && !entry.stopped.empty(); });
std::string title;
@@ -1410,7 +1419,6 @@ void Simulation::end_uninstall(GameId id, const std::string& stopped) {
else if (const auto known = uninstall_titles_.find(id); known != uninstall_titles_.end()) title = known->second;
ended.insert(ended.begin(), {id, std::move(title), stopped, state_.clock_ticks});
uninstall_titles_.erase(id);
- pending_uninstalls_.erase(id);
}
const EndedUninstall* Simulation::uninstall_stop(GameId id) const {
@@ -2103,8 +2111,17 @@ void Simulation::clear_account_specific_state() {
// Live organization (favorites, collections, ratings, notes) belongs to the device and stays.
if (live()) state_.library.view_sort.clear();
else state_.library = {};
- // Steam's installs and downloads go with its account; other stores' stay listed.
+ // Steam's installs and downloads go with its account; other stores' stay listed. So do its ended
+ // uninstalls; one still running may finish, but how it ends is not listed for the next account.
std::erase_if(state_.installations, [](const Installation& item) { return item.game_id.store == Store::kSteam; });
+ std::erase_if(state_.ended_uninstalls, [](const EndedUninstall& ended) { return ended.game_id.store == Store::kSteam; });
+ for (const auto& uninstall : state_.preparation_queue.uninstalls)
+ if (uninstall.game_id.store == Store::kSteam) previous_account_uninstalls_.insert(uninstall.game_id);
+ for (const auto id : pending_uninstalls_)
+ if (id.store == Store::kSteam) previous_account_uninstalls_.insert(id);
+ std::erase_if(pending_uninstalls_, [](GameId id) { return id.store == Store::kSteam; });
+ std::erase_if(batch_uninstalls_, [](GameId id) { return id.store == Store::kSteam; });
+ std::erase_if(uninstall_titles_, [](const auto& entry) { return entry.first.store == Store::kSteam; });
std::erase_if(state_.jobs, [](const Job& job) { return job.game_id.store == Store::kSteam; });
state_.volumes.clear();
state_.cloud.clear();
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 5407bda..5f2a49d 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -951,6 +951,8 @@ private:
// no notice of their own when they finish, and a stop is a corner notice, not a dialog.
std::set<GameId> batch_uninstalls_;
std::map<GameId, std::string> uninstall_titles_; // names of games being uninstalled, for once they are gone
+ // Steam games still being uninstalled when their account signed out: how they end is not listed.
+ std::set<GameId> previous_account_uninstalls_;
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
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index c42bf6f..d07d018 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -2516,6 +2516,27 @@ void live_queue_lists_uninstalls() {
activate(model, done_key);
activate(model, "prep-clear-completed");
check(model.TakePreparedClear() && model.state().ended_uninstalls.empty(), "Clear completed clears both");
+
+ // A game shows once: finished, it leaves the running list at once (before the controller's next
+ // list); uninstalled again, its earlier finish is not listed while it goes.
+ model.UpdatePreparationQueue({std::nullopt, {}, {}, {}, {{SteamId(42), "Deleting files…"}}});
+ model.NotifyUninstallFinished(SteamId(42));
+ const auto gamma_done = "prep-unin-done-42-" + std::to_string(now);
+ check((queue_keys(model) == std::vector<std::string>{"queue-preparation", gamma_done}),
+ "a finished uninstall is listed once, as done, at once");
+ model.UpdatePreparationQueue({std::nullopt, {}, {}, {}, {{SteamId(42), "Deleting files…"}}});
+ check((queue_keys(model) == std::vector<std::string>{"queue-preparation", "prep-unin-42"}),
+ "while the game is uninstalled again its earlier finish is not listed");
+
+ // Signing out drops the account's ended uninstalls; one still running may finish, unlisted.
+ model.UpdatePreparationQueue({std::nullopt, {}, {}, {}, {{SteamId(41), "Removing PS5 title…"}}});
+ model.NotifyUninstallStopped(SteamId(40), "Its drive is not connected. Connect it, then uninstall again.");
+ while (!model.state().navigation.modals.empty()) model.action("circle");
+ check(model.state().ended_uninstalls.size() == 2, "a finish and a stop are listed");
+ model.UpdateAccount({AuthState::SignedOut, {}, {}, {}, {}, true});
+ check(model.state().ended_uninstalls.empty(), "signing out drops the previous account's ended uninstalls");
+ model.NotifyUninstallFinished(SteamId(41));
+ check(model.state().ended_uninstalls.empty(), "an uninstall of the previous account that ends later is not listed");
}
// A game whose preparation needs the player stays in Preparation without a running preparation.