diff --git a/src/client/component/filesystem.cpp b/src/client/component/filesystem.cpp index f640120f..b911dcb8 100644 --- a/src/client/component/filesystem.cpp +++ b/src/client/component/filesystem.cpp @@ -5,6 +5,7 @@ #include "console.hpp" #include "localized_strings.hpp" #include "mods.hpp" +#include "language.hpp" #include "game/game.hpp" @@ -25,20 +26,6 @@ namespace filesystem return search_paths; } - bool is_fallback_lang() - { - static auto* loc_language = game::Dvar_FindVar("loc_language"); - const auto id = loc_language->current.integer; - return id == 5 || id == 6 || id == 8 || id == 9 || id == 10 || id == 11 || id == 12 || id == 13 || id == 15 || id == 17; - } - - bool is_polrus_lang() - { - static auto* loc_language = game::Dvar_FindVar("loc_language"); - const auto id = loc_language->current.integer; - return id == 5 || id == 6 || id == 12 || id == 13 || id == 17; - } - void fs_startup_stub(const char* name) { console::info("[FS] Startup\n"); @@ -68,12 +55,12 @@ namespace filesystem paths.push_back(path); - if (is_fallback_lang()) + if (language::is_non_latin()) { paths.push_back(path / "fallback"); } - if (is_polrus_lang()) + if (language::is_polrus() || language::is_arabic()) { paths.push_back(path / "polrus"); } diff --git a/src/client/component/fonts.cpp b/src/client/component/fonts.cpp index c273347c..6d18e1d7 100644 --- a/src/client/component/fonts.cpp +++ b/src/client/component/fonts.cpp @@ -5,6 +5,7 @@ #include "console.hpp" #include "filesystem.hpp" #include "command.hpp" +#include "language.hpp" #include "game/game.hpp" #include "game/dvars.hpp" @@ -138,9 +139,21 @@ namespace fonts return ui_get_font_handle_hook.invoke(a1, font_index); } + game::Font_s* get_bank_font() + { + if (language::is_asian()) + { + return game::R_RegisterFont("fonts/defaultBold.otf", 32); + } + else + { + return game::R_RegisterFont("fonts/bank.ttf", 32); + } + } + void* ui_asset_cache_stub() { - bank_font = game::R_RegisterFont("fonts/bank.ttf", 32); + bank_font = get_bank_font(); return ui_asset_cache_hook.invoke(); } diff --git a/src/client/component/language.cpp b/src/client/component/language.cpp index dbae1f90..39d5ee0c 100644 --- a/src/client/component/language.cpp +++ b/src/client/component/language.cpp @@ -1,10 +1,8 @@ #include #include "loader/component_loader.hpp" -#include "game/game.hpp" -#include "game/dvars.hpp" - #include "language.hpp" + #include "localized_strings.hpp" #include @@ -16,6 +14,37 @@ namespace language { namespace { + std::unordered_set non_latin_languages = + { + {game::LANGUAGE_RUSSIAN}, + {game::LANGUAGE_POLISH}, + {game::LANGUAGE_JAPANESE_FULL}, + {game::LANGUAGE_JAPANESE_PARTIAL}, + {game::LANGUAGE_TRADITIONAL_CHINESE}, + {game::LANGUAGE_SIMPLIFIED_CHINESE}, + {game::LANGUAGE_ARABIC}, + {game::LANGUAGE_CZECH}, + {game::LANGUAGE_KOREAN}, + {game::LANGUAGE_RUSSIAN_PARTIAL}, + }; + + std::unordered_set cyrillic_languages = + { + game::LANGUAGE_RUSSIAN, + game::LANGUAGE_POLISH, + game::LANGUAGE_CZECH, + game::LANGUAGE_RUSSIAN_PARTIAL, + }; + + + std::unordered_set asian_languages = + { + game::LANGUAGE_JAPANESE_FULL, + game::LANGUAGE_JAPANESE_PARTIAL, + game::LANGUAGE_TRADITIONAL_CHINESE, + game::LANGUAGE_SIMPLIFIED_CHINESE, + }; + const char* get_loc_language_string() { if (!utils::io::file_exists(LANGUAGE_FILE)) @@ -30,6 +59,32 @@ namespace language } } + game::language_t current() + { + static auto* loc_language = game::Dvar_FindVar("loc_language"); + return static_cast(loc_language->current.integer); + } + + bool is_non_latin() + { + return non_latin_languages.contains(current()); + } + + bool is_polrus() + { + return cyrillic_languages.contains(current()); + } + + bool is_arabic() + { + return current() == game::LANGUAGE_ARABIC; + } + + bool is_asian() + { + return asian_languages.contains(current()); + } + void set(const std::string& lang) { utils::io::write_file(LANGUAGE_FILE, lang, false); diff --git a/src/client/component/language.hpp b/src/client/component/language.hpp index d3621634..e1a54eea 100644 --- a/src/client/component/language.hpp +++ b/src/client/component/language.hpp @@ -1,7 +1,15 @@ #pragma once +#include "game/game.hpp" +#include "game/dvars.hpp" namespace language { void set(const std::string& language); void set_from_index(const int index); + + game::language_t current(); + bool is_non_latin(); + bool is_polrus(); + bool is_arabic(); + bool is_asian(); } diff --git a/src/client/game/structs.hpp b/src/client/game/structs.hpp index 1bb32712..8595bbd6 100644 --- a/src/client/game/structs.hpp +++ b/src/client/game/structs.hpp @@ -1595,6 +1595,29 @@ namespace game char __pad0[0x8]; }; + enum language_t + { + LANGUAGE_ENGLISH = 0, + LANGUAGE_FRENCH = 1, + LANGUAGE_GERMAN = 2, + LANGUAGE_ITALIAN = 3, + LANGUAGE_SPANISH = 4, + LANGUAGE_RUSSIAN = 5, + LANGUAGE_POLISH = 6, + LANGUAGE_PORTUGUESE = 7, + LANGUAGE_JAPANESE_FULL = 8, + LANGUAGE_JAPANESE_PARTIAL = 9, + LANGUAGE_TRADITIONAL_CHINESE = 10, + LANGUAGE_SIMPLIFIED_CHINESE = 11, + LANGUAGE_ARABIC = 12, + LANGUAGE_CZECH = 13, + LANGUAGE_SPANISHNA = 14, + LANGUAGE_KOREAN = 15, + LANGUAGE_ENGLISH_SAFE = 16, + LANGUAGE_RUSSIAN_PARTIAL = 17, + LANGUAGE_COUNT + }; + struct rectDef_s { float x;