Skip to content

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

C++

Show program file names first in program lists

Leonardo Lobatoc94b3d32176d
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index da8fe33..bf91b41 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -76,6 +76,19 @@ struct StringBuilder {
StringBuilder& operator<<(const GameId& id) { value.append(id.valid() ? ToKey(id) : "0"); return *this; }
};
+// A program in a list of a game's programs: its file name is what tells it from the others, with its whole
+// folder and anything else to say about it on the line under the name.
+std::string program_file_name(const std::string& path) {
+ const auto slash = path.find_last_of('/');
+ return slash == std::string::npos ? path : path.substr(slash + 1);
+}
+
+std::string program_note(const std::string& path, const std::string& note) {
+ const auto slash = path.find_last_of('/');
+ const auto folder = slash == std::string::npos ? std::string() : path.substr(0, slash);
+ return folder.empty() || note.empty() ? folder + note : folder + " · " + note;
+}
+
std::string read_file(const std::filesystem::path& path) {
std::FILE* input = std::fopen(path.string().c_str(), "rb");
if (!input) return {};
@@ -6270,18 +6283,18 @@ void Simulation::rebuild_view() {
else if (modal.id == "steam-programs" && action_key.rfind("steam-program-", 0) == 0) {
const auto index = static_cast<std::size_t>(std::stoul(action_key.substr(14)));
if (index < steam_programs_shown_.size()) {
- item.title = steam_programs_shown_[index].path;
- if (steam_programs_shown_[index].helper) item.subtitle = "Installer or tool";
+ item.title = program_file_name(steam_programs_shown_[index].path);
+ item.subtitle = program_note(steam_programs_shown_[index].path,
+ steam_programs_shown_[index].helper ? "Installer or tool" : "");
}
}
else if (import_programs && action_key.rfind("import-program-", 0) == 0) {
const auto index = static_cast<std::size_t>(std::stoul(action_key.substr(15)));
if (index < import_programs->programs.size()) {
const auto& program = import_programs->programs[index];
- item.title = program.path;
+ item.title = program_file_name(program.path);
item.value = format_bytes(program.bytes);
- if (program.helper) item.subtitle = "Installer or tool";
-
+ item.subtitle = program_note(program.path, program.helper ? "Installer or tool" : "");
}
}
else if (modal.id == "import-choice" && action_key == "import-play-in-place") {
@@ -6400,11 +6413,12 @@ void Simulation::rebuild_view() {
const auto index = static_cast<std::size_t>(std::stoul(action_key.substr(14)));
if (setup != game_setups_.end() && index < setup->second.programs.size()) {
const auto& program = setup->second.programs[index];
- item.title = program.path;
+ item.title = program_file_name(program.path);
const auto detected = rt::DetectedLabel(program.detected);
- item.subtitle = program.architecture.empty() ? "Not a Windows program the PS5 can start."
- : !program.refusal.empty() ? program.refusal
- : (program.architecture == "pe64" ? "64-bit" : "32-bit") + (detected.empty() ? std::string() : " · " + detected);
+ item.subtitle = program_note(program.path, program.architecture.empty() ? "Not a Windows program the PS5 can start."
+ : program.refusal);
+ if (!program.architecture.empty() && program.refusal.empty())
+ item.value = (program.architecture == "pe64" ? "64-bit" : "32-bit") + (detected.empty() ? std::string() : " · " + detected);
item.enabled = !program.architecture.empty() && program.refusal.empty();
rt::EffectiveSettings values;
if (EffectiveSettingsFor(state_.navigation.selected_game_id, &values) && values.launch &&
diff --git a/src/homebrew/view.cpp b/src/homebrew/view.cpp
index 6d03a8a..8d56969 100644
--- a/src/homebrew/view.cpp
+++ b/src/homebrew/view.cpp
@@ -3844,7 +3844,8 @@ class Render::Impl
view.surface == "storage" || view.surface == "move-storage" || view.surface == "install" || view.surface == "update" || view.surface == "kept-data" || view.surface == "leftover-titles" ||
view.surface == "download-server" ||
view.surface == "import-games" ||
- view.surface == "import-programs" || view.surface == "steam-programs";
+ view.surface == "import-programs" || view.surface == "steam-programs" ||
+ view.surface == "setup-programs";
const float width = overlay_transition_.panel_width(wide ? 960.0F : 640.0F);
const gfx::Rect panel{kWidth - width + (1.0F - ease) * width, 0.0F, width, kHeight};
overlay_.shadow({panel.x - 18.0F, 0.0F, panel.w + 18.0F, panel.h}, 0.0F, 36.0F,
@@ -4243,9 +4244,9 @@ class Render::Impl
std::string label = row.title.empty() ? row.action : row.title;
if (row.title.empty())
std::replace(label.begin(), label.end(), '-', ' ');
- // A program path ("redist/setup.exe") is shown as it is on the drive.
+ // A program's file name ("setup.exe") is shown as it is on the drive.
if (!label.empty() && label.front() >= 'a' && label.front() <= 'z' && row.action.rfind("import-program-", 0) != 0 &&
- row.action.rfind("steam-program-", 0) != 0)
+ row.action.rfind("steam-program-", 0) != 0 && row.action.rfind("setup-program-", 0) != 0)
label.front() = static_cast<char>(label.front() - 'a' + 'A');
return label;
}
@@ -4289,7 +4290,8 @@ class Render::Impl
view.surface == "game-maintenance";
// The Import sheets: each folder's path (or why it can't be added) under its name.
const bool import_sheet = view.surface == "import-games" || view.surface == "import-programs" ||
- view.surface == "import-choice" || view.surface == "steam-programs";
+ view.surface == "import-choice" || view.surface == "steam-programs" ||
+ view.surface == "setup-programs";
// About: each fact as its name over its value and note, at the row's full width, wrapped and never cut.
const bool about_sheet = view.surface == "about";
const auto about_lines = [&](const std::string &text, float size) {
@@ -4301,11 +4303,17 @@ class Render::Impl
return 58.0F + 30.0F * std::max(1.0F, about_lines(overlay_value(row), 24.0F)) +
26.0F * std::max(1.0F, about_lines(row.subtitle, 19.0F));
};
- // The import wizard's hints wrap onto a second line rather than being cut.
+ // The import wizard's hints wrap onto a second line rather than being cut, and a program's folder
+ // takes the lines it needs: the folder is how to tell programs of the same name apart.
const float hint_width = bounds.w - 48.0F;
+ const bool program_list = view.surface == "import-programs" || view.surface == "steam-programs" ||
+ view.surface == "setup-programs";
const auto hint_extra = [&](const ViewRow &row) {
- return view.surface == "import-choice" && !row.subtitle.empty() &&
- fonts_.regular.measure(row.subtitle, 19.0F) > hint_width
+ if (row.subtitle.empty())
+ return 0.0F;
+ if (program_list)
+ return 26.0F * static_cast<float>(std::max<std::size_t>(fonts_.regular.font->wrap(row.subtitle, 19.0F, hint_width).size(), 1) - 1);
+ return view.surface == "import-choice" && fonts_.regular.measure(row.subtitle, 19.0F) > hint_width
? 26.0F
: 0.0F;
};
@@ -4476,6 +4484,9 @@ class Render::Impl
// Under the value's line: the whole width, on two lines when it needs them.
ui::paragraph(overlay_, fonts_.regular, row.subtitle, rect.x + 24.0F, rect.y + 74.0F, 19.0F, hint_width,
26.0F, row.enabled ? kSecondary : kMuted, 2);
+ else if (described && program_list)
+ ui::paragraph(overlay_, fonts_.regular, row.subtitle, rect.x + 24.0F, rect.y + 74.0F, 19.0F, hint_width,
+ 26.0F, row.enabled ? kSecondary : kMuted);
else if (described)
ui::text(overlay_, fonts_.regular, fit(fonts_.regular, row.subtitle, 19.0F, rect.w - 72.0F - value_width),
checkbox ? name_x : rect.x + 24.0F, rect.y + 74.0F, 19.0F,
diff --git a/tests/homebrew_library_graphical_test.cpp b/tests/homebrew_library_graphical_test.cpp
index 2d14ea0..8718ab8 100644
--- a/tests/homebrew_library_graphical_test.cpp
+++ b/tests/homebrew_library_graphical_test.cpp
@@ -207,6 +207,28 @@ int main(int argc,char** argv) {
assert(renderer.capture_png(output/name,1920,1080));
};
capture_live("details-play.png");
+ {
+ // A game's programs: same file names in long folders still read apart.
+ std::map<GameId, LiveGameSetup> setups;
+ setups[SteamId(42)].scanned = true;
+ const std::string root = "X-Men Origins - Wolverine(TM)/";
+ setups[SteamId(42)].programs = {
+ {root + "Binaries/Wolverine.exe", "pe32", "", false, ""},
+ {root + "_Redist/Visual C++ Redistributable/VC 2008/vcredist_x86.exe", "pe32", "", true, ""},
+ {root + "_Redist/Visual C++ Redistributable/VC 2010/vcredist_x86.exe", "pe32", "", true, ""},
+ {root + "_Redist/Visual C++ Redistributable/VC 2010/vcredist_x64.exe", "pe64", "", true, ""},
+ {root + "_Redist/DirectX/dxwebsetup.exe", "pe32", "Uses a missing DLL.", true, ""},
+ {root + "_Redist/A very long folder name for a publisher tool that needs a second line to fit under the name/Tool.exe", "pe32", "", true, ""}};
+ live.SetGameSetups(setups);
+ LiveRuntimeGame prepared=ready; prepared.prepared=true;
+ live.UpdateRuntime(RuntimeState::Ready, {prepared});
+ assert(live.action("focus:details-more") && live.action("cross"));
+ assert(live.action("focus:run-once") && live.action("cross"));
+ capture_live("setup-programs.png");
+ while(!live.state().navigation.modals.empty()) assert(live.action("circle"));
+ live.SetGameSetups({});
+ live.UpdateRuntime(RuntimeState::Ready, {ready});
+ }
ready.can_play=false; ready.play_status="Starting…";
live.UpdateRuntime(RuntimeState::Ready, {ready});
capture_live("details-play-disabled.png");
diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cpp
index 3233d3f..23d1f8b 100644
--- a/tests/homebrew_live_model_test.cpp
+++ b/tests/homebrew_live_model_test.cpp
@@ -727,6 +727,10 @@ void live_runs_setup_program_once(const std::filesystem::path& base) {
check(find_row(model, "setup-program-0")->enabled && find_row(model, "setup-program-1")->value == "The game" &&
!find_row(model, "setup-program-2")->enabled,
"setup program: the picker names the game's program and refuses what can't start");
+ check(find_row(model, "setup-program-0")->title == "BmLauncher.exe" && find_row(model, "setup-program-0")->subtitle == "Binaries" &&
+ find_row(model, "setup-program-0")->value == "32-bit" &&
+ find_row(model, "setup-program-2")->subtitle == "Binaries · Uses a missing DLL.",
+ "setup program: the file name, with its folder and any refusal under it");
(void)model.TakeProgramScanRequests();
activate(model, "setup-program-0");
check(model.state().navigation.modals.back().title == "Run BmLauncher.exe once?" &&
@@ -1450,8 +1454,11 @@ void live_setup_asks_for_a_steam_program(const std::filesystem::path& base) {
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",
+ check(title("steam-program-0") == "Launcher64.exe" && title("steam-program-2") == "Setup.exe",
"steam program: installers and tools last");
+ check(find_row(model, "steam-program-0")->subtitle == "x64" &&
+ find_row(model, "steam-program-2")->subtitle == "x86 · Installer or tool",
+ "steam program: the folder sits under the file name");
activate(model, "steam-program-1");
const auto& record = model.state().game_settings.at(SteamId(449610));
check(record.steam_launch == "x86/Launcher.exe" && record.overrides.empty(),
diff --git a/tests/homebrew_simulation_test.cpp b/tests/homebrew_simulation_test.cpp
index ee85539..f4fb25f 100644
--- a/tests/homebrew_simulation_test.cpp
+++ b/tests/homebrew_simulation_test.cpp
@@ -1301,8 +1301,8 @@ static void t17_import_sheet(const std::filesystem::path& fixtures, const std::f
press("import-candidate-usb0:playden/import/Old School Rally");
check(simulation.view().surface == "import-programs" && simulation.view().title == "Old School Rally" &&
row("import-program-0")->title == "OldSchoolRally.exe" && row("import-program-0")->subtitle.empty() &&
- row("import-program-1")->title == "Benchmark/RallyBench.exe" && row("import-program-1")->subtitle.empty() &&
- row("import-program-2")->subtitle == "Installer or tool" && simulation.view().rows.back().title == "Back" &&
+ row("import-program-1")->title == "RallyBench.exe" && row("import-program-1")->subtitle == "Benchmark" &&
+ row("import-program-2")->subtitle.find("Installer or tool") != std::string::npos && simulation.view().rows.back().title == "Back" &&
simulation.state().navigation.focus_key == "import-program-0",
"T17 the program list puts the game first and labels helpers");
simulation.action("cross");