This commit is contained in:
Skull 2022-02-04 13:21:35 +02:00
parent 44a94ccd57
commit 78916f01e2
3 changed files with 30 additions and 13 deletions

View File

@ -7,10 +7,24 @@
#include <utils/hook.hpp>
#include <utils/string.hpp>
#include <game/dvars.hpp>
#include "version.hpp"
namespace branding
{
game::dvar_t* dvar_draw2d;
namespace
{
utils::hook::detour ui_get_formatted_build_number_hook;
const char* ui_get_formatted_build_number_stub()
{
const auto* const build_num = ui_get_formatted_build_number_hook.invoke<const char*>();
return utils::string::va("%s (%s)", VERSION, build_num);
}
}
class component final : public component_interface
{
@ -27,27 +41,22 @@ namespace branding
{
localized_strings::override("LUA_MENU_MULTIPLAYER_CAPS", "H1-Mod: MULTIPLAYER\n");
localized_strings::override("MENU_MULTIPLAYER_CAPS", "H1-Mod: MULTIPLAYER");
localized_strings::override("PLATFORM_UI_HEADER_PLAY_MP_CAPS", "H1-ONLINE");
}
dvars::override::Dvar_SetString("version", utils::string::va("H1-Mod %s", VERSION));
ui_get_formatted_build_number_hook.create(
SELECT_VALUE(0x1403B1C40, 0x1404E74C0), ui_get_formatted_build_number_stub);
scheduler::loop([]()
{
if (!dvar_draw2d)
{
dvar_draw2d = game::Dvar_FindVar("cg_draw2d");
}
if (dvar_draw2d && !dvar_draw2d->current.enabled)
{
return;
}
const auto x = 4;
const auto y = 4;
const auto scale = 1.0f;
float color[4] = { 1.0f, 0.5f, 0.0f, 1.0f };
float color[4] = { 0.666f, 0.666f, 0.666f, 0.666f };
const auto* text = "H1-Mod 1.4";
const auto* text = "H1-Mod: " VERSION;
auto* font = game::R_RegisterFont("fonts/fira_mono_bold.ttf", 20);

View File

@ -543,6 +543,8 @@ namespace dvars
}
namespace override {
static std::unordered_map<std::string, std::string> set_string_overrides;
game::dvar_t* register_int(const std::string& name, int value, int min, int max,
const unsigned int flags, bool add_to_list)
{
@ -555,5 +557,10 @@ namespace dvars
return game::Dvar_RegisterInt(hash, "", value, min, max, flags);
}
void Dvar_SetString(const std::string& name, const std::string& value)
{
set_string_overrides[name] = value;
}
}
}

View File

@ -34,5 +34,6 @@ namespace dvars
namespace override {
game::dvar_t* register_int(const std::string& name, int value, int min, int max, const unsigned int flags, bool add_to_list = true);
void Dvar_SetString(const std::string& name, const std::string& string);
}
}