From 0800649d8f4048b910fbde78608867b5c96c41b2 Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Sat, 13 Aug 2022 14:40:55 -0400 Subject: [PATCH] Add supported_languages.txt to specify which languages are available in a game. --- Readme_release.txt | 4 ++ dll/settings.h | 3 ++ dll/settings_parser.cpp | 37 +++++++++++++++++++ .../supported_languages.EXAMPLE.txt | 8 ++++ 4 files changed, 52 insertions(+) create mode 100644 files_example/steam_settings.EXAMPLE/supported_languages.EXAMPLE.txt diff --git a/Readme_release.txt b/Readme_release.txt index 105f005..2a02c1c 100644 --- a/Readme_release.txt +++ b/Readme_release.txt @@ -44,6 +44,10 @@ If the DLC file is present, the emulator will only unlock the DLCs in that file. The contents of this file are: appid=DLC name See the steam_settings.EXAMPLE folder for an example. +Languages: +You can include a steam_settings\supported_languages.txt file with a list of languages that the game supports. If the global emu language setting is not in this list of languages the emu will default to the first language in the list. +See the steam_settings.EXAMPLE folder for an example. + Depots: This is pretty rare but some games might use depot ids to see if dlcs are installed. You can provide a list of installed depots to the game with a steam_settings\depots.txt file. See the steam_settings.EXAMPLE folder for an example. diff --git a/dll/settings.h b/dll/settings.h index 28fc3f0..a7b2aa9 100644 --- a/dll/settings.h +++ b/dll/settings.h @@ -156,6 +156,9 @@ public: //app build id int build_id = 10; + //supported languages + std::set supported_languages; + //make lobby creation fail in the matchmaking interface bool disable_lobby_creation = false; diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index 3aa8ded..22dad2e 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -260,6 +260,41 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s local_storage->store_data_settings("user_steam_id.txt", temp_text, strlen(temp_text)); } + std::set supported_languages; + + { + std::string lang_config_path = Local_Storage::get_game_settings_path() + "supported_languages.txt"; + std::ifstream input( utf8_decode(lang_config_path) ); + + std::string first_language; + if (input.is_open()) { + consume_bom(input); + for( std::string line; getline( input, line ); ) { + if (!line.empty() && line[line.length()-1] == '\n') { + line.pop_back(); + } + + if (!line.empty() && line[line.length()-1] == '\r') { + line.pop_back(); + } + + try { + std::string lang = line; + if (!first_language.size()) first_language = lang; + supported_languages.insert(lang); + PRINT_DEBUG("Added supported_language %s\n", lang.c_str()); + } catch (...) {} + } + } + + if (!supported_languages.count(language)) { + if (first_language.size()) { + memset(language, 0, sizeof(language)); + first_language.copy(language, sizeof(language) - 1); + } + } + } + bool steam_offline_mode = false; bool disable_networking = false; bool disable_overlay = false; @@ -336,6 +371,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s settings_server->warn_forced = warn_forced; settings_client->warn_local_save = local_save; settings_server->warn_local_save = local_save; + settings_client->supported_languages = supported_languages; + settings_server->supported_languages = supported_languages; { std::string dlc_config_path = Local_Storage::get_game_settings_path() + "DLC.txt"; diff --git a/files_example/steam_settings.EXAMPLE/supported_languages.EXAMPLE.txt b/files_example/steam_settings.EXAMPLE/supported_languages.EXAMPLE.txt new file mode 100644 index 0000000..60c84dd --- /dev/null +++ b/files_example/steam_settings.EXAMPLE/supported_languages.EXAMPLE.txt @@ -0,0 +1,8 @@ +english +german +french +spanish +schinese +russian +japanese +latam