diff options
Diffstat (limited to 'NorthstarDLL/client')
-rw-r--r-- | NorthstarDLL/client/modlocalisation.cpp | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/NorthstarDLL/client/modlocalisation.cpp b/NorthstarDLL/client/modlocalisation.cpp index 430e3a5f..e5afc793 100644 --- a/NorthstarDLL/client/modlocalisation.cpp +++ b/NorthstarDLL/client/modlocalisation.cpp @@ -3,30 +3,51 @@ AUTOHOOK_INIT() +void* g_pVguiLocalize; + // clang-format off -AUTOHOOK(AddLocalisationFile, localize.dll + 0x6D80, -bool, __fastcall, (void* pVguiLocalize, const char* path, const char* pathId, char unknown)) +AUTOHOOK(CLocalize__AddFile, localize.dll + 0x6D80, +bool, __fastcall, (void* pVguiLocalize, const char* path, const char* pathId, bool bIncludeFallbackSearchPaths)) // clang-format on { - static bool bLoadModLocalisationFiles = true; - bool ret = AddLocalisationFile(pVguiLocalize, path, pathId, unknown); + // save this for later + g_pVguiLocalize = pVguiLocalize; + bool ret = CLocalize__AddFile(pVguiLocalize, path, pathId, bIncludeFallbackSearchPaths); if (ret) spdlog::info("Loaded localisation file {} successfully", path); - if (!bLoadModLocalisationFiles) - return ret; - - bLoadModLocalisationFiles = false; + return true; +} +// clang-format off +AUTOHOOK(CLocalize__ReloadLocalizationFiles, localize.dll + 0xB830, +void, __fastcall, (void* pVguiLocalize)) +// clang-format on +{ + // load all mod localization manually, so we keep track of all files, not just previously loaded ones for (Mod mod : g_pModManager->m_LoadedMods) if (mod.m_bEnabled) for (std::string& localisationFile : mod.LocalisationFiles) - AddLocalisationFile(pVguiLocalize, localisationFile.c_str(), pathId, unknown); + CLocalize__AddFile(g_pVguiLocalize, localisationFile.c_str(), nullptr, false); + + spdlog::info("reloading localization..."); + CLocalize__ReloadLocalizationFiles(pVguiLocalize); +} - bLoadModLocalisationFiles = true; +// clang-format off +AUTOHOOK(CEngineVGui__Init, engine.dll + 0x247E10, +void, __fastcall, (void* self)) +// clang-format on +{ + CEngineVGui__Init(self); // this loads r1_english, valve_english, dev_english - return ret; + // previously we did this in CLocalize::AddFile, but for some reason it won't properly overwrite localization from + // files loaded previously if done there, very weird but this works so whatever + for (Mod mod : g_pModManager->m_LoadedMods) + if (mod.m_bEnabled) + for (std::string& localisationFile : mod.LocalisationFiles) + CLocalize__AddFile(g_pVguiLocalize, localisationFile.c_str(), nullptr, false); } ON_DLL_LOAD_CLIENT("localize.dll", Localize, (CModule module)) |