2015-12-25 17:17:29 -05:00
|
|
|
#include "..\STDInclude.hpp"
|
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
2015-12-25 20:51:58 -05:00
|
|
|
Dvar::Var Localization::UseLocalization;
|
2015-12-25 17:17:29 -05:00
|
|
|
std::map<std::string, std::string> Localization::LocalizeMap;
|
|
|
|
|
|
|
|
void Localization::Set(const char* key, const char* value)
|
|
|
|
{
|
|
|
|
Localization::LocalizeMap[key] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* Localization::Get(const char* key)
|
|
|
|
{
|
2015-12-25 20:51:58 -05:00
|
|
|
if (!Localization::UseLocalization.Get<bool>()) return key;
|
|
|
|
|
2015-12-25 17:17:29 -05:00
|
|
|
if (Localization::LocalizeMap.find(key) != Localization::LocalizeMap.end())
|
|
|
|
{
|
|
|
|
return Localization::LocalizeMap[key].data();
|
|
|
|
}
|
|
|
|
|
|
|
|
Game::localizedEntry_s* entry = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_LOCALIZE, key).localize;
|
|
|
|
|
|
|
|
if (entry)
|
|
|
|
{
|
|
|
|
return entry->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
Localization::Localization()
|
|
|
|
{
|
|
|
|
Utils::Hook(0x629B90, Localization::Get, HOOK_JUMP).Install()->Quick();
|
|
|
|
|
2015-12-25 20:51:58 -05:00
|
|
|
//Localization::Set("MENU_MULTIPLAYER_CAPS", "^5Fotze");
|
|
|
|
Localization::UseLocalization = Dvar::Var::Register<bool>("ui_localize", true, Game::dvar_flag::DVAR_FLAG_NONE, "Use localization strings");
|
2015-12-25 17:17:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Localization::~Localization()
|
|
|
|
{
|
|
|
|
Localization::LocalizeMap.clear();
|
|
|
|
}
|
|
|
|
}
|