Skip to content

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

C++

Keep the update dialogs open when the library loads

Leonardo Lobato592cd573fa63
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index aabf5be..1d9cf5f 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -1819,6 +1819,18 @@ void Simulation::sync_self_update_job() {
// The running version's release notes, with its release page as a QR code: once after an update
// ("What's new"), and from Settings › About › Release notes.
+// The selected game changed under the dialogs: the ones about a game close, Playden's own update
+// dialogs (often opened at startup, before the library arrives) stay.
+void Simulation::close_game_modals() {
+ auto& modals = state_.navigation.modals;
+ modals.erase(std::remove_if(modals.begin(), modals.end(), [](const ModalEntry& modal) {
+ return std::none_of(modal.action_keys.begin(), modal.action_keys.end(), [](const std::string& key) {
+ return key == "self-update-install" || key == "self-update-restart" || key == "release-notes-ok" ||
+ key == "kit-install";
+ });
+ }), modals.end());
+}
+
void Simulation::open_release_notes(bool after_update) {
const auto& update = state_.self_update;
ModalEntry notes{"confirmation",
@@ -2490,12 +2502,12 @@ bool Simulation::UpdateLibrary(LibraryUpdate update) {
} else if (!current_visible.empty()) {
state_.navigation.selected_index = std::clamp(prior_index, 0, static_cast<int>(current_visible.size()) - 1);
state_.navigation.selected_game_id = current_visible[static_cast<std::size_t>(state_.navigation.selected_index)]->id;
- if (!state_.navigation.modals.empty()) state_.navigation.modals.clear();
+ close_game_modals();
state_.editor.active = false;
} else {
state_.navigation.selected_index = 0;
state_.navigation.selected_game_id = {};
- state_.navigation.modals.clear();
+ close_game_modals();
state_.editor.active = false;
}
@@ -2544,6 +2556,11 @@ bool Simulation::UpdateLibrary(LibraryUpdate update) {
} else {
state_.navigation.focus_key = prior_focus;
}
+ // An update dialog that stayed open keeps the focus; the route's new focus is where it returns to.
+ if (prior_overlay && !identity_retained && !state_.navigation.modals.empty()) {
+ state_.navigation.modals.front().opener_focus_key = state_.navigation.focus_key;
+ state_.navigation.focus_key = prior_focus;
+ }
const auto projected_shelves = shelves(state_);
for (std::size_t shelf_index = 0; shelf_index < projected_shelves.size(); ++shelf_index) {
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 9effa62..23c8001 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -896,6 +896,7 @@ private:
void show_update_prompt();
void sync_self_update_job();
void request_self_update_restart(const std::string& request = "restart");
+ void close_game_modals();
void open_release_notes(bool after_update);
std::string selected_volume_id_;
bool default_volume_saved_ = true; // last install-service report, so a failed save is said once
diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cpp
index 287de13..02b2340 100644
--- a/tests/homebrew_live_model_test.cpp
+++ b/tests/homebrew_live_model_test.cpp
@@ -956,6 +956,56 @@ void live_self_update(const std::filesystem::path& base) {
updated.state().navigation.modals.back().link == fresh.current_notes_url,
"update: the release notes open from Settings");
+ // The library arriving after the dialog opened (the cached list, then each store's) leaves it open.
+ {
+ auto late = make_live(base);
+ late.UpdateAccount({AuthState::SignedIn, "account", "Owner", {}, {}, false});
+ check(late.UpdateLibrary({{}, false, {}, false, true, 100}), "update: empty library delivered");
+ LiveSelfUpdate waiting;
+ waiting.current = "0.3.0";
+ waiting.finished_message = "Playden was updated to 0.3.0.";
+ waiting.whats_new = true;
+ late.UpdateSelfUpdate(waiting);
+ check(!late.state().navigation.modals.empty() &&
+ late.state().navigation.modals.back().title == "What's new in Playden 0.3.0",
+ "update: what's new opens before the games arrive");
+ playden::GameSummary game;
+ game.id = SteamId(220);
+ game.title = "Half-Life 2";
+ check(late.UpdateLibrary({{game}, false, {}, false, true, 100}), "update: games delivered");
+ check(!late.state().navigation.modals.empty() &&
+ late.state().navigation.modals.back().title == "What's new in Playden 0.3.0",
+ "update: the games arriving leave what's new open");
+ }
+
+ // The offer keeps its focus on Download when the selected game leaves the list under it.
+ {
+ auto offered = make_live(base);
+ offered.UpdateAccount({AuthState::SignedIn, "account", "Owner", {}, {}, false});
+ std::vector<playden::GameSummary> games;
+ for (int i = 0; i < 4; ++i) {
+ playden::GameSummary game;
+ game.id = SteamId(220 + i);
+ game.title = "Game " + std::to_string(i);
+ games.push_back(game);
+ }
+ check(offered.UpdateLibrary({games, false, {}, false, true, 100}), "update: four games delivered");
+ for (int i = 0; i < 3; ++i) offered.action("right");
+ LiveSelfUpdate available;
+ available.current = "0.2.0";
+ available.phase = "available";
+ available.available = "0.3.0";
+ offered.UpdateSelfUpdate(available);
+ check(!offered.state().navigation.modals.empty() &&
+ offered.state().navigation.modals.back().title == "Playden 0.3.0 is available",
+ "update: the offer opens over the library");
+ games.pop_back();
+ games.erase(games.begin() + 2);
+ check(offered.UpdateLibrary({games, false, {}, false, true, 100}), "update: the selected game leaves");
+ check(offered.action("cross") && offered.TakeSelfUpdateRequests() == std::vector<std::string>{"install"},
+ "update: Download and install still has the focus");
+ }
+
// A failed install says why; the previous run's result shows once.
auto failing = make_live(base);
failing.UpdateAccount({AuthState::SignedIn, "account", "Owner", {}, {}, false});