Skip to content

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

C++

Ask for a Steam game's program after its download

Leonardo Lobatoce3e0466542b
diff --git a/cmake/HomebrewUI.cmake b/cmake/HomebrewUI.cmake
index 38d94ba..2793e9a 100644
--- a/cmake/HomebrewUI.cmake
+++ b/cmake/HomebrewUI.cmake
@@ -249,7 +249,7 @@ target_include_directories(playden_homebrew_runtime_host PUBLIC "${CMAKE_SOURCE_
target_link_libraries(playden_homebrew_runtime_host PUBLIC playden_native_coordinator playden_runtime_settings_publication
playden_runtime_installs playden_runtime_install_service playden_runtime_package_installer
playden_runtime_private_directories playden_runtime_launch_service playden_runtime_session_reconciler
- playden_storage playden_steam_cm_codec playden_runtime_steamworks playden_runtime_layout_migration)
+ playden_storage playden_steam_cm_codec playden_runtime_steamworks playden_runtime_layout_migration playden_local_store)
add_library(playden_homebrew_artwork STATIC
"${CMAKE_SOURCE_DIR}/src/homebrew/artwork.cpp"
diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cpp
index a219051..1dda380 100644
--- a/src/homebrew/controller.cpp
+++ b/src/homebrew/controller.cpp
@@ -1,11 +1,8 @@
#include "homebrew/controller.hpp"
#include "diagnostics/redaction.h"
-#include "steam/backend/app_info.h"
-#include "stores/local/scanner.h"
#include "steam/install_volumes.h"
#include "steam/secret.h"
#include <algorithm>
-#include <cctype>
#include <chrono>
#include <utility>
@@ -1326,6 +1323,7 @@ void Controller::TickRuntime() {
live.scanned = setup.scanned;
live.draft = setup.draft;
live.refusal_soft = setup.refusal_soft;
+ for (const auto& choice : setup.steam_choices) live.steam_choices.push_back({choice.path, choice.helper});
if (const auto refusal = snapshot.refusals.find(app); refusal != snapshot.refusals.end()) live.refusal = refusal->second;
}
model_.SetGameSetups(std::move(setups));
@@ -1742,6 +1740,7 @@ void Controller::TickAppDetails() {
requested_detail_.reset();
launch_options_.clear();
launch_options_reason_.clear();
+ launches_any_branch_.clear();
prepare_after_details_.clear();
}
// Fetch Steam app info when the player opens a game's details while signed in.
@@ -1754,26 +1753,9 @@ void Controller::TickAppDetails() {
for (const auto& details : app_details_->Pump(8)) {
if (details.account_generation != generation) continue;
if (details.available) {
- // Options from every branch don't say which program starts the game: Install asks.
- std::vector<LaunchProgram> programs;
- if (details.launches_any_branch)
- for (const auto& option : details.launches) {
- // Only a Windows program can be the game's Program (game settings take .exe files only).
- const auto path = steam::RelativeGamePath(option.executable);
- if (!path || path->size() < 5 || !std::equal(path->end() - 4, path->end(), ".exe", [](char a, char b) {
- return std::tolower(static_cast<unsigned char>(a)) == b;
- }))
- continue;
- const auto same = [&](const LaunchProgram& other) {
- return std::equal(path->begin(), path->end(), other.path.begin(), other.path.end(), [](char a, char b) {
- return std::tolower(static_cast<unsigned char>(a)) == std::tolower(static_cast<unsigned char>(b));
- });
- };
- if (std::none_of(programs.begin(), programs.end(), same))
- programs.push_back({*path, playden::stores::local::IsLikelyHelper(*path)});
- }
- model_.UpdateAppDetails(details.id, details.download_bytes, details.install_bytes, details.windows_installable,
- std::move(programs));
+ model_.UpdateAppDetails(details.id, details.download_bytes, details.install_bytes, details.windows_installable);
+ if (details.launches_any_branch) launches_any_branch_.insert(details.id);
+ else launches_any_branch_.erase(details.id);
launch_options_[details.id] = details.launches;
launch_options_reason_.erase(details.id);
} else if (!launch_options_.count(details.id)) {
@@ -1820,16 +1802,7 @@ void Controller::SubmitPrepare(GameId id, bool announce) {
if (const auto found = launch_options_.find(id); found != launch_options_.end())
for (const auto& option : found->second)
request.launches.push_back({"", option.description, option.executable, option.working_directory, option.arguments});
- // The program chosen at Install when Steam listed options only for other branches goes first.
- if (const auto record = model_.state().game_settings.find(id);
- record != model_.state().game_settings.end() && !record->second.steam_launch.empty())
- std::stable_partition(request.launches.begin(), request.launches.end(), [&](const auto& launch) {
- const auto path = steam::RelativeGamePath(launch.executable);
- const auto& chosen = record->second.steam_launch;
- return path && std::equal(path->begin(), path->end(), chosen.begin(), chosen.end(), [](char a, char b) {
- return std::tolower(static_cast<unsigned char>(a)) == std::tolower(static_cast<unsigned char>(b));
- });
- });
+ request.launches_any_branch = launches_any_branch_.count(id) != 0;
// Steam's launch options and app details are for Steam games only: another store's game starts the
// program the player picks in Game settings.
const bool steam = id.store == Store::kSteam;
diff --git a/src/homebrew/controller.hpp b/src/homebrew/controller.hpp
index b3c7a69..69a9eb0 100644
--- a/src/homebrew/controller.hpp
+++ b/src/homebrew/controller.hpp
@@ -185,6 +185,8 @@ class Controller {
// Steam's Windows launch options per game, from app details. A game Playden ships
// no recipe for is prepared from them; Prepare waits while they are fetched.
std::map<GameId, std::vector<steam::LaunchOption>> launch_options_;
+ // Games whose Steam options are all for other branches: preparing may ask for the program.
+ std::set<GameId> launches_any_branch_;
std::map<GameId, std::string> launch_options_reason_;
std::set<GameId> prepare_after_details_;
// announce: tell the player when this preparation leaves the game ready to play
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index c34bb51..bd57faf 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -20,8 +20,10 @@
#include "platform/managed_file_lock.h"
#include "steam/backend/cloud_mapping.h"
#include "steam/backend/json.h"
+#include "stores/local/scanner.h"
#include <algorithm>
+#include <cctype>
#include <cerrno>
#include <chrono>
#include <cstdio>
@@ -2270,17 +2272,58 @@ const rt::GameRecipe* RuntimeHost::RecipeForPrepare(Composition& c, const Runtim
const auto saved = config_.settings_record ? config_.settings_record(GameOf(request)) : std::nullopt;
const auto choices = saved ? rt::RecipeChoicesFrom(*saved) : rt::RecipeChoices{};
const auto kit = c.kit ? rt::KitCapabilitiesFromManifest(c.kit->capabilities, true) : rt::KitCapabilities{};
+ // Steam's options all for other branches: the program the player chose goes first, and with no
+ // choice yet, the options whose program is in the folder decide (the import rules: one clear
+ // program starts the game, two or more are the player's choice).
+ auto launches = request.launches;
+ const auto same_program = [](const std::string& path, const std::string& other) {
+ return std::equal(path.begin(), path.end(), other.begin(), other.end(), [](char a, char b) {
+ return std::tolower(static_cast<unsigned char>(a)) == std::tolower(static_cast<unsigned char>(b));
+ });
+ };
+ const auto put_first = [&](const std::string& program) {
+ std::stable_partition(launches.begin(), launches.end(), [&](const rt::LaunchEntry& launch) {
+ const auto path = steam::RelativeGamePath(launch.executable);
+ return path && same_program(*path, program);
+ });
+ };
+ std::vector<SteamLaunchChoice> steam_choices;
+ if (saved && !saved->steam_launch.empty()) {
+ put_first(saved->steam_launch);
+ } else if (request.launches_any_branch && choices.program.empty()) {
+ for (const auto& launch : launches) {
+ const auto path = steam::RelativeGamePath(launch.executable);
+ if (!path || rt::GameProgramArchitecture(root.string(), *path).empty()) continue;
+ if (std::none_of(steam_choices.begin(), steam_choices.end(),
+ [&](const SteamLaunchChoice& other) { return same_program(*path, other.path); }))
+ steam_choices.push_back({*path, stores::local::IsLikelyHelper(*path)});
+ }
+ if (const auto clear = stores::local::ClearGameProgram(steam_choices)) put_first(steam_choices[*clear].path);
+ if (steam_choices.size() < 2 || stores::local::ClearGameProgram(steam_choices)) steam_choices.clear();
+ }
+ if (!steam_choices.empty()) {
+ *reason = "Choose the program that starts this game.";
+ Log("prepare waits app=" + std::to_string(request.runtime_number) + " steam programs=" +
+ std::to_string(steam_choices.size()));
+ Publish([&](RuntimeSnapshot& s) {
+ auto& setup = s.game_setups[request.runtime_number];
+ setup.steam_choices = std::move(steam_choices);
+ setup.draft.reset();
+ setup.refusal_soft = false;
+ });
+ return nullptr;
+ }
rt::GameRecipe generated;
bool soft = true;
rt::GameRecipeDiagnostics diagnostics;
- const bool made = (!request.launches.empty() || !choices.program.empty()) &&
- rt::GenerateGameRecipe(GameOf(request), request.runtime_number, request.title_name, request.launches, root.string(),
+ const bool made = (!launches.empty() || !choices.program.empty()) &&
+ rt::GenerateGameRecipe(GameOf(request), request.runtime_number, request.title_name, launches, root.string(),
&generated, reason, kit, choices, &soft, &diagnostics);
// The same line an unpack writes, so a refused SteamStub program is found the same way.
if (!made && !diagnostics.steam_stub_program.empty())
Log("steamstub app=" + std::to_string(request.runtime_number) + " found=" + diagnostics.steam_stub_program +
" changed=- failed=" + *reason + " (" + (diagnostics.steam_stub_detail.empty() ? "unknown" : diagnostics.steam_stub_detail) + ")");
- if (!made && request.launches.empty() && choices.program.empty())
+ if (!made && launches.empty() && choices.program.empty())
*reason = request.launch_reason.empty() ? "Steam lists no Windows program this console can start for this game."
: request.launch_reason;
// A refused game gets the folder's programs and a draft for Game settings to start from; a
@@ -2293,7 +2336,7 @@ const rt::GameRecipe* RuntimeHost::RecipeForPrepare(Composition& c, const Runtim
tried.try_anyway = true;
rt::GameRecipe permissive;
std::string ignored;
- if (!rt::GenerateGameRecipe(GameOf(request), request.runtime_number, request.title_name, request.launches, root.string(),
+ if (!rt::GenerateGameRecipe(GameOf(request), request.runtime_number, request.title_name, launches, root.string(),
&permissive, &ignored, kit, tried)) {
// No program yet: the sheet starts from the Program row.
permissive = {};
@@ -2310,6 +2353,7 @@ const rt::GameRecipe* RuntimeHost::RecipeForPrepare(Composition& c, const Runtim
}
Publish([&](RuntimeSnapshot& s) {
auto& setup = s.game_setups[request.runtime_number];
+ setup.steam_choices.clear();
if (!made) setup.programs = std::move(programs), setup.scanned = true;
setup.draft = std::move(draft);
setup.refusal_soft = !made && soft;
diff --git a/src/homebrew/runtime_host.hpp b/src/homebrew/runtime_host.hpp
index c035aa7..1854d82 100644
--- a/src/homebrew/runtime_host.hpp
+++ b/src/homebrew/runtime_host.hpp
@@ -214,6 +214,12 @@ struct RuntimeLaunchView {
enum class RuntimeHostStatus { kStarting, kUnavailable, kReady, kStopped };
+// A program one of Steam's launch options names, found in the game's folder.
+struct SteamLaunchChoice {
+ std::string path; // as Steam names it, '/' separated
+ bool helper = false; // an installer or tool (the import rules)
+};
+
// What Game settings needs to pick a game's program: the Windows programs in its folder and,
// for a game Playden could not prepare, a draft recipe to start the sheet from.
struct RuntimeGameSetup {
@@ -223,6 +229,9 @@ struct RuntimeGameSetup {
// no launch entry yet) and whether a choice (a program, "Try anyway") can get past the refusal.
std::optional<runtime::GameRecipe> draft;
bool refusal_soft = false;
+ // Steam's options are all for other branches and more than one of their programs is in the game's
+ // folder: preparing waits for the player to choose one (Game settings' steam_launch).
+ std::vector<SteamLaunchChoice> steam_choices;
};
@@ -333,6 +342,9 @@ struct RuntimePrepareRequest {
// ships no recipe for the game. launch_reason says why they are missing.
std::vector<runtime::LaunchEntry> launches;
std::string launch_reason;
+ // No option is for the public branch: `launches` are every branch's, and Steam doesn't say
+ // which program starts the game.
+ bool launches_any_branch = false;
// The game; a default one stands for the Steam game runtime_number names.
GameId game;
};
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index c7b1fc7..8e3732b 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -1179,35 +1179,20 @@ void Simulation::NotifyImportFailed(const ImportRequest& request, const std::str
rebuild_view();
}
-std::vector<LaunchProgram> Simulation::steam_programs(const Game& game) {
- auto programs = game.launch_programs;
- // Installers and tools last, each group in Steam's order (its default option first).
- std::stable_partition(programs.begin(), programs.end(), [](const LaunchProgram& program) { return !program.helper; });
- return programs;
-}
-
-bool Simulation::ask_steam_program(GameId id) {
+void Simulation::open_steam_programs(GameId id) {
+ const auto setup = game_setups_.find(id);
const auto* game = find_game(state_, id);
- if (!game || game->launch_programs.empty()) return false;
- const auto programs = steam_programs(*game);
- // A program the player already chose (in Game settings, or here for an earlier install) is kept.
- if (const auto found = state_.game_settings.find(id); found != state_.game_settings.end() &&
- (found->second.overrides.count("program") ||
- !found->second.steam_launch.empty()))
- return false;
- if (const auto clear = playden::stores::local::ClearGameProgram(programs)) {
- // Steam's first option is tried first; an installer or tool listed before the game isn't.
- if (programs[*clear].path != game->launch_programs.front().path) choose_steam_launch(id, programs[*clear].path);
- return false;
- }
- steam_programs_shown_ = programs;
+ if (!game || setup == game_setups_.end() || setup->second.steam_choices.empty()) return;
+ steam_programs_shown_ = setup->second.steam_choices;
+ // Installers and tools last, each group in Steam's order (its default option first).
+ std::stable_partition(steam_programs_shown_.begin(), steam_programs_shown_.end(),
+ [](const LaunchProgram& program) { return !program.helper; });
steam_programs_game_ = id;
std::vector<std::string> actions;
- for (std::size_t index = 0; index < programs.size(); ++index)
+ for (std::size_t index = 0; index < steam_programs_shown_.size(); ++index)
actions.push_back("steam-program-" + std::to_string(index));
actions.push_back("cancel");
- open_modal({"steam-programs", game->title, "details-install", std::move(actions), 0, false});
- return true;
+ open_modal({"steam-programs", game->title, state_.navigation.focus_key, std::move(actions), 0, false});
}
bool Simulation::SeedGameProgram(GameId id, const std::string& program) {
@@ -2012,18 +1997,12 @@ void Simulation::choose_steam_launch(GameId id, const std::string& program) {
if (!live() || !id.valid()) return;
state_.game_settings[id].steam_launch = program;
save_profile();
+ // Answered: the row waits for the new setup, which no longer asks.
+ if (auto setup = game_setups_.find(id); setup != game_setups_.end()) setup->second.steam_choices.clear();
+ pending_runtime_prepare_requests_.push_back(id);
+ rebuild_view();
}
-void Simulation::start_live_install(GameId id) {
- // Install at once when the game fits the default drive (or its size is checked later);
- // otherwise the sheet says why and offers another drive for this install.
- install_volume_id_.clear();
- if (id.valid() && live_install_allowed(assess_install(state_, id, selected_volume_id_, steam::kInstallSpaceMargin).readiness,
- free_space_supported_))
- pending_install_requests_.push_back({InstallRequestKind::Install, id});
- else if (id.valid())
- open_modal({"install", "Install game", "details-install", {"install-confirm", "storage-picker", "cancel"}, 0, false});
-}
// Used space is what the drive reports, which already includes what downloads have written or
// preallocated; reserved space is the rest of each download's install estimate, as the install
@@ -2242,8 +2221,7 @@ void Simulation::UpdateAccount(AccountUpdate update) {
bool Simulation::UpdateAppDetails(GameId id, std::optional<std::uint64_t> download_bytes,
std::optional<std::uint64_t> install_bytes,
- std::optional<bool> windows_installable,
- std::vector<LaunchProgram> launch_programs) {
+ std::optional<bool> windows_installable) {
if (!live()) return false;
const auto game = std::find_if(state_.games.begin(), state_.games.end(),
[id](const Game& candidate) { return candidate.id == id; });
@@ -2251,7 +2229,6 @@ bool Simulation::UpdateAppDetails(GameId id, std::optional<std::uint64_t> downlo
game->download_bytes = download_bytes;
game->install_bytes = install_bytes;
game->windows_installable = windows_installable;
- game->launch_programs = std::move(launch_programs);
apply_live_volume_usage();
rebuild_view();
return true;
@@ -3735,7 +3712,7 @@ void Simulation::rebuild_view() {
if (import_programs)
view_.subtitle = import_programs->ascii_ok ? "Choose the program that starts the game." : kImportCopyOnlyText;
if (modal.id == "steam-programs")
- view_.subtitle = "Steam doesn't say which program starts the game. Choose one; you can change it in Game settings.";
+ view_.subtitle = "Steam lists more than one program for this game. Choose the one that starts it; you can change it later in Game settings.";
// The import wizard: what it imports, where from, and how big it is.
const bool import_wizard = modal.id == "import-choice" || modal.id == "import-storage";
const auto import_wizard_subject = import_wizard ? import_subject() : ImportSubject{};
@@ -4319,7 +4296,7 @@ void Simulation::rebuild_view() {
else if (modal.id == "game-maintenance") view_.legends = {"Cross Select", "L1/R1 Jump", "Circle Cancel"};
else if (modal.id == "import-games") view_.legends = {"Cross Select", "Circle Close"};
else if (modal.id == "import-programs" || modal.id == "import-choice") view_.legends = {"Cross Select", "Circle Back"};
- else if (modal.id == "steam-programs") view_.legends = {"Cross Install", "Circle Cancel"};
+ else if (modal.id == "steam-programs") view_.legends = {"Cross Choose", "Circle Cancel"};
else if (modal.id == "import-storage") view_.legends = {"Cross Import here", "Circle Back"};
else if (modal.id == "installed-games")
// The batch's rows only report; Cross does something only on its buttons.
@@ -4576,6 +4553,14 @@ void Simulation::rebuild_view() {
: value.status == "Checking" || value.status == "Removing" || value.status == "Unavailable" ? value.status
: std::string{};
play.enabled = enabled && value.uninstall_status.empty();
+ // Setting up waits for the player to choose the game's program.
+ if (const auto setup = game_setups_.find(game->id); setup != game_setups_.end() &&
+ !setup->second.steam_choices.empty() && !value.ready && value.status != "Preparing") {
+ play.title = "Choose program";
+ play.action = "steam-programs";
+ play.value.clear();
+ play.enabled = value.uninstall_status.empty();
+ }
if (!value.uninstall_status.empty()) {
play.value = value.uninstall_status;
play.action.clear();
@@ -6447,14 +6432,22 @@ void Simulation::activate() {
}
} else if (live() && action_name == "live-install") {
const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);
- if (!ask_steam_program(id)) start_live_install(id);
+ // Install at once when the game fits the default drive (or its size is checked later);
+ // otherwise the sheet says why and offers another drive for this install.
+ install_volume_id_.clear();
+ if (id.valid() && live_install_allowed(assess_install(state_, id, selected_volume_id_, steam::kInstallSpaceMargin).readiness,
+ free_space_supported_))
+ pending_install_requests_.push_back({InstallRequestKind::Install, id});
+ else if (id.valid())
+ open_modal({"install", "Install game", "details-install", {"install-confirm", "storage-picker", "cancel"}, 0, false});
+ } else if (live() && action_name == "steam-programs") {
+ open_steam_programs(state_.navigation.detail_id.value_or(state_.navigation.selected_game_id));
} else if (live() && action_name.rfind("steam-program-", 0) == 0) {
const auto index = static_cast<std::size_t>(std::stoul(action_name.substr(14)));
if (index >= steam_programs_shown_.size()) return;
const auto id = steam_programs_game_;
- choose_steam_launch(id, steam_programs_shown_[index].path);
close_modal();
- start_live_install(id);
+ choose_steam_launch(id, steam_programs_shown_[index].path);
} else if (live() && action_name == "open-downloads") {
state_.navigation.route = Route::Downloads;
state_.navigation.focus_key = "job-" + ToKey(state_.navigation.detail_id.value_or(GameId{}));
@@ -8014,8 +8007,11 @@ void Simulation::SetGeneratedRecipes(const std::vector<rt::GameRecipe>& recipes)
void Simulation::SetGameSetups(std::map<GameId, LiveGameSetup> setups) {
const auto same = [](const LiveGameSetup& a, const LiveGameSetup& b) {
if (a.scanned != b.scanned || a.refusal_soft != b.refusal_soft || a.refusal != b.refusal ||
- a.programs.size() != b.programs.size() || a.draft.has_value() != b.draft.has_value())
+ a.programs.size() != b.programs.size() || a.draft.has_value() != b.draft.has_value() ||
+ a.steam_choices.size() != b.steam_choices.size())
return false;
+ for (std::size_t index = 0; index < a.steam_choices.size(); ++index)
+ if (a.steam_choices[index].path != b.steam_choices[index].path) return false;
for (std::size_t index = 0; index < a.programs.size(); ++index)
if (a.programs[index].path != b.programs[index].path ||
a.programs[index].architecture != b.programs[index].architecture ||
@@ -8027,9 +8023,23 @@ 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.
+ for (const auto& [id, setup] : game_setups_) {
+ if (setup.steam_choices.empty() || asked_before.count(id)) 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)) {
+ push_notice({"steam-programs-" + ToKey(id), "Choose the program for " + game->title, "", false,
+ kLiveNoticeSeconds * 2, false, "Steam lists more than one. Choose Program on the game's page."});
+ }
+ }
refresh_game_settings();
open_settings_after_prepare();
// An open Program picker shows the scan's programs as soon as they arrive.
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 4cb67e7..0984b70 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -122,6 +122,12 @@ struct LiveSelfUpdate {
bool finished_failed = false;
};
// Live: what Game settings needs to choose a game's program, projected from the runtime host.
+// A program a Steam launch option names, as a path in the game folder.
+struct LaunchProgram {
+ std::string path;
+ bool helper = false; // an installer or tool (the import rules)
+};
+
struct LiveGameSetup {
std::vector<playden::runtime::GameProgram> programs; // the game folder's Windows programs
bool scanned = false;
@@ -130,6 +136,9 @@ struct LiveGameSetup {
std::optional<playden::runtime::GameRecipe> draft;
bool refusal_soft = false;
std::string refusal;
+ // Steam's options are all for other branches and more than one program is in the folder:
+ // setting up waits for the player's choice (the Play row and a sheet ask).
+ std::vector<LaunchProgram> steam_choices;
};
// Live per-game runtime (private bottle and PS5 title) state, projected from the runtime host.
struct LiveRuntimeGame {
@@ -356,12 +365,6 @@ inline bool operator==(PersistenceLoadToken left, PersistenceLoadToken right) {
return left.id == right.id && left.baseline_revision == right.baseline_revision;
}
-// A program a Steam launch option names, as a path in the game folder.
-struct LaunchProgram {
- std::string path;
- bool helper = false; // an installer or tool (the import rules)
-};
-
struct Game {
GameId id;
std::string title;
@@ -380,9 +383,6 @@ struct Game {
std::optional<std::int64_t> last_played;
std::optional<std::uint64_t> playtime_minutes;
std::optional<bool> windows_installable; // from Steam app info; absent until fetched
- // Steam lists no option for the public branch: the programs of every branch's options, which
- // Install asks the player to choose from when more than one could be the game.
- std::vector<LaunchProgram> launch_programs;
bool art_pending = false;
bool art_failed = false;
};
@@ -779,8 +779,7 @@ public:
void SetFreeSpaceSupported(bool supported) noexcept { free_space_supported_ = supported; }
// Live mode: Steam app-info estimates for one game (download/install size, installability).
bool UpdateAppDetails(GameId id, std::optional<std::uint64_t> download_bytes,
- std::optional<std::uint64_t> install_bytes, std::optional<bool> windows_installable,
- std::vector<LaunchProgram> launch_programs = {});
+ std::optional<std::uint64_t> install_bytes, std::optional<bool> windows_installable);
// Live mode: the Steam store's description, genres and controller support for one game;
// kept across library refreshes.
void UpdateStoreDetails(GameId id, std::string description, std::vector<std::string> genres,
@@ -1082,12 +1081,10 @@ private:
// Imported games playing in place from their folder (State::external_games), and a copy running.
[[nodiscard]] const LiveExternalGame* external_game(GameId id) const;
[[nodiscard]] const Job* import_copy_job(GameId id) const;
- // Install for a Steam game whose launch options name no clear program asks for one first
- // (the import rules: installers and tools last, one clear program isn't asked for).
- [[nodiscard]] static std::vector<LaunchProgram> steam_programs(const Game& game);
- bool ask_steam_program(GameId id);
+ // A game whose setup waits for its program (LiveGameSetup::steam_choices): the sheet that asks,
+ // installers and tools last, and the choice, which sets the game up again.
+ void open_steam_programs(GameId id);
void choose_steam_launch(GameId id, const std::string& program);
- void start_live_install(GameId id);
std::vector<LaunchProgram> steam_programs_shown_;
GameId steam_programs_game_;
std::size_t import_program_index_ = 0;
diff --git a/src/homebrew/view.cpp b/src/homebrew/view.cpp
index 1af7439..e2b51eb 100644
--- a/src/homebrew/view.cpp
+++ b/src/homebrew/view.cpp
@@ -3430,7 +3430,7 @@ class Render::Impl
static const std::map<std::string, std::string> names = {
{"choice-picker", "Game settings"}, {"preset-picker", "Game settings"}, {"button-mapping", "Game settings"},
{"game-settings", "Playden"}, {"game-maintenance", "Playden"}, {"kept-data", "Settings"}, {"installed-games", "Settings"},
- {"import-games", "Library"}, {"import-programs", "Import games"}, {"steam-programs", "Install"}, {"import-choice", "Import games"},
+ {"import-games", "Library"}, {"import-programs", "Import games"}, {"steam-programs", "Setup"}, {"import-choice", "Import games"},
{"import-storage", "Import games"},
{"job-actions", "Downloads"}, {"prep-actions", "Preparation"}, {"storage-details", "Storage"}, {"context", "Game"}, {"compatibility", "Game"}, {"collections", "Game"}, {"collections-manage", "Library"},
{"filters", "Library"}, {"logs-controls", "Logs"}, {"setting-value", "Settings"}, {"diagnostics", "Settings"},
diff --git a/tests/homebrew_library_graphical_test.cpp b/tests/homebrew_library_graphical_test.cpp
index dfba9b1..8e3d064 100644
--- a/tests/homebrew_library_graphical_test.cpp
+++ b/tests/homebrew_library_graphical_test.cpp
@@ -160,17 +160,23 @@ int main(int argc,char** argv) {
capture_update("release-notes-short.png");
}
{
- // Steam's options name no clear program: Install asks which one starts the game.
+ // Steam's options name no clear program: setting up asks which one starts the game.
Simulation live({}, {}, ModelMode::Live);
live.UpdateAccount({AuthState::SignedIn,"123","Synthetic account",{},{},true});
assert(live.UpdateLibrary({backend.games,false,{},false,false,{}}));
- live.UpdateVolumes({{"internal","Console storage",true,200'000'000'000,1'000'000'000}},"internal");
- live.UpdateAppDetails(SteamId(42), 300'000'000, 600'000'000, true,
- {{"RSDragonwilds.exe",false},{"Aqua-Coyote.exe",false},{"Redist/Setup.exe",true}});
- assert(live.action("details:42") && live.action("focus:details-install") && live.action("cross"));
+ live.UpdateInstalls({}, {{SteamId(42), 600'000'000}});
+ LiveRuntimeGame waiting; waiting.game_id=SteamId(42); waiting.status="Not prepared"; waiting.can_prepare=true;
+ live.UpdateRuntime(RuntimeState::Ready, {waiting});
+ assert(live.action("details:42"));
+ playden::homebrew::LiveGameSetup setup;
+ setup.steam_choices={{"x64/Launcher64.exe",false},{"x86/Launcher.exe",false},{"Redist/Setup.exe",true}};
+ live.SetGameSetups({{SteamId(42),setup}});
assert(live.view().surface=="steam-programs");
for(int i=0;i<16;++i) renderer.draw(live,1920,1080);
assert(renderer.capture_png(output/"steam-programs.png",1920,1080));
+ assert(live.action("focus:cancel") && live.action("cross"));
+ for(int i=0;i<16;++i) renderer.draw(live,1920,1080);
+ assert(renderer.capture_png(output/"steam-programs-play.png",1920,1080));
}
{
// An installed, prepared game: Play is the same height as the other actions,
diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cpp
index 8400433..55378ea 100644
--- a/tests/homebrew_live_model_test.cpp
+++ b/tests/homebrew_live_model_test.cpp
@@ -805,63 +805,63 @@ void live_imported_program_seeds_once(const std::filesystem::path& base) {
"seed: saved at once");
}
-// Steam options only for other branches don't say which program starts the game: Install asks
-// when two or more could be it, and asks nothing for one clear program (the import rules).
-void live_install_asks_for_a_steam_program(const std::filesystem::path& base) {
- using playden::homebrew::InstallRequestKind;
- using playden::homebrew::LaunchProgram;
+// Steam options only for other branches don't say which program starts the game: once the download is
+// there, setting up waits for the player's choice. The sheet lists installers and tools last, and the
+// choice is kept as Steam's option (steam_launch), not as a Program, and sets the game up again.
+void live_setup_asks_for_a_steam_program(const std::filesystem::path& base) {
+ using playden::homebrew::LiveGameSetup;
std::filesystem::create_directories(base);
auto model = make_live(base);
model.SetGameSettingsFile(base / "steam-program-settings.json");
model.UpdateAccount({AuthState::SignedIn, "account", "Owner", {}, {}, false});
- playden::GameSummary dragonwilds;
- dragonwilds.id = SteamId(1374490);
- dragonwilds.title = "RuneScape: Dragonwilds";
- playden::GameSummary strive;
- strive.id = SteamId(1384160);
- strive.title = "GUILTY GEAR -STRIVE-";
- check(model.UpdateLibrary({{dragonwilds, strive}, false, {}, false, true, 100}), "steam program: library delivered");
- model.UpdateVolumes({{"internal", "Console storage", true, 200'000'000'000, 1'000'000'000}}, "internal");
-
- check(model.action("details:1374490") &&
- model.UpdateAppDetails(SteamId(1374490), 100, 200, true,
- {{"RSDragonwilds.exe", false}, {"Aqua-Coyote.exe", false}, {"Setup.exe", true}}),
- "steam program: details with two programs");
- activate(model, "details-install");
- check(model.view().surface == "steam-programs" && model.TakeInstallRequests().empty(),
- "steam program: Install asks first");
- check(model.state().navigation.modals.back().action_keys.size() == 4, "steam program: every program and Cancel");
- activate(model, "cancel");
- check(model.view().surface != "steam-programs" && model.TakeInstallRequests().empty() &&
- !model.state().game_settings.count(SteamId(1374490)),
- "steam program: Cancel installs nothing");
- activate(model, "details-install");
+ playden::GameSummary monster;
+ monster.id = SteamId(449610);
+ monster.title = "Monster Boy";
+ playden::GameSummary other;
+ other.id = SteamId(220);
+ other.title = "Half-Life 2";
+ check(model.UpdateLibrary({{monster, other}, false, {}, false, true, 100}), "steam program: library delivered");
+ model.UpdateInstalls({}, {{SteamId(449610), 1024, "internal", true}});
+ playden::homebrew::LiveRuntimeGame runtime;
+ runtime.game_id = SteamId(449610);
+ runtime.status = "Not prepared";
+ runtime.can_prepare = true;
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});
+ LiveGameSetup setup;
+ setup.steam_choices = {{"x86/Setup.exe", true}, {"x64/Launcher64.exe", false}, {"x86/Launcher.exe", false}};
+
+ // Elsewhere, a notification says so; the game's Play row asks.
+ check(model.action("details:220"), "steam program: another page");
+ model.SetGameSetups({{SteamId(449610), setup}});
+ check(std::any_of(model.state().notices.begin(), model.state().notices.end(),
+ [](const auto& notice) { return notice.id.rfind("steam-programs-", 0) == 0; }) &&
+ model.state().navigation.modals.empty(),
+ "steam program: a notification away from the game's page");
+ check(model.action("details:449610"), "steam program: its page");
+ const auto play = std::find_if(model.view().rows.begin(), model.view().rows.end(),
+ [](const auto& row) { return row.key == "details-play"; });
+ check(play != model.view().rows.end() && play->title == "Choose program" && play->enabled, "steam program: Play asks");
+ activate(model, "details-play");
+ check(model.view().surface == "steam-programs" && model.state().navigation.modals.back().action_keys.size() == 4,
+ "steam program: every program and Cancel");
+ const auto title = [&](const std::string& key) {
+ for (const auto& row : model.view().rows) if (row.action == key) return row.title;
+ return std::string();
+ };
+ check(title("steam-program-0") == "x64/Launcher64.exe" && title("steam-program-2") == "x86/Setup.exe",
+ "steam program: installers and tools last");
activate(model, "steam-program-1");
- auto requests = model.TakeInstallRequests();
- check(requests.size() == 1 && requests[0].kind == InstallRequestKind::Install && requests[0].game_id == SteamId(1374490),
- "steam program: choosing one installs");
- check(model.state().game_settings.at(SteamId(1374490)).steam_launch == "Aqua-Coyote.exe" &&
- model.state().game_settings.at(SteamId(1374490)).overrides.empty(),
- "steam program: the choice is kept as Steam's option, not as a Program");
- activate(model, "details-install");
- check(model.view().surface != "steam-programs" && model.TakeInstallRequests().size() == 1,
- "steam program: an earlier choice isn't asked for again");
-
- // One program besides installers and tools: no question.
- check(model.action("details:1384160") &&
- model.UpdateAppDetails(SteamId(1384160), 100, 200, true, {{"GGST.exe", false}, {"Redist/vcredist.exe", true}}),
- "steam program: details with one clear program");
- activate(model, "details-install");
- requests = model.TakeInstallRequests();
- check(model.view().surface != "steam-programs" && requests.size() == 1 && requests[0].game_id == SteamId(1384160),
- "steam program: one clear program installs at once");
- check(!model.state().game_settings.count(SteamId(1384160)), "steam program: Steam's first option needs no setting");
- // An installer or tool listed before the game: the game's option goes first.
- check(model.UpdateAppDetails(SteamId(1384160), 100, 200, true, {{"Redist/vcredist.exe", true}, {"GGST.exe", false}}),
- "steam program: details with a tool first");
- activate(model, "details-install");
- check(model.TakeInstallRequests().size() == 1 && model.state().game_settings.at(SteamId(1384160)).steam_launch == "GGST.exe",
- "steam program: the clear program goes before the tool");
+ const auto& record = model.state().game_settings.at(SteamId(449610));
+ check(record.steam_launch == "x86/Launcher.exe" && record.overrides.empty(),
+ "steam program: kept as Steam's option, not as a Program");
+ 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");
+
+ // Over the game's own page, the sheet opens by itself.
+ model.SetGameSetups({});
+ model.SetGameSetups({{SteamId(449610), setup}});
+ check(model.view().surface == "steam-programs", "steam program: the sheet opens over the game's page");
}
} // namespace
@@ -879,7 +879,7 @@ int main() {
live_program_change_applies_like_other_settings(base);
live_imported_game_steam_app_id(base);
live_imported_program_seeds_once(base);
- live_install_asks_for_a_steam_program(base);
+ live_setup_asks_for_a_steam_program(base);
live_starts_clean_and_never_reads_or_writes_fixtures(base);
live_dispatches_bounded_service_effects_and_replaces_challenges(base);
failed_signout_preserves_account_until_external_clear(base);
diff --git a/tests/homebrew_runtime_host_test.cpp b/tests/homebrew_runtime_host_test.cpp
index 7256236..6e1a184 100644
--- a/tests/homebrew_runtime_host_test.cpp
+++ b/tests/homebrew_runtime_host_test.cpp
@@ -2688,6 +2688,70 @@ void SteamEntryWithoutFolderStartsInInstallRoot() {
host.Shutdown();
}
+// Steam's options all for other branches (Monster Boy lists x64/Launcher64.exe and x86/Launcher.exe
+// for a debug branch): preparing waits for the player's choice when two of their programs are in the
+// folder, then starts the chosen one as Steam's option. One clear program is used without asking.
+void PreparesSteamProgramChosenAfterDownload() {
+ Fixture fixture;
+ auto config = fixture.Config();
+ config.host_namespace_prefix = fixture.root;
+ config.package_paths.console_data_root = "/data";
+ config.package_paths.host_data_root = fixture.root / "data";
+ config.package_operations.hash_file = HashArtifactFile;
+ config.package_operations.hash_bytes = HashArtifactBytes;
+ config.package_operations.free_space_unverifiable = true;
+ config.package_operations.validate_bottle = [](const fs::path& bottle) {
+ return fs::is_regular_file(bottle / "system.reg") && fs::is_regular_file(bottle / "user.reg");
+ };
+ const auto kit = SyntheticKit(fixture.root / "kit");
+ config.admit_kit = [&kit](std::string*) { return std::optional<RuntimeKit>(kit); };
+ unsigned uuids = 0;
+ config.uuid = [&uuids]() -> std::optional<std::string> {
+ ++uuids; return std::string("00000000-0000-4000-8000-00000000000") + std::to_string(uuids);
+ };
+ config.unix_time = [] { return std::int64_t{1760000000}; };
+ config.session_data_root = fixture.root / "data";
+ const auto game = fixture.root / "data/homebrew/FAKE77031/games/449610";
+ std::string pe(0x80 + 26, '\0');
+ pe[0] = 'M'; pe[1] = 'Z'; pe[0x3c] = 0x40; pe[0x40] = 'P'; pe[0x41] = 'E';
+ pe[0x44] = 0x64; pe[0x45] = static_cast<char>(0x86); pe[0x40 + 24] = 0x0b; pe[0x40 + 25] = 0x02;
+ std::filesystem::create_directories(game / "x64");
+ std::filesystem::create_directories(game / "x86");
+ Write(game / "x64/Launcher64.exe", pe, 0644);
+ Write(game / "x86/Launcher.exe", pe, 0644);
+ CHECK(chmod(game.c_str(), 0755) == 0);
+ GameSettingsRecord saved;
+ config.settings_record = [&](const playden::GameId&) -> std::optional<GameSettingsRecord> { return saved; };
+ RuntimePrepareRequest request{449610, "/data/homebrew/FAKE77031/games/449610", "internal", "Monster Boy"};
+ // Missing.exe (another branch's program) isn't in the download, so it isn't offered.
+ request.launches = {{"", "", "x64\\Launcher64.exe", "", ""}, {"", "", "Missing.exe", "", ""},
+ {"", "", "x86\\Launcher.exe", "", "-safe"}};
+ request.launches_any_branch = true;
+
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ CHECK(WaitFor(host, Started).kit_available);
+ host.Prepare(request);
+ const auto asked = WaitFor(host, [](const RuntimeSnapshot& s) { return s.refusals.count(449610) != 0; });
+ CHECK(asked.refusals.at(449610).find("Choose the program") != std::string::npos && asked.installs.empty());
+ const auto& choices = asked.game_setups.at(449610).steam_choices;
+ CHECK(choices.size() == 2 && choices[0].path == "x64/Launcher64.exe" && choices[1].path == "x86/Launcher.exe" &&
+ !choices[0].helper && !asked.game_setups.at(449610).draft);
+
+ // The player chooses the second: it is prepared as Steam's option, with Steam's arguments.
+ saved.steam_launch = "x86/Launcher.exe";
+ host.Prepare(request);
+ const auto done = WaitFor(host, [](const RuntimeSnapshot& s) {
+ return !s.preparing_app && !s.installs.empty() && s.installs[0].state == PreparationState::kReady;
+ }, 60);
+ if (done.refusals.count(449610)) std::fprintf(stderr, "refused: %s\n", done.refusals.at(449610).c_str());
+ CHECK(!done.refusals.count(449610) && done.game_setups.at(449610).steam_choices.empty());
+ CHECK(done.generated_recipes.size() == 1 && done.generated_recipes[0].launch_entries[0].executable == "x86/Launcher.exe" &&
+ done.generated_recipes[0].launch_entries[0].id != kProgramEntryId &&
+ done.generated_recipes[0].launch_entries[0].arguments == "-safe");
+ host.Shutdown();
+}
+
void PreparesProgramChosenInSettings() {
Fixture fixture;
auto config = fixture.Config();
@@ -4566,6 +4630,7 @@ int main(int argc, char** argv) {
PreparationEndsAwaitingRegistration();
PreparesGameWithoutShippedRecipe();
PreparesProgramChosenInSettings();
+ PreparesSteamProgramChosenAfterDownload();
SteamEntryWithoutFolderStartsInInstallRoot();
PreparesUdkGameWithEulaAccepted();
ResumesInterruptedCaptureFromSavedRequest();