1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#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->GetMods() | ModManager::FilterEnabled)
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->GetMods() | ModManager::FilterEnabled)
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()
}
|