diff options
author | Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> | 2023-12-27 00:32:01 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-27 01:32:01 +0100 |
commit | f5ab6fb5e8be7b73e6003d4145081d5e0c0ce287 (patch) | |
tree | 90f2c6a4885dbd181799e2325cf33588697674e1 /primedev/client/modlocalisation.cpp | |
parent | bb8ed59f6891b1196c5f5bbe7346cd171c8215fa (diff) | |
download | NorthstarLauncher-f5ab6fb5e8be7b73e6003d4145081d5e0c0ce287.tar.gz NorthstarLauncher-f5ab6fb5e8be7b73e6003d4145081d5e0c0ce287.zip |
Folder restructuring from primedev (#624)v1.21.2-rc3v1.21.2
Copies of over the primedev folder structure for easier cherry-picking of further changes
Co-authored-by: F1F7Y <filip.bartos07@proton.me>
Diffstat (limited to 'primedev/client/modlocalisation.cpp')
-rw-r--r-- | primedev/client/modlocalisation.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/primedev/client/modlocalisation.cpp b/primedev/client/modlocalisation.cpp new file mode 100644 index 00000000..2b73876b --- /dev/null +++ b/primedev/client/modlocalisation.cpp @@ -0,0 +1,55 @@ +#include "mods/modmanager.h" + +AUTOHOOK_INIT() + +void* g_pVguiLocalize; + +// clang-format off +AUTOHOOK(CLocalize__AddFile, localize.dll + 0x6D80, +bool, __fastcall, (void* pVguiLocalize, const char* path, const char* pathId, bool bIncludeFallbackSearchPaths)) +// clang-format on +{ + // save this for later + g_pVguiLocalize = pVguiLocalize; + + bool ret = CLocalize__AddFile(pVguiLocalize, path, pathId, bIncludeFallbackSearchPaths); + if (ret) + spdlog::info("Loaded localisation file {} successfully", path); + + 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) + CLocalize__AddFile(g_pVguiLocalize, localisationFile.c_str(), nullptr, false); + + spdlog::info("reloading localization..."); + CLocalize__ReloadLocalizationFiles(pVguiLocalize); +} + +// 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 + + // 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)) +{ + AUTOHOOK_DISPATCH() +} |