Skip to content

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

C++

Download games in the language you choose

ozchoafd53b42c37c
diff --git a/cmake/HomebrewPS5.cmake b/cmake/HomebrewPS5.cmake
index ffb465e..cba09c0 100644
--- a/cmake/HomebrewPS5.cmake
+++ b/cmake/HomebrewPS5.cmake
@@ -158,6 +158,7 @@ function(playden_add_homebrew_ps5_title)
--start-group "${gl_sdk}/lib/libPS5OpenGL.a" "${sdk}/target/lib/libunwind.a"
"${sdk}/target/lib/libc++abi.a" "${sdk}/target/lib/libc++.a"
"${sdk_deps}/compiler-rt/libclang_rt.builtins-x86_64.a" $<TARGET_FILE:playden_hui> $<TARGET_FILE:playden_homebrew_ui> $<TARGET_FILE:playden_homebrew_model>
+ $<TARGET_FILE:playden_steam_content_language>
$<TARGET_FILE:playden_homebrew_qr> $<TARGET_FILE:playden_homebrew_controller>
$<TARGET_FILE:playden_homebrew_artwork_cache> $<TARGET_FILE:playden_homebrew_artwork> $<TARGET_FILE:playden_persistence_controller> $<TARGET_FILE:playden_persistence_service> $<TARGET_FILE:playden_preferences> $<TARGET_FILE:playden_library_controller> $<TARGET_FILE:playden_library_service> $<TARGET_FILE:playden_steam_library> $<TARGET_FILE:playden_steam_cm> $<TARGET_FILE:playden_steam_cm_codec> $<TARGET_FILE:playden_depot_codec>
$<TARGET_FILE:playden_local_session_repository> $<TARGET_FILE:playden_auth_diagnostics> $<TARGET_FILE:playden_local_store> $<TARGET_FILE:playden_local_copy>
@@ -169,6 +170,7 @@ function(playden_add_homebrew_ps5_title)
--end-group --as-needed ${link_stubs}
WORKING_DIRECTORY "${out}/link"
DEPENDS "${common_dialog_stub}" playden_ps5_runtime playden_ps5_shims playden_ps5_app playden_hui playden_homebrew_ui playden_homebrew_model ${title_database_targets}
+ playden_steam_content_language
playden_homebrew_qr playden_homebrew_controller playden_local_session_repository playden_auth_diagnostics playden_local_store playden_local_copy
playden_homebrew_artwork_cache playden_homebrew_artwork playden_persistence_controller playden_persistence_service playden_preferences playden_library_controller playden_library_service playden_steam_library playden_steam_cm playden_steam_cm_codec playden_depot_codec
playden_library playden_self_update playden_miniz playden_steam_auth playden_steam_http playden_steam_protocol playden_steam_core playden_web playden_web_logs playden_web_http playden_diagnostic_log playden_storage playden_native_access playden_managed_directory playden_runtime_steamworks playden_runtime_artifact_hash playden_runtime_settings_storage playden_runtime_private_directories playden_runtime_session_reconciler playden_runtime_launch_service playden_runtime_install_service playden_runtime_installs playden_runtime_layout_migration playden_game_paths
@@ -178,6 +180,7 @@ function(playden_add_homebrew_ps5_title)
$<TARGET_FILE:playden_steam_auth>
$<TARGET_FILE:playden_steam_core> $<TARGET_FILE:playden_diagnostic_log> $<TARGET_FILE:playden_storage>
$<TARGET_FILE:playden_library> $<TARGET_FILE:playden_native_access> $<TARGET_FILE:playden_managed_directory> $<TARGET_FILE:playden_runtime_steamworks> $<TARGET_FILE:playden_runtime_artifact_hash> $<TARGET_FILE:playden_runtime_settings_storage> $<TARGET_FILE:playden_runtime_private_directories> $<TARGET_FILE:playden_runtime_session_reconciler> $<TARGET_FILE:playden_runtime_launch_service> $<TARGET_FILE:playden_runtime_install_service> $<TARGET_FILE:playden_runtime_installs> $<TARGET_FILE:playden_runtime_layout_migration> $<TARGET_FILE:playden_game_paths>
+ $<TARGET_FILE:playden_steam_content_language>
$<TARGET_FILE:playden_homebrew_qr> $<TARGET_FILE:playden_homebrew_controller>
$<TARGET_FILE:playden_homebrew_artwork_cache> $<TARGET_FILE:playden_homebrew_artwork> $<TARGET_FILE:playden_persistence_controller> $<TARGET_FILE:playden_persistence_service> $<TARGET_FILE:playden_preferences> $<TARGET_FILE:playden_library_controller> $<TARGET_FILE:playden_library_service> $<TARGET_FILE:playden_steam_library> $<TARGET_FILE:playden_steam_cm> $<TARGET_FILE:playden_steam_cm_codec> $<TARGET_FILE:playden_depot_codec>
$<TARGET_FILE:playden_local_session_repository> $<TARGET_FILE:playden_auth_diagnostics> $<TARGET_FILE:playden_local_store> $<TARGET_FILE:playden_local_copy>
diff --git a/cmake/HomebrewUI.cmake b/cmake/HomebrewUI.cmake
index 1afe97a..959e5a9 100644
--- a/cmake/HomebrewUI.cmake
+++ b/cmake/HomebrewUI.cmake
@@ -77,7 +77,7 @@ target_include_directories(playden_steam_cm_codec PUBLIC "${CMAKE_SOURCE_DIR}/sr
target_include_directories(playden_steam_cm_codec PRIVATE "${PLAYDEN_STB_IMAGE_INCLUDE_DIR}")
target_compile_features(playden_steam_cm_codec PUBLIC cxx_std_17)
target_link_libraries(playden_steam_cm_codec PUBLIC playden_game_paths playden_steam_protocol playden_managed_directory
- playden_runtime_steamworks playden_runtime_artifact_hash playden_miniz playden_library)
+ playden_runtime_steamworks playden_runtime_artifact_hash playden_miniz playden_library playden_steam_content_language)
if(PLAYDEN_PLATFORM_PS5)
target_compile_options(playden_steam_cm_codec PRIVATE -fno-exceptions -fno-rtti)
endif()
diff --git a/cmake/PlaydenCore.cmake b/cmake/PlaydenCore.cmake
index 723ad8c..8d40cec 100644
--- a/cmake/PlaydenCore.cmake
+++ b/cmake/PlaydenCore.cmake
@@ -60,10 +60,16 @@ add_library(playden_diagnostic_log STATIC "${CMAKE_SOURCE_DIR}/src/app/diagnosti
target_include_directories(playden_diagnostic_log PUBLIC "${CMAKE_SOURCE_DIR}/src")
target_compile_features(playden_diagnostic_log PUBLIC cxx_std_17)
+# The languages Steam ships game content in. The depot selection, the preferences and the
+# Steamworks emulator all name them, and none of those may depend on the others.
+add_library(playden_steam_content_language STATIC
+ "${CMAKE_SOURCE_DIR}/src/steam/backend/content_language.cpp")
+target_include_directories(playden_steam_content_language PUBLIC "${CMAKE_SOURCE_DIR}/src")
+target_compile_features(playden_steam_content_language PUBLIC cxx_std_17)
add_library(playden_preferences STATIC "${CMAKE_SOURCE_DIR}/src/app/preferences.cpp")
target_include_directories(playden_preferences PUBLIC "${CMAKE_SOURCE_DIR}/src")
target_compile_features(playden_preferences PUBLIC cxx_std_17)
-target_link_libraries(playden_preferences PUBLIC playden_storage)
+target_link_libraries(playden_preferences PUBLIC playden_storage playden_steam_content_language)
add_library(playden_persistence_service STATIC "${CMAKE_SOURCE_DIR}/src/app/persistence_service.cpp")
target_include_directories(playden_persistence_service PUBLIC "${CMAKE_SOURCE_DIR}/src")
diff --git a/cmake/ProsperoRuntime.cmake b/cmake/ProsperoRuntime.cmake
index ce60d5a..e189a9a 100644
--- a/cmake/ProsperoRuntime.cmake
+++ b/cmake/ProsperoRuntime.cmake
@@ -146,7 +146,7 @@ add_library(playden_runtime_steamworks STATIC "${CMAKE_SOURCE_DIR}/src/runtime/s
"${CMAKE_SOURCE_DIR}/src/runtime/dotnet_heap.cpp" "${CMAKE_SOURCE_DIR}/src/runtime/steam_stub.cpp")
target_compile_features(playden_runtime_steamworks PUBLIC cxx_std_17)
target_include_directories(playden_runtime_steamworks PUBLIC "${CMAKE_SOURCE_DIR}/src")
-target_link_libraries(playden_runtime_steamworks PUBLIC playden_runtime_artifact_hash)
+target_link_libraries(playden_runtime_steamworks PUBLIC playden_runtime_artifact_hash playden_steam_content_language)
target_link_libraries(playden_runtime_steamworks PRIVATE playden_curl_8_22)
add_library(playden_runtime_kit_admission STATIC
"${CMAKE_SOURCE_DIR}/src/runtime/kit_admission.cpp")
diff --git a/src/app/preferences.cpp b/src/app/preferences.cpp
index 15f98dd..861cc89 100644
--- a/src/app/preferences.cpp
+++ b/src/app/preferences.cpp
@@ -1,5 +1,7 @@
#include "app/preferences.h"
+#include "steam/backend/content_language.h"
+
#include <algorithm>
#include <iterator>
#include <string>
@@ -15,11 +17,12 @@ std::string ToString(const Bytes& bytes) {
return std::string(bytes.begin(), bytes.end());
}
-// Versions 8 and 9: one "key=value" line per field, in this order, each ending in a newline. Version 9 adds
-// web_access (on in older files).
-constexpr const char* kVersionNineKeys[] = {"reduce_motion", "title_store_suffix", "cloud_saves_auto",
- "steam_sign_in_password", "downloads_slow_network", "steam_stay_signed_in",
- "beta_updates", "download_server", "web_access"};
+// Versions 8 to 10: one "key=value" line per field, in this order, each ending in a newline. Version 9 adds
+// web_access (on in older files), version 10 content_language (English in older files, which is what they
+// downloaded).
+constexpr const char* kVersionTenKeys[] = {"reduce_motion", "title_store_suffix", "cloud_saves_auto",
+ "steam_sign_in_password", "downloads_slow_network", "steam_stay_signed_in",
+ "beta_updates", "download_server", "web_access", "content_language"};
bool ParseFlag(const std::string& value, bool* flag) {
if (value != "0" && value != "1") return false;
@@ -39,9 +42,9 @@ bool ParseKeyed(const std::string& serialized, int version, Preferences* prefere
if (serialized.compare(0, header.size(), header) != 0 || serialized.back() != '\n') return false;
std::vector<std::string> values;
std::size_t start = header.size();
- const std::size_t count = version == 9 ? std::size(kVersionNineKeys) : std::size(kVersionNineKeys) - 1;
+ const std::size_t count = std::size(kVersionTenKeys) - static_cast<std::size_t>(10 - version);
for (std::size_t field = 0; field < count; ++field) {
- const char* key = kVersionNineKeys[field];
+ const char* key = kVersionTenKeys[field];
const std::string prefix = std::string(key) + "=";
const auto end = serialized.find('\n', start);
if (end == std::string::npos || serialized.compare(start, prefix.size(), prefix) != 0) return false;
@@ -53,8 +56,13 @@ bool ParseKeyed(const std::string& serialized, int version, Preferences* prefere
if (!ParseFlag(values[0], &parsed.reduce_motion) || !ParseFlag(values[1], &parsed.title_store_suffix) ||
!ParseFlag(values[2], &parsed.cloud_saves_auto) || !ParseFlag(values[3], &parsed.steam_sign_in_password) ||
!ParseFlag(values[4], &parsed.downloads_slow_network) || !ParseFlag(values[5], &parsed.steam_stay_signed_in) ||
- !ParseFlag(values[6], &parsed.beta_updates) || (version == 9 && !ParseFlag(values[8], &parsed.web_access)))
+ !ParseFlag(values[6], &parsed.beta_updates) || (version >= 9 && !ParseFlag(values[8], &parsed.web_access)))
return false;
+ // Only a language Steam names: anything else would pick depots that do not exist.
+ if (version >= 10) {
+ if (!steam::IsContentLanguage(values[9])) return false;
+ parsed.content_language = values[9];
+ }
// A host the current rule refuses is dropped without resetting unrelated preferences.
if (ValidDownloadServer(values[7])) parsed.download_server = values[7];
*preferences = std::move(parsed);
@@ -82,7 +90,7 @@ PreferencesLoadResult PreferencesStore::Load() const {
std::string serialized = ToString(read.value());
Preferences keyed;
- if (ParseKeyed(serialized, 9, &keyed) || ParseKeyed(serialized, 8, &keyed))
+ if (ParseKeyed(serialized, 10, &keyed) || ParseKeyed(serialized, 9, &keyed) || ParseKeyed(serialized, 8, &keyed))
return PreferencesLoadResult{std::move(keyed), PreferencesLoadStatus::kLoaded, std::string()};
bool beta_updates = false;
if (serialized.rfind("version=7\n", 0) == 0) {
@@ -97,7 +105,8 @@ PreferencesLoadResult PreferencesStore::Load() const {
// Version 1 holds only reduce_motion; version 2 adds title_store_suffix; version 3 cloud_saves_auto;
// version 4 steam_sign_in_password; version 5 downloads_slow_network; version 6 steam_stay_signed_in
// (on in files older than that). Version 7 appends beta_updates (off in older files); version 8 (above)
- // adds the download server (Automatic in older files), version 9 web access (on in older files).
+ // adds the download server (Automatic in older files), version 9 web access (on in older files), version 10
+ // the content language (English in older files).
for (const int motion : {0, 1}) {
if (serialized == std::string("version=1\nreduce_motion=") + char('0' + motion) + "\n") {
Preferences preferences;
@@ -182,7 +191,7 @@ Result<void> PreferencesStore::Save(const Preferences& preferences) const {
if(!ready.ok()) return ready;
// Never write a host that cannot be read back, including embedded newlines.
const std::string server = ValidDownloadServer(preferences.download_server) ? preferences.download_server : std::string();
- const std::string text = std::string("version=9\nreduce_motion=") + (preferences.reduce_motion ? "1" : "0") +
+ const std::string text = std::string("version=10\nreduce_motion=") + (preferences.reduce_motion ? "1" : "0") +
"\ntitle_store_suffix=" + (preferences.title_store_suffix ? "1" : "0") +
"\ncloud_saves_auto=" + (preferences.cloud_saves_auto ? "1" : "0") +
"\nsteam_sign_in_password=" + (preferences.steam_sign_in_password ? "1" : "0") +
@@ -190,7 +199,11 @@ Result<void> PreferencesStore::Save(const Preferences& preferences) const {
"\nsteam_stay_signed_in=" + (preferences.steam_stay_signed_in ? "1" : "0") +
"\nbeta_updates=" + (preferences.beta_updates ? "1" : "0") +
"\ndownload_server=" + server +
- "\nweb_access=" + (preferences.web_access ? "1" : "0") + "\n";
+ "\nweb_access=" + (preferences.web_access ? "1" : "0") + "\ncontent_language=" +
+ (steam::IsContentLanguage(preferences.content_language)
+ ? preferences.content_language
+ : std::string(steam::kDefaultContentLanguage)) +
+ "\n";
return storage_.WriteAtomic(kPreferencesPath, Bytes(text.begin(), text.end()));
}
diff --git a/src/app/preferences.h b/src/app/preferences.h
index 39b0de5..8eead9d 100644
--- a/src/app/preferences.h
+++ b/src/app/preferences.h
@@ -28,6 +28,10 @@ struct Preferences {
// Web access: Playden's logs, redacted, on the local network at port 7031 while Playden is open. On by default,
// so a tester can send logs without first finding a switch; version 1 only reads.
bool web_access = true;
+ // The language game content is downloaded in, as Steam names its depot languages
+ // ("german", "koreana"). Steam ships localisations as separate depots; a game that has none
+ // in this language is installed in English, as every game was before this could be chosen.
+ std::string content_language = "english";
};
enum class PreferencesLoadStatus {
diff --git a/src/homebrew/host.cpp b/src/homebrew/host.cpp
index 2dc762e..8620bb2 100644
--- a/src/homebrew/host.cpp
+++ b/src/homebrew/host.cpp
@@ -47,6 +47,14 @@
namespace {
+// Settings › Game language, read by the install and details workers when they start a job.
+std::mutex content_language_lock;
+std::string content_language{playden::steam::kDefaultContentLanguage};
+std::string selected_content_language() {
+ const std::lock_guard<std::mutex> guard(content_language_lock);
+ return content_language;
+}
+
struct Options {
std::string scenario;
std::filesystem::path profile = PLAYDEN_HOMEBREW_DEFAULT_PROFILE;
@@ -552,6 +560,7 @@ int main(int argc, char** argv) {
details_cm->SetSharedSession(steam_cm);
details_source = std::make_unique<playden::steam::CmAppDetailsSource>(*details_cm);
details_source->SetLicensedDepots(&licensed_depots);
+ details_source->SetContentLanguage([] { return selected_content_language(); });
details_sessions = std::make_unique<playden::LocalSessionRepository>(options->data_directory.string(), playden::LocalSessionRepository::DiagnosticReport{}, session_vault.get());
app_details = std::make_unique<playden::steam::AppDetailsService>(*details_source, *details_sessions);
install_cm = std::make_unique<playden::steam::CmClient>(PLAYDEN_HOMEBREW_CA_BUNDLE, *library_storage);
@@ -574,6 +583,7 @@ int main(int argc, char** argv) {
}
return tuning;
});
+ install_runner->SetContentLanguage([] { return selected_content_language(); });
install_runner->SetLog([log_directory](std::uint32_t app, const char* step, const char* category, const char* detail) {
char line[640];
if (std::string(step) == "install-removal")
@@ -804,6 +814,10 @@ int main(int argc, char** argv) {
std::lock_guard lock(download_tuning_state.mutex);
download_tuning_state.download_server = simulation.state().download_server;
}
+ {
+ const std::lock_guard<std::mutex> guard(content_language_lock);
+ content_language = simulation.state().content_language;
+ }
render->draw(simulation, width, height, options->headless ? 1.0F / 60.0F : frame_dt);
rendered_once = true;
if (simulation.state().quit_requested) running = false;
diff --git a/src/homebrew/ps5.cpp b/src/homebrew/ps5.cpp
index 1c35392..b0df7bf 100644
--- a/src/homebrew/ps5.cpp
+++ b/src/homebrew/ps5.cpp
@@ -47,6 +47,7 @@
#include <array>
#include <atomic>
+#include <mutex>
#include <cstdio>
#include <cstdlib>
#include <vector>
@@ -160,6 +161,14 @@ std::atomic<bool> downloads_slow_network{false};
// The main loop updates this selection; the install worker copies it at download start.
std::mutex download_server_mutex;
std::string download_server;
+// Settings › Game language, read by the install worker when a download starts and by the
+// details worker when it estimates sizes. A string needs a lock; the UI writes it once a frame.
+std::mutex content_language_lock;
+std::string content_language{playden::steam::kDefaultContentLanguage};
+std::string selected_content_language() {
+ const std::lock_guard<std::mutex> guard(content_language_lock);
+ return content_language;
+}
// Development requests are processed in file order on the first frame.
std::vector<playden::steam::InstallRequest> take_install_requests(bool runtime_ready) {
const std::string request_path = title_root + "/dev/install-request.txt";
@@ -358,6 +367,7 @@ int main() {
details_cm.SetSharedSession(steam_cm);
playden::steam::CmAppDetailsSource details_source(details_cm);
details_source.SetLicensedDepots(&licensed_depots);
+ details_source.SetContentLanguage([] { return selected_content_language(); });
playden::LocalSessionRepository details_sessions(user_root, {}, &session_vault);
playden::steam::AppDetailsService app_details(details_source, details_sessions);
playden::steam::CmClient install_cm(paths.trust_store, library_storage);
@@ -379,6 +389,7 @@ int main() {
}
return tuning;
});
+ install_runner.SetContentLanguage([] { return selected_content_language(); });
install_runner.SetLog([](std::uint32_t app, const char* step, const char* category, const char* detail) {
char line[640];
if (std::string(step) == "install-removal")
@@ -902,6 +913,10 @@ int main() {
std::lock_guard lock(download_server_mutex);
download_server = simulation.state().download_server;
}
+ {
+ const std::lock_guard<std::mutex> guard(content_language_lock);
+ content_language = simulation.state().content_language;
+ }
#endif
const auto ticked = hui::sys::monotonic_us();
if (simulation.state().quit_requested) break;
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index 1b8b7bb..c767bd4 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -2809,7 +2809,7 @@ void Simulation::ApplyLiveDownloadServers(const LiveDownloadServers& snapshot) {
playden::Preferences Simulation::ExportPreferences() const {
return {state_.reduced_motion, state_.title_store_suffix, state_.cloud_saves_auto, state_.sign_in_password,
state_.downloads_slow_network, state_.stay_signed_in, state_.beta_updates, state_.download_server,
- state_.web_access};
+ state_.web_access, state_.content_language};
}
void Simulation::apply_organization_snapshot(const playden::OrganizationSnapshot& snapshot) {
@@ -3040,6 +3040,7 @@ bool Simulation::ApplyPreferences(PersistenceLoadToken token,
state_.download_server = loaded.preferences.download_server;
state_.web_access = loaded.preferences.web_access;
state_.stay_signed_in = loaded.preferences.steam_stay_signed_in;
+ state_.content_language = loaded.preferences.content_language;
captured_preferences_ = loaded.preferences;
preferences_saved_revision_ = preferences_revision_;
}
@@ -3121,6 +3122,7 @@ bool Simulation::record_live_persistence() {
after_preferences.download_server != captured_preferences_.download_server ||
after_preferences.web_access != captured_preferences_.web_access ||
after_preferences.beta_updates != captured_preferences_.beta_updates ||
+ after_preferences.content_language != captured_preferences_.content_language ||
after_preferences.steam_stay_signed_in != captured_preferences_.steam_stay_signed_in);
if (organization_changed && !snapshot_within_model_bounds(after_organization)) {
@@ -3148,6 +3150,7 @@ bool Simulation::record_live_persistence() {
state_.download_server = captured_preferences_.download_server;
state_.web_access = captured_preferences_.web_access;
state_.stay_signed_in = captured_preferences_.steam_stay_signed_in;
+ state_.content_language = captured_preferences_.content_language;
organization_journal_full_ = true;
force_organization_reset_ = false;
force_organization_selection_ = false;
@@ -3321,6 +3324,8 @@ void Simulation::load_profile() {
state_.account().display_name = saved_account.empty() ? std::string{} : string_value(root->get("account_display_name"), "Connected fixture account");
state_.reduced_motion = bool_value(root->get("reduced_motion"));
state_.download_server = string_value(root->get("download_server"));
+ if (const auto saved = string_value(root->get("content_language")); playden::steam::IsContentLanguage(saved))
+ state_.content_language = saved;
if (saved_auth == "signed-out" || saved_auth == "cancelled" || (saved_auth == "waiting" && saved_account.empty())) {
state_.account().authentication = AuthState::SignedOut; state_.account().id.clear(); state_.account().display_name.clear();
state_.account().cache_available = false; state_.account().challenge_expiry = 0; state_.navigation.route = Route::Startup; state_.navigation.focus_key = "startup-connect";
@@ -3460,6 +3465,7 @@ bool Simulation::save_profile() {
+ "\",\"authentication\":\"" + auth_name(state_.account().authentication) + "\",\"account_last_sync\":" + std::to_string(state_.account().last_sync)
+ ",\"next_job_serial\":" + std::to_string(next_job_serial_) + ",\"reduced_motion\":"
+ (state_.reduced_motion ? "true" : "false") + ",\"download_server\":\"" + json::escape(state_.download_server)
+ + "\",\"content_language\":\"" + json::escape(state_.content_language)
+ "\",\"query\":\"" + json::escape(state_.library.query)
+ "\",\"scope\":\"" + json::escape(state_.library.scope) + "\",\"favorites\":[";
bool first = true;
@@ -4167,6 +4173,9 @@ void Simulation::rebuild_view() {
"tile; its saves and settings move to Kept game data, and its game files stay in the Library.";
if (modal.id == "download-server")
view_.subtitle = "Applies to downloads that start or resume from now.";
+ if (modal.id == "content-language")
+ view_.subtitle = "New downloads are in this language when the game has it, and in English when it does not. "
+ "Games already installed keep the language they were downloaded in.";
for (const auto& action_key : modal.action_keys) {
auto& item = row(action_key, RowKind::Action, action_label(action_key), action_key);
item.dangerous = modal.destructive && action_key != "cancel";
@@ -4226,6 +4235,14 @@ void Simulation::rebuild_view() {
}
continue;
}
+ // The game-language picker: every language Steam has, with the one in use ticked.
+ if (modal.id == "content-language" && action_key.rfind("content-language-", 0) == 0) {
+ const auto code = action_key.substr(17);
+ item.kind = RowKind::Choice;
+ item.title = playden::steam::LanguageName(code);
+ item.selected = code == state_.content_language;
+ if (item.selected) item.value = "In use";
+ }
// Demos and Family sharing are on unless the player hid them.
if (action_key == "filter-hide-demos" || action_key == "filter-hide-family") {
item.kind = RowKind::Toggle;
@@ -4846,6 +4863,7 @@ void Simulation::rebuild_view() {
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 Choose", "Circle Cancel"};
+ else if (modal.id == "content-language") view_.legends = {"Cross Use this language", "L1/R1 Jump", "Circle Back"};
else if (modal.id == "import-storage") view_.legends = {"Cross Import here", "Circle Back"};
else if (modal.id == "installed-games") view_.legends = {"Cross Select", "Triangle Uninstall", "Circle Close"};
else if (!modal.setting_id.empty()) view_.legends = {"Cross Select", "Triangle Reset", "L1/R1 Jump", "Circle Back"};
@@ -5498,6 +5516,11 @@ void Simulation::rebuild_view() {
auto& suffix = add("settings-title-store", RowKind::Toggle, "Store name in PS5 titles", "toggle-title-store");
suffix.selected = state_.title_store_suffix;
suffix.subtitle = "Name game titles like \"Half-Life 2 (Steam)\". Prepared games change with their next Update.";
+ // Steam ships localisations as separate depots, so the language has to be chosen
+ // before a game is downloaded.
+ auto& content = add("settings-content-language", RowKind::Action, "Game language", "content-language-picker");
+ content.value = playden::steam::LanguageName(state_.content_language);
+ content.subtitle = "Which language new downloads are in, when the game has it. Games already installed keep theirs.";
auto& cloud = add("settings-cloud-saves", RowKind::Toggle, "Sync Cloud saves automatically", "toggle-cloud-saves");
cloud.selected = state_.cloud_saves_auto;
cloud.subtitle = state_.cloud_saves_auto ? "Before Play, after each game and when Playden starts."
@@ -6832,6 +6855,25 @@ void Simulation::activate() {
}
save_profile();
close_modal();
+ } else if (action_name == "content-language-picker") {
+ std::vector<std::string> actions;
+ actions.reserve(playden::steam::ContentLanguages().size() + 1);
+ for (const auto& language : playden::steam::ContentLanguages())
+ actions.push_back("content-language-" + std::string(language.code));
+ actions.push_back("cancel");
+ // Opens on the language in use, so a list this long does not start at the top every time.
+ int focus = 0;
+ for (std::size_t index = 0; index < actions.size(); ++index)
+ if (actions[index] == "content-language-" + state_.content_language) focus = static_cast<int>(index);
+ open_modal({"content-language", "Game language", state_.navigation.focus_key, std::move(actions), focus, false});
+ } else if (action_name.rfind("content-language-", 0) == 0) {
+ const auto code = action_name.substr(17);
+ if (playden::steam::IsContentLanguage(code)) {
+ state_.content_language = code;
+ save_profile();
+ }
+ close_modal();
+ return;
} else if (action_name == "storage-picker") {
// From the install sheet the choice is for that install only; Settings changes the default.
picking_install_volume_ = live() && !state_.navigation.modals.empty() && state_.navigation.modals.back().id == "install";
@@ -8387,6 +8429,7 @@ bool Simulation::action(const std::string& logical_action) {
else if ((logical_action == "l1" || logical_action == "r1") && !state_.navigation.modals.empty() &&
(state_.navigation.modals.back().id == "game-settings" || state_.navigation.modals.back().id == "preset-picker" ||
state_.navigation.modals.back().id == "game-maintenance" ||
+ state_.navigation.modals.back().id == "content-language" ||
state_.navigation.modals.back().id == "button-mapping" || state_.navigation.modals.back().id == "controller-tuning" ||
!state_.navigation.modals.back().setting_id.empty()))
move(0, logical_action == "l1" ? -5 : 5); // L1/R1 jump five rows, as on macOS
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 577b6b8..3b974df 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -7,6 +7,7 @@
#include "library/organization.h"
#include "library/model.h"
#include "runtime/game_settings.h"
+#include "steam/backend/content_language.h"
#include <array>
#include <cstdint>
@@ -682,6 +683,8 @@ struct State {
bool title_store_suffix = false; // PS5 titles named "<game> (Steam)"
bool cloud_saves_auto = false; // Cloud saves move before Play, after sessions and at startup (opt-in)
bool beta_updates = false;
+ // The language games are downloaded in, as Steam names its depot languages ("german").
+ std::string content_language{playden::steam::kDefaultContentLanguage};
bool downloads_slow_network = false; // 8 download pieces at a time instead of 4 (Settings › Storage)
// Empty: Steam default (Steam's order); kFastestDownloadServer: Fastest (raced at each download); otherwise
// the chosen provider's stable identifier.
diff --git a/src/runtime/steamworks.cpp b/src/runtime/steamworks.cpp
index 3ce2c4b..ec727af 100644
--- a/src/runtime/steamworks.cpp
+++ b/src/runtime/steamworks.cpp
@@ -1,6 +1,7 @@
#include "runtime/steamworks.h"
#include "runtime/artifact_hash.h"
+#include "steam/backend/content_language.h"
#include <algorithm>
#include <cerrno>
@@ -400,19 +401,27 @@ SteamworksResult RestoreSteamworks(const std::string& install_root, const std::v
return result;
}
-std::string SerializeSteamworksFacts(const std::vector<std::uint32_t>& depots, const std::vector<std::uint32_t>& owned_dlc) {
- return "depots=" + Join(Sorted(depots), ",") + "\ndlc=" + Join(Sorted(owned_dlc), ",") + "\n";
+std::string SerializeSteamworksFacts(const std::vector<std::uint32_t>& depots, const std::vector<std::uint32_t>& owned_dlc,
+ const std::string& language) {
+ std::string text = "depots=" + Join(Sorted(depots), ",") + "\ndlc=" + Join(Sorted(owned_dlc), ",") + "\n";
+ // The language the depots were installed for. Older files have no line and read as English,
+ // which is what they were installed in.
+ if (!language.empty() && language != std::string(steam::kDefaultContentLanguage))
+ text += "language=" + language + "\n";
+ return text;
}
bool WriteSteamworksFacts(const std::string& install_root, const std::vector<std::uint32_t>& depots,
- const std::vector<std::uint32_t>& owned_dlc) {
- return WriteAtomic(fs::path(install_root) / kSteamworksFactsFile, SerializeSteamworksFacts(depots, owned_dlc));
+ const std::vector<std::uint32_t>& owned_dlc, const std::string& language) {
+ return WriteAtomic(fs::path(install_root) / kSteamworksFactsFile,
+ SerializeSteamworksFacts(depots, owned_dlc, language));
}
bool ReadSteamworksFacts(const std::string& install_root, SteamworksIdentity* identity) {
const auto text = ReadFile(fs::path(install_root) / kSteamworksFactsFile, 64 * 1024);
if (!text) return false;
std::vector<std::uint32_t> depots, dlc;
+ std::string language;
std::size_t start = 0;
while (start < text->size()) {
auto end = text->find('\n', start);
@@ -421,6 +430,13 @@ bool ReadSteamworksFacts(const std::string& install_root, SteamworksIdentity* id
start = end + 1;
const auto equals = line.find('=');
if (equals == std::string::npos) continue;
+ if (line.compare(0, equals, "language") == 0) {
+ const auto value = line.substr(equals + 1);
+ // Only a language Steam names; anything else leaves the game on English rather than
+ // handing the emulator a value it cannot use.
+ if (steam::IsContentLanguage(value)) language = value;
+ continue;
+ }
auto* target = line.compare(0, equals, "depots") == 0 ? &depots : line.compare(0, equals, "dlc") == 0 ? &dlc : nullptr;
if (!target) continue;
std::size_t at = equals + 1;
@@ -439,6 +455,7 @@ bool ReadSteamworksFacts(const std::string& install_root, SteamworksIdentity* id
}
identity->depots = std::move(depots);
identity->owned_dlc = std::move(dlc);
+ if (!language.empty()) identity->language = language;
return true;
}
diff --git a/src/runtime/steamworks.h b/src/runtime/steamworks.h
index 42dc67c..b83a371 100644
--- a/src/runtime/steamworks.h
+++ b/src/runtime/steamworks.h
@@ -82,10 +82,13 @@ SteamworksResult RemoveLegacySteam(const std::string& install_root, const std::v
// Interface versions a steam_api DLL asks for, as gbe_fork's generate_interfaces finds them.
std::vector<std::string> SteamInterfaces(std::string_view dll_bytes);
-// The facts file the download writes, and its reader (missing or unreadable: false).
-std::string SerializeSteamworksFacts(const std::vector<std::uint32_t>& depots, const std::vector<std::uint32_t>& owned_dlc);
+// The facts file the download writes, and its reader (missing or unreadable: false). `language`
+// is the content language the depots were installed for; English, and files written before
+// Playden could choose one, leave the line out.
+std::string SerializeSteamworksFacts(const std::vector<std::uint32_t>& depots, const std::vector<std::uint32_t>& owned_dlc,
+ const std::string& language = {});
bool WriteSteamworksFacts(const std::string& install_root, const std::vector<std::uint32_t>& depots,
- const std::vector<std::uint32_t>& owned_dlc);
+ const std::vector<std::uint32_t>& owned_dlc, const std::string& language = {});
bool ReadSteamworksFacts(const std::string& install_root, SteamworksIdentity* identity);
} // namespace playden::runtime
diff --git a/src/steam/backend/app_info.cpp b/src/steam/backend/app_info.cpp
index 1b0988c..2ccf467 100644
--- a/src/steam/backend/app_info.cpp
+++ b/src/steam/backend/app_info.cpp
@@ -3,6 +3,7 @@
#include <algorithm>
#include <charconv>
+#include "steam/backend/content_language.h"
#include "steam/backend/vdf.h"
namespace playden::steam {
@@ -95,7 +96,7 @@ int NaturalCompare(std::string_view a, std::string_view b) {
return 0;
}
-bool Fail(std::string* reason, const char* text) {
+bool Fail(std::string* reason, std::string_view text) {
if (reason != nullptr) *reason = text;
return false;
}
@@ -386,7 +387,7 @@ bool OsListMatchesWindows(std::string_view os_list) {
}
bool SelectDepots(const AppInfo& app, const std::set<std::uint32_t>& owned_apps,
- const std::optional<std::set<std::uint32_t>>& owned_depots,
+ const std::optional<std::set<std::uint32_t>>& owned_depots, std::string_view language,
std::vector<DepotInfo>* selected, std::string* reason) {
if (owned_apps.count(app.app_id) == 0) {
return Fail(reason, "This account does not own the selected game.");
@@ -401,9 +402,18 @@ bool SelectDepots(const AppInfo& app, const std::set<std::uint32_t>& owned_apps,
if (depot.depot_from_app) accessible.insert(depot.id);
}
+ const std::string wanted = language.empty() ? std::string(kDefaultContentLanguage) : LowerString(language);
+ // A game that has no depot in the wanted language gets English, which is what Playden has
+ // always installed: asking for a language the game does not carry must not take content away.
+ const bool carries_wanted = std::any_of(app.depots.begin(), app.depots.end(), [&](const DepotInfo& depot) {
+ return !depot.language.empty() && LowerString(depot.language) == wanted;
+ });
+ const std::string chosen = carries_wanted ? wanted : std::string(kDefaultContentLanguage);
+
std::vector<DepotInfo> eligible;
for (const DepotInfo& depot : app.depots) {
- const bool language_ok = depot.language.empty() || LowerString(depot.language) == "english";
+ // A depot with no language belongs to every language; the rest only to their own.
+ const bool language_ok = depot.language.empty() || LowerString(depot.language) == chosen;
const bool dlc_ok = (!depot.is_dlc && !depot.dlc_app_id) ||
(depot.dlc_app_id && owned_apps.count(*depot.dlc_app_id) != 0);
if (OsListMatchesWindows(depot.os_list) && language_ok && !depot.shared_install &&
@@ -412,7 +422,7 @@ bool SelectDepots(const AppInfo& app, const std::set<std::uint32_t>& owned_apps,
}
}
if (eligible.empty()) {
- return Fail(reason, "This game has no downloadable Windows content for English.");
+ return Fail(reason, "This game has no downloadable Windows content for " + LanguageName(chosen) + ".");
}
bool has_win64 = false;
for (const DepotInfo& depot : eligible) {
diff --git a/src/steam/backend/app_info.h b/src/steam/backend/app_info.h
index bacf311..d90e362 100644
--- a/src/steam/backend/app_info.h
+++ b/src/steam/backend/app_info.h
@@ -88,12 +88,15 @@ std::optional<AppInfo> ParseAppInfo(std::uint32_t app_id, std::string_view buffe
// Steam `oslist`: empty means every platform; otherwise a comma list that must name windows.
bool OsListMatchesWindows(std::string_view os_list);
-// Windows/English depot selection: eligible by OS, language, shared install, access and DLC
-// ownership, then only those with a public manifest. A usable 64-bit Windows depot excludes
-// 32-bit alternates but not architecture-neutral content. Results are sorted by id. Returns
-// false with a short reason when nothing is eligible or available.
+// Windows depot selection: eligible by OS, language, shared install, access and DLC ownership,
+// then only those with a public manifest. A usable 64-bit Windows depot excludes 32-bit
+// alternates but not architecture-neutral content. Results are sorted by id. `language` is the
+// content language the player chose, as Steam names it ("german"); a depot with no language
+// belongs to every language. A game that carries no depot in that language is selected for
+// English instead, so asking for a language the game does not have never installs less than
+// before. Returns false with a short reason when nothing is eligible or available.
bool SelectDepots(const AppInfo& app, const std::set<std::uint32_t>& owned_apps,
- const std::optional<std::set<std::uint32_t>>& owned_depots,
+ const std::optional<std::set<std::uint32_t>>& owned_depots, std::string_view language,
std::vector<DepotInfo>* selected, std::string* reason);
// Depots that look like the game itself but the account's licenses do not grant: no oslist, no
diff --git a/src/steam/backend/cm_app_details.cpp b/src/steam/backend/cm_app_details.cpp
index 0b2c155..0b360fb 100644
--- a/src/steam/backend/cm_app_details.cpp
+++ b/src/steam/backend/cm_app_details.cpp
@@ -5,7 +5,8 @@
namespace playden::steam {
AppDetails DetailsFromAppInfo(std::uint32_t id, const std::string& buffer,
- const std::optional<LicensedDepots::Grant>& licensed) {
+ const std::optional<LicensedDepots::Grant>& licensed,
+ std::string_view language) {
AppDetails details;
details.id = GameId::Steam(id);
const auto app = ParseAppInfo(id, buffer);
@@ -22,9 +23,9 @@ AppDetails DetailsFromAppInfo(std::uint32_t id, const std::string& buffer,
if (licensed) {
auto apps = licensed->apps;
apps.insert(id);
- selected = SelectDepots(*app, apps, licensed->depots, &depots, &reason);
+ selected = SelectDepots(*app, apps, licensed->depots, language, &depots, &reason);
}
- if (!selected && !SelectDepots(*app, owned, std::nullopt, &depots, &reason)) {
+ if (!selected && !SelectDepots(*app, owned, std::nullopt, language, &depots, &reason)) {
details.reason = "No Windows content to install.";
return details;
}
@@ -58,6 +59,7 @@ std::vector<AppDetails> CmAppDetailsSource::Fetch(const StoredSession& session,
const auto fetched = client_.FetchAppInfo(session, app_ids, cancel);
std::vector<AppDetails> result;
if (!fetched.ok()) return result; // the service reports these as retryable
+ const auto language = language_ ? language_() : std::string(kDefaultContentLanguage);
for (const auto id : apps) {
const auto found = fetched.buffers.find(id);
if (found == fetched.buffers.end()) {
@@ -67,7 +69,7 @@ std::vector<AppDetails> CmAppDetailsSource::Fetch(const StoredSession& session,
result.push_back(std::move(missing));
continue;
}
- result.push_back(DetailsFromAppInfo(id, found->second, licensed_ ? licensed_->Get() : std::nullopt));
+ result.push_back(DetailsFromAppInfo(id, found->second, licensed_ ? licensed_->Get() : std::nullopt, language));
}
return result;
}
diff --git a/src/steam/backend/cm_app_details.h b/src/steam/backend/cm_app_details.h
index 156b179..d1ca985 100644
--- a/src/steam/backend/cm_app_details.h
+++ b/src/steam/backend/cm_app_details.h
@@ -2,28 +2,37 @@
#include "steam/app_details_service.h"
#include "steam/backend/cm_client.h"
+#include "steam/backend/content_language.h"
+
+#include <functional>
namespace playden::steam {
-// App details from PICS: totals of the depots Playden would install (Windows, English, public
-// branch) and whether a Windows launch entry exists. Sizes are Steam's per-depot figures, so they
-// are an estimate until the manifests are fetched.
+// App details from PICS: totals of the depots Playden would install (Windows, the chosen content
+// language, public branch) and whether a Windows launch entry exists. Sizes are Steam's per-depot
+// figures, so they are an estimate until the manifests are fetched.
class CmAppDetailsSource final : public AppDetailsSource {
public:
explicit CmAppDetailsSource(CmClient& client) : client_(client) {}
// The licenses the library last read: sizes then count only the depots they grant.
void SetLicensedDepots(const LicensedDepots* licensed) { licensed_ = licensed; }
+ // The content language sizes are counted for; it has to be the one an install would use or
+ // the free-space check is made against the wrong depots. Read on the details worker when a
+ // fetch starts, so a change in Settings reaches the next one.
+ void SetContentLanguage(std::function<std::string()> language) { language_ = std::move(language); }
std::vector<AppDetails> Fetch(const StoredSession& session, const std::vector<GameId>& ids,
const std::atomic<bool>& cancel) override;
private:
CmClient& client_;
const LicensedDepots* licensed_ = nullptr;
+ std::function<std::string()> language_;
};
// Pure part, for tests: turns one parsed app buffer into details. With `licensed`, sizes count
// only the depots those licenses grant, as an install selects them.
AppDetails DetailsFromAppInfo(std::uint32_t id, const std::string& buffer,
- const std::optional<LicensedDepots::Grant>& licensed = std::nullopt);
+ const std::optional<LicensedDepots::Grant>& licensed = std::nullopt,
+ std::string_view language = kDefaultContentLanguage);
} // namespace playden::steam
diff --git a/src/steam/backend/content_language.cpp b/src/steam/backend/content_language.cpp
new file mode 100644
index 0000000..4dd118e
--- /dev/null
+++ b/src/steam/backend/content_language.cpp
@@ -0,0 +1,73 @@
+// content_language.cpp - The languages Steam ships game content in.
+// Copyright (c) 2026 Playden contributors
+// SPDX-License-Identifier: MIT
+#include "steam/backend/content_language.h"
+
+#include <algorithm>
+
+namespace playden::steam {
+namespace {
+
+char Lower(char c) { return (c >= 'A' && c <= 'Z') ? static_cast<char>(c - 'A' + 'a') : c; }
+
+std::string Lowered(std::string_view value) {
+ std::string result(value);
+ for (char& c : result) c = Lower(c);
+ return result;
+}
+
+} // namespace
+
+const std::vector<ContentLanguage>& ContentLanguages() {
+ // Steam's own names, which are what a depot's `language` holds. A few do not read like the
+ // language they stand for: "koreana" is Korean, "brazilian" is Brazilian Portuguese, and
+ // "latam" is Latin American Spanish.
+ static const std::vector<ContentLanguage> languages = {
+ {"english", "English"},
+ {"arabic", "Arabic"},
+ {"bulgarian", "Bulgarian"},
+ {"schinese", "Simplified Chinese"},
+ {"tchinese", "Traditional Chinese"},
+ {"czech", "Czech"},
+ {"danish", "Danish"},
+ {"dutch", "Dutch"},
+ {"finnish", "Finnish"},
+ {"french", "French"},
+ {"german", "German"},
+ {"greek", "Greek"},
+ {"hungarian", "Hungarian"},
+ {"italian", "Italian"},
+ {"japanese", "Japanese"},
+ {"koreana", "Korean"},
+ {"norwegian", "Norwegian"},
+ {"polish", "Polish"},
+ {"portuguese", "Portuguese"},
+ {"brazilian", "Portuguese (Brazil)"},
+ {"romanian", "Romanian"},
+ {"russian", "Russian"},
+ {"spanish", "Spanish (Spain)"},
+ {"latam", "Spanish (Latin America)"},
+ {"swedish", "Swedish"},
+ {"thai", "Thai"},
+ {"turkish", "Turkish"},
+ {"ukrainian", "Ukrainian"},
+ {"vietnamese", "Vietnamese"},
+ };
+ return languages;
+}
+
+bool IsContentLanguage(std::string_view code) {
+ const auto wanted = Lowered(code);
+ const auto& languages = ContentLanguages();
+ return std::any_of(languages.begin(), languages.end(),
+ [&](const ContentLanguage& language) { return language.code == wanted; });
+}
+
+std::string LanguageName(std::string_view code) {
+ const auto wanted = Lowered(code);
+ for (const auto& language : ContentLanguages())
+ if (language.code == wanted) return std::string(language.name);
+ return std::string(code);
+}
+
+} // namespace playden::steam
diff --git a/src/steam/backend/content_language.h b/src/steam/backend/content_language.h
new file mode 100644
index 0000000..a186b2e
--- /dev/null
+++ b/src/steam/backend/content_language.h
@@ -0,0 +1,33 @@
+// content_language.h - The languages Steam ships game content in.
+// Copyright (c) 2026 Playden contributors
+// SPDX-License-Identifier: MIT
+#pragma once
+
+#include <string>
+#include <string_view>
+#include <vector>
+
+namespace playden::steam {
+
+// A language Steam tags depots with, and the name a player reads.
+struct ContentLanguage {
+ std::string_view code; // as app info writes it: "german", "koreana", "schinese"
+ std::string_view name; // "German", "Korean", "Simplified Chinese"
+};
+
+// What Playden has always installed, and what a game that carries no depot in the chosen
+// language falls back to.
+inline constexpr std::string_view kDefaultContentLanguage = "english";
+
+// Every language Steam uses, in the order the picker shows them: the default first, then the
+// rest by name. The same set the Steamworks emulator is told about.
+const std::vector<ContentLanguage>& ContentLanguages();
+
+// True when `code` is one Steam uses. Comparison ignores case.
+bool IsContentLanguage(std::string_view code);
+
+// The player-facing name of `code` ("german" -> "German"), or `code` itself when Steam has no
+// such language, so a depot tagged with something unexpected still reads sensibly.
+std::string LanguageName(std::string_view code);
+
+} // namespace playden::steam
diff --git a/src/steam/backend/download_server_source.cpp b/src/steam/backend/download_server_source.cpp
index 73e05c0..ef2dc63 100644
--- a/src/steam/backend/download_server_source.cpp
+++ b/src/steam/backend/download_server_source.cpp
@@ -2,6 +2,7 @@
#include "steam/backend/download_server_source.h"
#include "steam/backend/app_info.h"
+#include "steam/backend/content_language.h"
#include "steam/backend/depot_manifest.h"
#include "steam/backend/gzip.h"
@@ -81,7 +82,7 @@ CdnDownloadServerSource::PayloadResult CdnDownloadServerSource::PrepareApp(
if (common) {
for (const auto& depot : app->depots)
if (depot.id == 228990 && depot.manifest_gid) depots.push_back(depot);
- } else if (!SelectDepots(*app, {app_id}, std::nullopt, &depots, nullptr)) return PayloadResult::kFailed;
+ } else if (!SelectDepots(*app, {app_id}, std::nullopt, kDefaultContentLanguage, &depots, nullptr)) return PayloadResult::kFailed;
if (depots.empty()) return PayloadResult::kFailed;
// Prefer the game's own depots over borrowed content. A refused depot does not prevent
// another readable depot of the installed game from supplying the sample.
diff --git a/src/steam/backend/steam_install_runner.cpp b/src/steam/backend/steam_install_runner.cpp
index d385c7b..55058c8 100644
--- a/src/steam/backend/steam_install_runner.cpp
+++ b/src/steam/backend/steam_install_runner.cpp
@@ -215,7 +215,8 @@ InstallRunner::Result SteamInstallRunner::InstallApp(const StoredSession& sessio
}
std::set<std::uint32_t> owned_apps = entitlements.owned_apps;
owned_apps.insert(id);
- if (!SelectDepots(*app, owned_apps, entitlements.owned_depots, &target.depots, &reason)) {
+ const std::string language = language_ ? language_() : std::string(kDefaultContentLanguage);
+ if (!SelectDepots(*app, owned_apps, entitlements.owned_depots, language, &target.depots, &reason)) {
log("depots", "none", reason.c_str());
result.failure = "No Windows content to install.";
return result;
@@ -286,7 +287,7 @@ InstallRunner::Result SteamInstallRunner::InstallApp(const StoredSession& sessio
depots.push_back(depot.id);
for (const auto app_id : app->dlc_app_ids)
if (entitlements.owned_apps.count(app_id)) dlc.push_back(app_id);
- if (!runtime::WriteSteamworksFacts(root, depots, dlc)) log("steamworks_facts", "write-failed", root.c_str());
+ if (!runtime::WriteSteamworksFacts(root, depots, dlc, language)) log("steamworks_facts", "write-failed", root.c_str());
}
result.canceled = outcome.error == InstallError::kCanceled;
result.retry_later = outcome.error == InstallError::kNetwork;
diff --git a/src/steam/backend/steam_install_runner.h b/src/steam/backend/steam_install_runner.h
index 7c78082..4f90b8b 100644
--- a/src/steam/backend/steam_install_runner.h
+++ b/src/steam/backend/steam_install_runner.h
@@ -2,6 +2,7 @@
#include "steam/backend/cdn_client.h"
#include "steam/backend/cm_client.h"
+#include "steam/backend/content_language.h"
#include "steam/backend/depot_installer.h"
#include "steam/install_service.h"
@@ -37,8 +38,8 @@ std::vector<std::string> FormatInstallServerStats(const std::vector<InstallServe
using InstallLogFn = std::function<void(std::uint32_t app, const char* step, const char* category, const char* detail)>;
void LogInstallTrace(const InstallLogFn& log, std::uint32_t app, const char* marker);
-// Installs a Steam game: PICS app info for the depot selection (Windows, English, public
-// branch), then the resumable depot installer.
+// Installs a Steam game: PICS app info for the depot selection (Windows, the chosen content
+// language, public branch), then the resumable depot installer.
class SteamInstallRunner final : public SessionInstallRunner {
public:
SteamInstallRunner(SessionRepository& sessions, CmClient& cm, CdnClient& cdn, FastestServerCache::Now now = {})
@@ -51,6 +52,9 @@ class SteamInstallRunner final : public SessionInstallRunner {
std::string DownloadServerName() const override { return server_name_; }
FastestServerCache& fastest_server() { return fastest_; }
void SetTuning(std::function<DownloadTuning()> tuning) { tuning_ = std::move(tuning); }
+ // The content language each install selects depots for, read when the install starts so a
+ // change to the setting reaches the next download. English when unset.
+ void SetContentLanguage(std::function<std::string()> language) { language_ = std::move(language); }
// Optional sanitized log: the Steam app ID, step, error category and a short detail; never
// tokens or account identifiers. Called on the install worker.
using LogFn = InstallLogFn;
@@ -92,6 +96,7 @@ class SteamInstallRunner final : public SessionInstallRunner {
std::string server_name_; // the install worker's own: set and read during InstallApp's progress
LogFn log_;
std::function<DownloadTuning()> tuning_;
+ std::function<std::string()> language_;
std::atomic<std::uint32_t> current_app_{0};
};
diff --git a/tests/app_details_test.cpp b/tests/app_details_test.cpp
index 5e4c9e3..7210277 100644
--- a/tests/app_details_test.cpp
+++ b/tests/app_details_test.cpp
@@ -240,6 +240,31 @@ void OtherBranchOptionsAreCandidates() {
dragonwilds.launches[1].executable == "Aqua-Coyote.exe");
}
+// The size shown has to count the depots the install will fetch: a localised game is bigger in
+// a language it carries, and the free-space check is made against that figure.
+void SizesFollowTheContentLanguage() {
+ const std::string buffer = R"("appinfo"
+{
+ "appid" "400"
+ "common" { "name" "Portal" "type" "Game" }
+ "config" { "launch" { "0" { "executable" "portal.exe" "config" { "oslist" "windows" } } } }
+ "depots"
+ {
+ "401" { "config" { "oslist" "windows" } "manifests" { "public" { "gid" "1" "size" "1000" "download" "400" } } }
+ "402" { "config" { "oslist" "windows" "language" "russian" } "manifests" { "public" { "gid" "2" "size" "500" "download" "200" } } }
+ }
+})";
+ const auto english = DetailsFromAppInfo(400, buffer);
+ assert(english.available && english.install_bytes == 1000u && english.download_bytes == 400u);
+
+ const auto russian = DetailsFromAppInfo(400, buffer, std::nullopt, "russian");
+ assert(russian.available && russian.install_bytes == 1500u && russian.download_bytes == 600u);
+
+ // A language the game does not carry is installed in English, and sized as English.
+ const auto polish = DetailsFromAppInfo(400, buffer, std::nullopt, "polish");
+ assert(polish.available && polish.install_bytes == 1000u && polish.download_bytes == 400u);
+}
+
int main() {
SizesCountOnlyLicensedDepots();
RequestsAreDeduplicatedPerGeneration();
@@ -249,4 +274,5 @@ int main() {
DefaultBetaKeyIsThePublicBranch();
OtherBranchOptionsAreCandidates();
ImpossibleDownloadSizeFallsBackToInstallSize();
+ SizesFollowTheContentLanguage();
}
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index ea8b51f..7f78330 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -1243,8 +1243,9 @@ void live_storage_section_and_installed_games() {
check(section_of(key) == "Storage", "the storage rows are in the Storage section");
std::vector<std::string> library;
for (const auto& row : model.view().rows) if (row.section == "Library") library.push_back(row.key);
- check(library == std::vector<std::string>{"settings-import", "settings-title-store", "settings-cloud-saves"},
- "Library starts with Import games, then its two toggles");
+ check(library == std::vector<std::string>{"settings-import", "settings-title-store", "settings-content-language",
+ "settings-cloud-saves"},
+ "Library starts with Import games, then the store name, game language and Cloud saves rows");
check(find_row(model, "settings-storage")->action == "storage-picker", "Games storage opens the drive picker");
std::vector<std::string> order;
for (const auto& row : model.view().rows) if (row.section == "Storage") order.push_back(row.key);
diff --git a/tests/preferences_test.cpp b/tests/preferences_test.cpp
index 9e8e722..85eb045 100644
--- a/tests/preferences_test.cpp
+++ b/tests/preferences_test.cpp
@@ -186,9 +186,10 @@ void SignInMethodPersistsAndVersionThreeOpensQr() {
Check(store.Save(preferences).ok(), "sign-in method preference saves");
const auto saved = storage.Read("preferences.conf");
Check(saved.ok() && std::string(saved.value().begin(), saved.value().end()) ==
- "version=9\nreduce_motion=0\ntitle_store_suffix=0\ncloud_saves_auto=1\nsteam_sign_in_password=1\n"
- "downloads_slow_network=0\nsteam_stay_signed_in=1\nbeta_updates=0\ndownload_server=\nweb_access=1\n",
- "version 9 format includes Automatic download server and web access");
+ "version=10\nreduce_motion=0\ntitle_store_suffix=0\ncloud_saves_auto=1\nsteam_sign_in_password=1\n"
+ "downloads_slow_network=0\nsteam_stay_signed_in=1\nbeta_updates=0\ndownload_server=\nweb_access=1\n"
+ "content_language=english\n",
+ "version 10 format includes Automatic download server, web access and English");
const auto loaded = store.Load();
Check(loaded.status == playden::PreferencesLoadStatus::kLoaded && loaded.preferences.steam_sign_in_password &&
loaded.preferences.cloud_saves_auto,
@@ -344,9 +345,10 @@ void OlderPreferencesUseAutomaticDownloadServer() {
"migration retains old fields and defaults later fields");
Check(store.Save(loaded.preferences).ok(), "migrated preferences save");
const auto saved = storage.Read("preferences.conf");
- Check(saved.ok() && std::string(saved.value().begin(), saved.value().end()).rfind("version=9\n", 0) == 0,
- "saving a migrated file writes version 9");
+ Check(saved.ok() && std::string(saved.value().begin(), saved.value().end()).rfind("version=10\n", 0) == 0,
+ "saving a migrated file writes version 10");
Check(loaded.preferences.web_access, "every older preference version has web access on");
+ Check(loaded.preferences.content_language == "english", "every older preference version downloads English");
}
}
@@ -447,6 +449,63 @@ void PreferencesPrepareIndependentRoot() {
std::remove((root+"/preferences.conf").c_str());rmdir(root.c_str());
}
+void ContentLanguagePersistsAndOlderVersionsStayEnglish() {
+ TemporaryDirectory directory;
+ playden::Storage storage(directory.path());
+ playden::PreferencesStore store(storage);
+ Check(store.Load().preferences.content_language == "english", "a fresh install downloads English");
+ const std::string version_seven =
+ "version=7\nreduce_motion=0\ntitle_store_suffix=0\ncloud_saves_auto=0\nsteam_sign_in_password=0\n"
+ "downloads_slow_network=0\nsteam_stay_signed_in=1\nbeta_updates=1\n";
+ const std::string version_nine =
+ "version=9\nreduce_motion=0\ntitle_store_suffix=0\ncloud_saves_auto=0\nsteam_sign_in_password=0\n"
+ "downloads_slow_network=0\nsteam_stay_signed_in=1\nbeta_updates=1\ndownload_server=cache.example\nweb_access=0\n";
+ const std::string version_eight =
+ "version=8\nreduce_motion=0\ntitle_store_suffix=0\ncloud_saves_auto=0\nsteam_sign_in_password=0\n"
+ "downloads_slow_network=0\nsteam_stay_signed_in=1\nbeta_updates=1\ndownload_server=cache.example\n";
+ for (const auto& old : {version_seven, version_eight, version_nine}) {
+ Check(storage.WriteAtomic("preferences.conf", playden::Bytes(old.begin(), old.end())).ok(), "older fixture is written");
+ const auto loaded = store.Load();
+ Check(loaded.status == playden::PreferencesLoadStatus::kLoaded && loaded.preferences.beta_updates &&
+ loaded.preferences.content_language == "english",
+ "version 7 to 9 preferences load and keep downloading English");
+ }
+ Check(storage.WriteAtomic("preferences.conf", playden::Bytes(version_nine.begin(), version_nine.end())).ok(),
+ "version 9 fixture is written");
+ const auto nine = store.Load();
+ Check(!nine.preferences.web_access && nine.preferences.download_server == "cache.example",
+ "version 9 keeps web access and the download server alongside English");
+ playden::Preferences preferences;
+ preferences.content_language = "german";
+ preferences.download_server = "fastest";
+ preferences.web_access = false;
+ Check(store.Save(preferences).ok(), "a chosen game language saves");
+ const auto german = store.Load();
+ Check(german.status == playden::PreferencesLoadStatus::kLoaded && german.preferences.content_language == "german" &&
+ german.preferences.download_server == "fastest" && !german.preferences.web_access,
+ "the chosen game language survives restart with the other fields");
+ playden::Preferences unknown;
+ unknown.content_language = "klingon\nbeta_updates=1";
+ Check(store.Save(unknown).ok(), "an unknown game language saves");
+ const auto english = store.Load();
+ Check(english.status == playden::PreferencesLoadStatus::kLoaded && english.preferences.content_language == "english" &&
+ !english.preferences.beta_updates,
+ "an unknown game language is saved as English and cannot inject a preference");
+ const std::string ten =
+ "version=10\nreduce_motion=0\ntitle_store_suffix=0\ncloud_saves_auto=0\nsteam_sign_in_password=0\n"
+ "downloads_slow_network=0\nsteam_stay_signed_in=1\nbeta_updates=0\ndownload_server=\nweb_access=1\n";
+ const std::string malformed[] = {ten + "content_language=klingon\n", ten + "content_language=\n", ten,
+ ten + "content_language=german\nx=1\n", version_nine + "content_language=german\n",
+ "version=10" + version_nine.substr(9)};
+ for (const auto& text : malformed) {
+ Check(storage.WriteAtomic("preferences.conf", playden::Bytes(text.begin(), text.end())).ok(), "bad fixture is written");
+ const auto corrupt = store.Load();
+ Check(corrupt.status == playden::PreferencesLoadStatus::kDefaultCorrupt &&
+ corrupt.preferences.content_language == "english",
+ "a language Steam does not have, or a malformed version 10 file, is corrupt and restores English");
+ }
+}
+
} // namespace
int main() {
@@ -466,6 +525,7 @@ int main() {
OlderPreferencesUseAutomaticDownloadServer();
DownloadServerRoundTripsAndInvalidHostsUseAutomatic();
VersionEightRejectsTruncatedOrMalformedFiles();
+ ContentLanguagePersistsAndOlderVersionsStayEnglish();
if (failures != 0) {
std::fprintf(stderr, "%d preference test assertion(s) failed\n", failures);
diff --git a/tests/runtime_steamworks_test.cpp b/tests/runtime_steamworks_test.cpp
index f440b62..ed19655 100644
--- a/tests/runtime_steamworks_test.cpp
+++ b/tests/runtime_steamworks_test.cpp
@@ -154,6 +154,23 @@ int main(int argc, char** argv) {
SteamworksIdentity facts;
CHECK(ReadSteamworksFacts(root.string(), &facts));
CHECK((facts.depots == std::vector<std::uint32_t>{10, 20}) && (facts.owned_dlc == std::vector<std::uint32_t>{3000, 3001}));
+ // A file from before Playden could choose a language reads as English, which is what it got.
+ CHECK(facts.language == "english");
+
+ // Each game keeps the language it was downloaded in, whatever Settings says now, so the
+ // emulator tells the game the language its files are actually in.
+ Write(root / kSteamworksFactsFile, SerializeSteamworksFacts({20, 10}, {3001, 3000}, "russian"));
+ SteamworksIdentity localised;
+ CHECK(ReadSteamworksFacts(root.string(), &localised));
+ CHECK(localised.language == "russian" && (localised.depots == std::vector<std::uint32_t>{10, 20}));
+ // English is the default, so it is not written out; the reader answers with it either way.
+ CHECK(SerializeSteamworksFacts({10}, {}, "english").find("language=") == std::string::npos);
+ // A language Steam does not have leaves the game on English rather than reaching the emulator.
+ Write(root / kSteamworksFactsFile, "depots=10\ndlc=\nlanguage=klingon\n");
+ SteamworksIdentity unknown;
+ CHECK(ReadSteamworksFacts(root.string(), &unknown));
+ CHECK(unknown.language == "english");
+
Write(root / kSteamworksFactsFile, "depots=1,x\n");
CHECK(!ReadSteamworksFacts(root.string(), &facts));
// A game without steam_api: nothing to do.
diff --git a/tests/steam_app_info_test.cpp b/tests/steam_app_info_test.cpp
index eaaecac..f6bb0d2 100644
--- a/tests/steam_app_info_test.cpp
+++ b/tests/steam_app_info_test.cpp
@@ -262,31 +262,31 @@ void TestSelectDepots() {
CHECK(app);
std::vector<DepotInfo> selected;
std::string reason;
- CHECK(SelectDepots(*app, {kApp}, std::nullopt, &selected, &reason));
+ CHECK(SelectDepots(*app, {kApp}, std::nullopt, "english", &selected, &reason));
CHECK((Ids(selected) == U32s{101, 106}));
- CHECK(SelectDepots(*app, {kApp, 999}, std::nullopt, &selected, &reason));
+ CHECK(SelectDepots(*app, {kApp, 999}, std::nullopt, "english", &selected, &reason));
CHECK((Ids(selected) == U32s{101, 105, 106}));
- CHECK(SelectDepots(*app, {kApp, 999}, std::set<std::uint32_t>{101}, &selected, &reason));
+ CHECK(SelectDepots(*app, {kApp, 999}, std::set<std::uint32_t>{101}, "english", &selected, &reason));
CHECK((Ids(selected) == U32s{101}));
- CHECK(!SelectDepots(*app, {999}, std::nullopt, &selected, &reason));
+ CHECK(!SelectDepots(*app, {999}, std::nullopt, "english", &selected, &reason));
CHECK(reason.find("does not own") != std::string::npos);
- CHECK(!SelectDepots(*app, {kApp}, std::set<std::uint32_t>{102, 103, 104}, &selected, &reason));
+ CHECK(!SelectDepots(*app, {kApp}, std::set<std::uint32_t>{102, 103, 104}, "english", &selected, &reason));
CHECK(reason.find("no downloadable") != std::string::npos);
AppInfo empty_manifest = *app;
for (DepotInfo& d : empty_manifest.depots) d.manifest_gid = 0;
- CHECK(!SelectDepots(empty_manifest, {kApp, 999}, std::nullopt, &selected, &reason));
+ CHECK(!SelectDepots(empty_manifest, {kApp, 999}, std::nullopt, "english", &selected, &reason));
CHECK(reason.find("public branch") != std::string::npos);
AppInfo duplicate = *app;
duplicate.depots.push_back(duplicate.depots[0]);
- CHECK(!SelectDepots(duplicate, {kApp}, std::nullopt, &selected, &reason));
+ CHECK(!SelectDepots(duplicate, {kApp}, std::nullopt, "english", &selected, &reason));
// depot_from_app grants access even when the account's depot list omits it.
AppInfo from_app = *app;
from_app.depots[0].depot_from_app = 5;
- CHECK(SelectDepots(from_app, {kApp}, std::set<std::uint32_t>{106}, &selected, &reason));
+ CHECK(SelectDepots(from_app, {kApp}, std::set<std::uint32_t>{106}, "english", &selected, &reason));
CHECK((Ids(selected) == U32s{101, 106}));
AppInfo architectures;
@@ -303,19 +303,60 @@ void TestSelectDepots() {
shared.id = 203;
shared.os_arch.clear();
architectures.depots = {win32, shared, win64};
- CHECK(SelectDepots(architectures, {kApp}, std::nullopt, &selected, &reason));
+ CHECK(SelectDepots(architectures, {kApp}, std::nullopt, "english", &selected, &reason));
CHECK((Ids(selected) == U32s{201, 203}));
architectures.depots.erase(architectures.depots.begin() + 2);
- CHECK(SelectDepots(architectures, {kApp}, std::nullopt, &selected, &reason));
+ CHECK(SelectDepots(architectures, {kApp}, std::nullopt, "english", &selected, &reason));
CHECK((Ids(selected) == U32s{202, 203}));
architectures.depots.push_back(win64);
architectures.depots.back().manifest_gid = 0;
- CHECK(SelectDepots(architectures, {kApp}, std::nullopt, &selected, &reason));
+ CHECK(SelectDepots(architectures, {kApp}, std::nullopt, "english", &selected, &reason));
CHECK((Ids(selected) == U32s{202, 203}));
}
+// The content language picks the localised depots to install beside the language-neutral ones.
+void TestDepotLanguage() {
+ const auto app = ParseAppInfo(kApp, Buffer());
+ CHECK(app);
+ std::vector<DepotInfo> selected;
+ std::string reason;
+
+ // 101 and 106 carry no language and belong to every one; 103 is the German depot.
+ CHECK(SelectDepots(*app, {kApp}, std::nullopt, "german", &selected, &reason));
+ CHECK((Ids(selected) == U32s{101, 103, 106}));
+ CHECK(SelectDepots(*app, {kApp}, std::nullopt, "GERMAN", &selected, &reason));
+ CHECK((Ids(selected) == U32s{101, 103, 106}));
+
+ // The game has no Russian depot, so it is installed in English rather than without its
+ // localised content: asking for a language a game does not carry never installs less.
+ CHECK(SelectDepots(*app, {kApp}, std::nullopt, "russian", &selected, &reason));
+ CHECK((Ids(selected) == U32s{101, 106}));
+ // An empty language is English, which is what Playden installed before it could be chosen.
+ CHECK(SelectDepots(*app, {kApp}, std::nullopt, "", &selected, &reason));
+ CHECK((Ids(selected) == U32s{101, 106}));
+
+ // A language depot the licenses do not grant is left out, like any other.
+ CHECK(SelectDepots(*app, {kApp}, std::set<std::uint32_t>{101, 103}, "german", &selected, &reason));
+ CHECK((Ids(selected) == U32s{101, 103}));
+ CHECK(SelectDepots(*app, {kApp}, std::set<std::uint32_t>{101}, "german", &selected, &reason));
+ CHECK((Ids(selected) == U32s{101}));
+
+ // Nothing to install says which language it looked for.
+ CHECK(!SelectDepots(*app, {kApp}, std::set<std::uint32_t>{102, 104}, "german", &selected, &reason));
+ CHECK(reason.find("German") != std::string::npos);
+
+ // A game whose only Windows content is localised installs that content.
+ AppInfo localised = *app;
+ for (DepotInfo& depot : localised.depots)
+ if (depot.id == 101) depot.language = "german";
+ CHECK(SelectDepots(localised, {kApp}, std::nullopt, "german", &selected, &reason));
+ CHECK((Ids(selected) == U32s{101, 103, 106}));
+ CHECK(SelectDepots(localised, {kApp}, std::nullopt, "english", &selected, &reason));
+ CHECK((Ids(selected) == U32s{106}));
+}
+
// A partial grant must not install as if complete (issue #58): Team Fortress 2's content depot has
// no oslist or language and comes from a license the account's other one lacks.
void TestMissingBaseDepots() {
@@ -337,12 +378,12 @@ void TestMissingBaseDepots() {
std::string reason;
const std::set<std::uint32_t> partial{232251};
- CHECK(SelectDepots(app, {440}, partial, &selected, &reason));
+ CHECK(SelectDepots(app, {440}, partial, "english", &selected, &reason));
CHECK((Ids(selected) == U32s{232251}));
CHECK((MissingBaseDepots(app, partial, selected) == U32s{441, 450}));
const std::set<std::uint32_t> full{441, 232251};
- CHECK(SelectDepots(app, {440}, full, &selected, &reason));
+ CHECK(SelectDepots(app, {440}, full, "english", &selected, &reason));
CHECK((Ids(selected) == U32s{441, 232251}));
// An unowned depot smaller than the game is an extra, not the game.
CHECK(MissingBaseDepots(app, full, selected).empty());
@@ -350,7 +391,7 @@ void TestMissingBaseDepots() {
CHECK(MissingBaseDepots(app, std::nullopt, selected).empty());
AppInfo sizeless = app;
for (DepotInfo& depot : sizeless.depots) depot.size = 0;
- CHECK(SelectDepots(sizeless, {440}, partial, &selected, &reason));
+ CHECK(SelectDepots(sizeless, {440}, partial, "english", &selected, &reason));
CHECK(MissingBaseDepots(sizeless, partial, selected).empty());
// Marvel Rivals: the free license grants one content depot; a same-size copy and a third content
@@ -367,7 +408,7 @@ void TestMissingBaseDepots() {
other.size = 20'311'069'758ull;
rivals.depots = {granted, copy, other};
const std::set<std::uint32_t> free_license{2767031};
- CHECK(SelectDepots(rivals, {2767030}, free_license, &selected, &reason));
+ CHECK(SelectDepots(rivals, {2767030}, free_license, "english", &selected, &reason));
CHECK((Ids(selected) == U32s{2767031}));
CHECK(MissingBaseDepots(rivals, free_license, selected).empty());
}
@@ -477,6 +518,7 @@ int main() {
TestParse();
TestParseDefaultsAndFailures();
TestSelectDepots();
+ TestDepotLanguage();
TestMissingBaseDepots();
TestEligibleLaunches();
TestWindowsArguments();