Skip to content

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

C++

Don't ask for the program again right after choosing

Leonardo Lobato89e9f5089e7e
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index 8e3732b..e802d4d 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -8023,16 +8023,19 @@ void Simulation::SetGameSetups(std::map<GameId, LiveGameSetup> setups) {
std::equal(setups.begin(), setups.end(), game_setups_.begin(),
[&](const auto& a, const auto& b) { return a.first == b.first && same(a.second, b.second); }))
return;
- std::set<GameId> asked_before;
- for (const auto& [id, setup] : game_setups_)
- if (!setup.steam_choices.empty()) asked_before.insert(id);
game_setups_ = std::move(setups);
for (const auto& [id, setup] : game_setups_)
if (setup.scanned) requested_program_scans_.erase(id);
// A setup that now waits for its program asks once: the sheet over the game's own page, otherwise
// a notification; the Play row asks until then.
+ // Asked until the runtime no longer waits: a setup still waiting right after the player chose
+ // (the runtime hasn't taken the new request yet) doesn't ask again.
+ std::erase_if(steam_programs_asked_, [&](GameId id) {
+ const auto found = game_setups_.find(id);
+ return found == game_setups_.end() || found->second.steam_choices.empty();
+ });
for (const auto& [id, setup] : game_setups_) {
- if (setup.steam_choices.empty() || asked_before.count(id)) continue;
+ if (setup.steam_choices.empty() || !steam_programs_asked_.insert(id).second) continue;
if (state_.navigation.route == Route::Details && state_.navigation.detail_id == id && state_.navigation.modals.empty()) {
open_steam_programs(id);
} else if (const auto* game = find_game(state_, id)) {
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 0984b70..1ebe979 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -1086,6 +1086,7 @@ private:
void open_steam_programs(GameId id);
void choose_steam_launch(GameId id, const std::string& program);
std::vector<LaunchProgram> steam_programs_shown_;
+ std::set<GameId> steam_programs_asked_; // games whose waiting setup asked once already
GameId steam_programs_game_;
std::size_t import_program_index_ = 0;
bool import_program_chosen_ = false; // the program was clear (ClearGameProgram): its list was skipped
diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cpp
index 55378ea..87f8ccd 100644
--- a/tests/homebrew_live_model_test.cpp
+++ b/tests/homebrew_live_model_test.cpp
@@ -857,6 +857,9 @@ void live_setup_asks_for_a_steam_program(const std::filesystem::path& base) {
const auto prepares = model.TakeRuntimePrepareRequests();
check(std::count(prepares.begin(), prepares.end(), SteamId(449610)) == 1, "steam program: the game is set up again");
check(model.view().surface != "steam-programs", "steam program: the sheet closes");
+ // The runtime still reports the old wait until it takes the new request: no second question.
+ model.SetGameSetups({{SteamId(449610), setup}});
+ check(model.view().surface != "steam-programs", "steam program: a stale wait doesn't ask again");
// Over the game's own page, the sheet opens by itself.
model.SetGameSetups({});