Localization stuff.
This commit is contained in:
parent
e2c48fa9c5
commit
81c049e192
@ -22,6 +22,7 @@ namespace Components
|
|||||||
Loader::Register(new FileSystem());
|
Loader::Register(new FileSystem());
|
||||||
Loader::Register(new QuickPatch());
|
Loader::Register(new QuickPatch());
|
||||||
Loader::Register(new AssetHandler());
|
Loader::Register(new AssetHandler());
|
||||||
|
Loader::Register(new Localization());
|
||||||
Loader::Register(new MusicalTalent());
|
Loader::Register(new MusicalTalent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,4 +36,5 @@ namespace Components
|
|||||||
#include "FileSystem.hpp"
|
#include "FileSystem.hpp"
|
||||||
#include "QuickPatch.hpp"
|
#include "QuickPatch.hpp"
|
||||||
#include "AssetHandler.hpp"
|
#include "AssetHandler.hpp"
|
||||||
|
#include "Localization.hpp"
|
||||||
#include "MusicalTalent.hpp"
|
#include "MusicalTalent.hpp"
|
||||||
|
40
iw4/Components/Localization.cpp
Normal file
40
iw4/Components/Localization.cpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#include "..\STDInclude.hpp"
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
|
||||||
|
Localization::Set("MENU_MULTIPLAYER_CAPS", "^5Fotze");
|
||||||
|
}
|
||||||
|
|
||||||
|
Localization::~Localization()
|
||||||
|
{
|
||||||
|
Localization::LocalizeMap.clear();
|
||||||
|
}
|
||||||
|
}
|
16
iw4/Components/Localization.hpp
Normal file
16
iw4/Components/Localization.hpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
class Localization : public Component
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Localization();
|
||||||
|
~Localization();
|
||||||
|
const char* GetName() { return "Localization"; };
|
||||||
|
|
||||||
|
static void Set(const char* key, const char* value);
|
||||||
|
static const char* Get(const char* key);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::map<std::string, std::string> LocalizeMap;
|
||||||
|
};
|
||||||
|
}
|
@ -852,6 +852,12 @@ namespace Game
|
|||||||
UILocalVarContext localVars;
|
UILocalVarContext localVars;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct localizedEntry_s
|
||||||
|
{
|
||||||
|
const char* value;
|
||||||
|
const char* name;
|
||||||
|
};
|
||||||
|
|
||||||
union XAssetHeader
|
union XAssetHeader
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
@ -859,5 +865,6 @@ namespace Game
|
|||||||
menuDef_t *menu;
|
menuDef_t *menu;
|
||||||
Material *material;
|
Material *material;
|
||||||
snd_alias_list_t *aliasList;
|
snd_alias_list_t *aliasList;
|
||||||
|
localizedEntry_s *localize;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
<ClInclude Include="Components\FastFiles.hpp" />
|
<ClInclude Include="Components\FastFiles.hpp" />
|
||||||
<ClInclude Include="Components\FileSystem.hpp" />
|
<ClInclude Include="Components\FileSystem.hpp" />
|
||||||
<ClInclude Include="Components\Loader.hpp" />
|
<ClInclude Include="Components\Loader.hpp" />
|
||||||
|
<ClInclude Include="Components\Localization.hpp" />
|
||||||
<ClInclude Include="Components\Logger.hpp" />
|
<ClInclude Include="Components\Logger.hpp" />
|
||||||
<ClInclude Include="Components\Materials.hpp" />
|
<ClInclude Include="Components\Materials.hpp" />
|
||||||
<ClInclude Include="Components\Menus.hpp" />
|
<ClInclude Include="Components\Menus.hpp" />
|
||||||
@ -93,6 +94,7 @@
|
|||||||
<ClCompile Include="Components\FastFiles.cpp" />
|
<ClCompile Include="Components\FastFiles.cpp" />
|
||||||
<ClCompile Include="Components\FileSystem.cpp" />
|
<ClCompile Include="Components\FileSystem.cpp" />
|
||||||
<ClCompile Include="Components\Loader.cpp" />
|
<ClCompile Include="Components\Loader.cpp" />
|
||||||
|
<ClCompile Include="Components\Localization.cpp" />
|
||||||
<ClCompile Include="Components\Logger.cpp" />
|
<ClCompile Include="Components\Logger.cpp" />
|
||||||
<ClCompile Include="Components\Materials.cpp" />
|
<ClCompile Include="Components\Materials.cpp" />
|
||||||
<ClCompile Include="Components\Menus.cpp" />
|
<ClCompile Include="Components\Menus.cpp" />
|
||||||
|
@ -122,6 +122,9 @@
|
|||||||
<ClCompile Include="Components\Party.cpp">
|
<ClCompile Include="Components\Party.cpp">
|
||||||
<Filter>Source\Components\Modules</Filter>
|
<Filter>Source\Components\Modules</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Components\Localization.cpp">
|
||||||
|
<Filter>Source\Components\Modules</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Steam\Interfaces\SteamUser.hpp">
|
<ClInclude Include="Steam\Interfaces\SteamUser.hpp">
|
||||||
@ -220,5 +223,8 @@
|
|||||||
<ClInclude Include="Components\Party.hpp">
|
<ClInclude Include="Components\Party.hpp">
|
||||||
<Filter>Source\Components\Modules</Filter>
|
<Filter>Source\Components\Modules</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Components\Localization.hpp">
|
||||||
|
<Filter>Source\Components\Modules</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user