[Localization] Generate class names for 10+ classes
This commit is contained in:
parent
712f0d9ef4
commit
ea3ac3ddcb
@ -260,6 +260,25 @@ namespace Components
|
|||||||
Utils::Hook(0x4CE5EE, Localization::SetStringStub, HOOK_CALL).install()->quick();
|
Utils::Hook(0x4CE5EE, Localization::SetStringStub, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
Localization::UseLocalization = Dvar::Register<bool>("ui_localize", true, Game::dvar_flag::DVAR_FLAG_NONE, "Use localization strings");
|
Localization::UseLocalization = Dvar::Register<bool>("ui_localize", true, Game::dvar_flag::DVAR_FLAG_NONE, "Use localization strings");
|
||||||
|
|
||||||
|
// Generate localized entries for custom classes above 10
|
||||||
|
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool* /*restrict*/)
|
||||||
|
{
|
||||||
|
if (type != Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY) return;
|
||||||
|
|
||||||
|
if(name == "CLASS_SLOT1"s)
|
||||||
|
{
|
||||||
|
for(int i = 11; i <= NUM_CUSTOM_CLASSES; ++i)
|
||||||
|
{
|
||||||
|
std::string key = Utils::String::VA("CLASS_SLOT%i", i);
|
||||||
|
|
||||||
|
std::string value = asset.localize->value;
|
||||||
|
Utils::String::Replace(value, "1", Utils::String::VA("%i", i)); // Pretty ugly, but it should work
|
||||||
|
|
||||||
|
Localization::Set(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Localization::~Localization()
|
Localization::~Localization()
|
||||||
|
@ -118,7 +118,8 @@ namespace Components
|
|||||||
|
|
||||||
StructuredData::StructuredData()
|
StructuredData::StructuredData()
|
||||||
{
|
{
|
||||||
Utils::Hook::Set<BYTE>(0x60A2FE, 15); // 15 custom classes
|
// 15 or more custom classes
|
||||||
|
Utils::Hook::Set<BYTE>(0x60A2FE, NUM_CUSTOM_CLASSES);
|
||||||
|
|
||||||
// Only execute this when building zones
|
// Only execute this when building zones
|
||||||
if (!ZoneBuilder::IsEnabled()) return;
|
if (!ZoneBuilder::IsEnabled()) return;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define PROTOCOL 0x93
|
#define PROTOCOL 0x93
|
||||||
|
#define NUM_CUSTOM_CLASSES 15
|
||||||
|
|
||||||
// This allows us to compile our structures in IDA, for easier reversing :3
|
// This allows us to compile our structures in IDA, for easier reversing :3
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Loading…
Reference in New Issue
Block a user