aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2023-01-06 20:40:02 +0000
committerGitHub <noreply@github.com>2023-01-06 21:40:02 +0100
commitd4f90eafc91f83cca270e46164f435908dc94b9d (patch)
tree222426efd65c86eed441002458eb8aafb3bd634a /NorthstarDLL
parent3cfd6f96e3f459223294cbf80fa2108424aefe96 (diff)
downloadNorthstarLauncher-d4f90eafc91f83cca270e46164f435908dc94b9d.tar.gz
NorthstarLauncher-d4f90eafc91f83cca270e46164f435908dc94b9d.zip
Fix overriding individual localisation strings being weird (#394)v1.12.0-rc3v1.12.0-rc2
* change how we load localisation to fix overriding individual localisation strings * fix formatting * fix formatting again
Diffstat (limited to 'NorthstarDLL')
-rw-r--r--NorthstarDLL/client/modlocalisation.cpp43
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))