t7x/src/client/component/branding.cpp

51 lines
1.2 KiB
C++
Raw Normal View History

2022-09-16 14:55:36 -04:00
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "version.hpp"
2022-09-16 14:55:36 -04:00
2022-09-17 08:51:34 -04:00
#include "scheduler.hpp"
2023-03-18 04:14:54 -04:00
#include <utils/hook.hpp>
2022-09-16 14:55:36 -04:00
namespace branding
{
namespace
{
void draw_branding()
{
constexpr auto x = 4;
2022-09-17 03:16:24 -04:00
constexpr auto y = 0;
2022-09-18 02:33:11 -04:00
constexpr auto scale = 0.45f;
2022-10-17 15:01:21 -04:00
float color[4] = {0.666f, 0.666f, 0.666f, 0.666f};
2022-09-16 14:55:36 -04:00
2022-12-03 13:56:24 -05:00
const auto* font = reinterpret_cast<uint32_t*(*)()>(0x141CAC8E0_g)();
2022-09-16 14:55:36 -04:00
if (!font) return;
2022-12-03 13:56:24 -05:00
game::R_AddCmdDrawText("BOIII: " VERSION, std::numeric_limits<int>::max(), font, static_cast<float>(x),
2022-09-16 14:55:36 -04:00
y + static_cast<float>(font[2]) * scale,
2022-10-17 15:01:21 -04:00
scale, scale, 0.0f, color, game::ITEM_TEXTSTYLE_NORMAL);
2022-09-16 14:55:36 -04:00
}
2023-03-18 04:14:54 -04:00
const char* get_ingame_console_prefix_stub()
{
return "BOIII> ";
}
2022-09-16 14:55:36 -04:00
}
2023-01-01 15:51:04 -05:00
struct component final : client_component
2022-09-16 14:55:36 -04:00
{
void post_unpack() override
{
2022-09-17 08:51:34 -04:00
scheduler::loop(draw_branding, scheduler::renderer);
2023-03-18 04:14:54 -04:00
// Change window title prefix
utils::hook::copy_string(0x14303F3D8_g, "BOIII");
// Change ingame console prefix
utils::hook::call(0x141339970_g, get_ingame_console_prefix_stub);
2022-09-16 14:55:36 -04:00
}
};
}
REGISTER_COMPONENT(branding::component)