2022-02-03 14:05:24 -05:00
|
|
|
#include <std_include.hpp>
|
|
|
|
#include "loader/component_loader.hpp"
|
2022-02-23 15:23:00 -05:00
|
|
|
|
2022-02-03 14:05:24 -05:00
|
|
|
#include "localized_strings.hpp"
|
|
|
|
#include "scheduler.hpp"
|
|
|
|
#include "command.hpp"
|
2022-02-23 15:23:00 -05:00
|
|
|
#include "version.hpp"
|
|
|
|
|
2022-02-03 14:05:24 -05:00
|
|
|
#include "game/game.hpp"
|
2022-02-28 14:31:25 -05:00
|
|
|
#include "dvars.hpp"
|
2022-02-03 14:05:24 -05:00
|
|
|
|
|
|
|
#include <utils/hook.hpp>
|
|
|
|
#include <utils/string.hpp>
|
2022-02-04 06:21:35 -05:00
|
|
|
|
2022-02-23 15:23:00 -05:00
|
|
|
// fonts/default.otf, fonts/defaultBold.otf, fonts/fira_mono_regular.ttf, fonts/fira_mono_bold.ttf
|
2022-02-03 14:05:24 -05:00
|
|
|
|
|
|
|
namespace branding
|
|
|
|
{
|
2022-02-04 06:21:35 -05:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
utils::hook::detour ui_get_formatted_build_number_hook;
|
|
|
|
|
2022-02-26 17:03:29 -05:00
|
|
|
float color[4] = {0.666f, 0.666f, 0.666f, 0.666f};
|
|
|
|
|
2022-02-04 06:21:35 -05:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2022-02-03 14:05:24 -05:00
|
|
|
|
|
|
|
class component final : public component_interface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void post_unpack() override
|
|
|
|
{
|
2022-02-03 22:21:16 -05:00
|
|
|
|
|
|
|
if (game::environment::is_dedi())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-04 02:07:31 -05:00
|
|
|
if (game::environment::is_mp())
|
2022-02-03 22:21:16 -05:00
|
|
|
{
|
2022-02-26 17:03:29 -05:00
|
|
|
localized_strings::override("LUA_MENU_MULTIPLAYER_CAPS", "H1-MOD: MULTIPLAYER\n");
|
|
|
|
localized_strings::override("MENU_MULTIPLAYER_CAPS", "H1-MOD: MULTIPLAYER");
|
2022-02-03 22:21:16 -05:00
|
|
|
}
|
2022-02-03 14:05:24 -05:00
|
|
|
|
2022-02-28 14:31:25 -05:00
|
|
|
dvars::override::set_string("version", utils::string::va("H1-Mod %s", VERSION));
|
2022-02-04 06:21:35 -05:00
|
|
|
|
|
|
|
ui_get_formatted_build_number_hook.create(
|
|
|
|
SELECT_VALUE(0x1403B1C40, 0x1404E74C0), ui_get_formatted_build_number_stub);
|
|
|
|
|
2022-02-03 14:05:24 -05:00
|
|
|
scheduler::loop([]()
|
2022-02-23 15:23:00 -05:00
|
|
|
{
|
2022-02-26 17:03:29 -05:00
|
|
|
const auto font = game::R_RegisterFont("fonts/fira_mono_bold.ttf", 20);
|
2022-02-03 14:05:24 -05:00
|
|
|
|
2022-02-26 17:03:29 -05:00
|
|
|
game::R_AddCmdDrawText("H1-Mod: " VERSION, 0x7FFFFFFF, font, 10.f,
|
|
|
|
5.f + static_cast<float>(font->pixelHeight), 1.f, 1.f, 0.0f, color, 0);
|
2022-02-23 15:23:00 -05:00
|
|
|
}, scheduler::pipeline::renderer);
|
2022-02-03 14:05:24 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
REGISTER_COMPONENT(branding::component)
|