2022-02-03 11:05:24 -08:00
|
|
|
#include <std_include.hpp>
|
|
|
|
#include "loader/component_loader.hpp"
|
2022-02-23 21:23:00 +01:00
|
|
|
|
2022-11-01 00:09:02 -05:00
|
|
|
#include "command.hpp"
|
|
|
|
#include "dvars.hpp"
|
2022-02-03 11:05:24 -08:00
|
|
|
#include "localized_strings.hpp"
|
|
|
|
#include "scheduler.hpp"
|
2022-02-23 21:23:00 +01:00
|
|
|
#include "version.hpp"
|
|
|
|
|
2022-02-03 11:05:24 -08:00
|
|
|
#include "game/game.hpp"
|
|
|
|
|
|
|
|
#include <utils/hook.hpp>
|
|
|
|
#include <utils/string.hpp>
|
2022-02-04 13:21:35 +02:00
|
|
|
|
2022-02-23 21:23:00 +01:00
|
|
|
// fonts/default.otf, fonts/defaultBold.otf, fonts/fira_mono_regular.ttf, fonts/fira_mono_bold.ttf
|
2022-02-03 11:05:24 -08:00
|
|
|
|
|
|
|
namespace branding
|
|
|
|
{
|
2022-02-04 13:21:35 +02:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
utils::hook::detour ui_get_formatted_build_number_hook;
|
|
|
|
|
2022-12-22 08:39:14 -06:00
|
|
|
float color[4] = {0.39f, 0.9f, 0.4f, 0.9f};
|
2022-02-26 23:03:29 +01:00
|
|
|
|
2022-02-04 13:21:35 +02: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-05-20 20:57:27 +02:00
|
|
|
|
|
|
|
void draw_branding()
|
|
|
|
{
|
2022-12-22 08:39:14 -06:00
|
|
|
const auto font = game::R_RegisterFont("fonts/fira_mono_bold.ttf", 22);
|
2023-01-27 01:03:35 +01:00
|
|
|
if (!font)
|
2022-05-20 20:57:27 +02:00
|
|
|
{
|
2023-01-27 01:03:35 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-06-05 23:25:06 +03:00
|
|
|
#ifdef DEBUG
|
2023-01-27 01:03:35 +01:00
|
|
|
const auto text = "h1-mod: " VERSION " (" __DATE__ " " __TIME__ ")";
|
2022-06-05 23:25:06 +03:00
|
|
|
#else
|
2023-01-27 01:03:35 +01:00
|
|
|
const auto text = "h1-mod: " VERSION ";
|
2022-06-05 23:25:06 +03:00
|
|
|
#endif
|
2023-01-27 01:03:35 +01:00
|
|
|
|
|
|
|
const auto placement = game::ScrPlace_GetViewPlacement();
|
|
|
|
float text_color[4] = {0.6f, 0.6f, 0.6f, 0.6f};
|
|
|
|
|
|
|
|
game::rectDef_s rect{};
|
|
|
|
rect.x = 0;
|
|
|
|
rect.y = 0;
|
|
|
|
rect.w = 500;
|
|
|
|
rect.horzAlign = 0;
|
|
|
|
rect.vertAlign = 0;
|
|
|
|
|
|
|
|
game::rectDef_s text_rect{};
|
|
|
|
|
|
|
|
game::UI_DrawWrappedText(placement, text, &rect, font, -102.5f, 10.f, 0.17f, text_color, 0, 0, &text_rect, 0);
|
2022-05-20 20:57:27 +02:00
|
|
|
}
|
2022-02-04 13:21:35 +02:00
|
|
|
}
|
2022-02-03 11:05:24 -08:00
|
|
|
|
|
|
|
class component final : public component_interface
|
|
|
|
{
|
|
|
|
public:
|
2022-05-20 20:57:27 +02:00
|
|
|
void post_start() override
|
|
|
|
{
|
|
|
|
scheduler::loop(draw_branding, scheduler::pipeline::renderer);
|
|
|
|
}
|
|
|
|
|
2022-02-03 11:05:24 -08:00
|
|
|
void post_unpack() override
|
|
|
|
{
|
2022-02-04 05:21:16 +02:00
|
|
|
if (game::environment::is_dedi())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-04 13:21:35 +02:00
|
|
|
ui_get_formatted_build_number_hook.create(
|
2022-05-24 18:48:37 +03:00
|
|
|
SELECT_VALUE(0x406EC0_b, 0x1DF300_b), ui_get_formatted_build_number_stub);
|
2022-02-03 11:05:24 -08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-05-17 18:08:53 +03:00
|
|
|
REGISTER_COMPONENT(branding::component)
|