Add supported_languages.txt to specify which languages are available in a game.

This commit is contained in:
Mr_Goldberg 2022-08-13 14:40:55 -04:00
parent 63128907fd
commit 0800649d8f
No known key found for this signature in database
GPG key ID: 8597D87419DEF278
4 changed files with 52 additions and 0 deletions

View file

@ -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.

View file

@ -156,6 +156,9 @@ public:
//app build id
int build_id = 10;
//supported languages
std::set<std::string> supported_languages;
//make lobby creation fail in the matchmaking interface
bool disable_lobby_creation = false;

View file

@ -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<std::string> 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";

View file

@ -0,0 +1,8 @@
english
german
french
spanish
schinese
russian
japanese
latam