Skip to content

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

C++

Reset Program to Steam's launch option, not the old pick

Leonardo Lobatof202a9df702f
diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cpp
index 358e187..ab46efe 100644
--- a/src/runtime/game_settings.cpp
+++ b/src/runtime/game_settings.cpp
@@ -309,6 +309,15 @@ const LaunchEntry* FindEntry(const GameRecipe& recipe, std::string_view id) {
return nullptr;
}
+// The launch entry that starts without a choice: the recipe's first. A recipe generated for a
+// program the player chose lists it first; without that choice the next preparation drops it,
+// so the default is the first of Steam's entries. A recipe with only the player's program keeps it.
+std::string DefaultLaunchEntry(const GameRecipe& recipe) {
+ for (const auto& entry : recipe.launch_entries)
+ if (entry.id != kProgramEntryId) return entry.id;
+ return recipe.launch_entries.empty() ? std::string() : recipe.launch_entries.front().id;
+}
+
// A row that settings built by hand (older callers, tests) may leave out reads as unavailable.
const EffectiveValue& OptionalValue(const EffectiveSettings& settings, const char* id) {
static const EffectiveValue missing = [] {
@@ -506,9 +515,7 @@ bool BuildEffectiveSettings(const GameRecipe& recipe, const SettingsPreset* pres
EffectiveSettings out;
for (const auto& definition : SettingsCatalogue()) {
EffectiveValue value;
- value.value = definition.id == "launch_option"
- ? (recipe.launch_entries.empty() ? std::string() : recipe.launch_entries.front().id)
- : definition.playden_default;
+ value.value = definition.id == "launch_option" ? DefaultLaunchEntry(recipe) : definition.playden_default;
const auto layer = [&](const std::map<std::string, std::string>& source, ValueSource kind) {
const auto found = source.find(definition.id);
if (found == source.end()) return true;
diff --git a/tests/game_settings_test.cpp b/tests/game_settings_test.cpp
index 1d40f7e..bb97131 100644
--- a/tests/game_settings_test.cpp
+++ b/tests/game_settings_test.cpp
@@ -66,6 +66,23 @@ int main(int argc, char** argv) {
CHECK(ValidateSettingValue(hl2, definition.id, definition.playden_default, &reason));
}
+ // DefaultSkipsPlayerProgram: a recipe generated for the player's program lists it first; without
+ // that choice the default is Steam's entry, as the next preparation makes it, and the choice still finds it.
+ {
+ GameRecipe chosen = hl2;
+ chosen.launch_entries = {{kProgramEntryId, "FalloutNV.exe", "FalloutNV.exe", "", ""},
+ {"launch-1", "Launcher", "FalloutNVLauncher.exe", "", ""}};
+ EffectiveSettings values;
+ SettingsError problem;
+ CHECK(BuildEffectiveSettings(chosen, nullptr, {}, KitCapabilities{}, &values, &problem));
+ CHECK(values.launch && values.launch->id == "launch-1");
+ CHECK(BuildEffectiveSettings(chosen, nullptr, {{"program", "FalloutNV.exe"}}, KitCapabilities{}, &values, &problem));
+ CHECK(values.launch && values.launch->id == kProgramEntryId && values.launch->executable == "FalloutNV.exe");
+ chosen.launch_entries.resize(1);
+ CHECK(BuildEffectiveSettings(chosen, nullptr, {}, KitCapabilities{}, &values, &problem));
+ CHECK(values.launch && values.launch->id == kProgramEntryId);
+ }
+
// RecipeArgumentsPreserved: with no overrides the HL2 recipe gives the owner-verified profile.
const ProfileTarget target{"playden-steam-220", "/data/homebrew/FAKE77031/games/220"};
EffectiveSettings settings;
diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cpp
index 6574604..25d3c76 100644
--- a/tests/homebrew_live_model_test.cpp
+++ b/tests/homebrew_live_model_test.cpp
@@ -404,6 +404,21 @@ void live_program_change_offers_recreate_bottle(const std::filesystem::path& bas
runtime.launch_path = "Other/Other.exe";
model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});
check(marked(), "recreate: one folder program replacing another is marked too");
+
+ // Recreated for the chosen program, the recipe lists it first. Reset to recipe goes back to Steam's
+ // launch option, which the next preparation makes, so it needs the bottle made again too.
+ recipe.launch_entries.insert(recipe.launch_entries.begin(), {"program", "FalloutNV.exe", "FalloutNV.exe", "", ""});
+ model.SetGeneratedRecipes({recipe});
+ runtime.launch_path = "FalloutNV.exe";
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});
+ check(!marked(), "recreate: the recreated bottle matches the settings");
+ activate(model, "details-more");
+ activate(model, "game-settings");
+ activate(model, "setting-launch_option");
+ activate(model, "value-reset");
+ check(model.action("circle") && !model.state().navigation.modals.empty() &&
+ model.state().navigation.modals.back().title == "Recreate the bottle now?",
+ "recreate: Reset to recipe offers Recreate bottle");
}
} // namespace