Branding changes

This commit is contained in:
fed 2023-02-25 01:57:36 +01:00
parent 71eaa5f8a4
commit 70d3263e44
5 changed files with 43 additions and 15 deletions

View File

@ -1,11 +1,12 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "game/dvars.hpp"
#include "localized_strings.hpp"
#include "scheduler.hpp"
#include "command.hpp"
#include "game/game.hpp"
#include "game/ui_scripting/execution.hpp"
#include <utils/hook.hpp>
#include <utils/string.hpp>
@ -17,18 +18,35 @@ namespace branding
{
float color[4] = {0.9f, 0.9f, 0.5f, 1.f};
int get_build_number_stub(game::hks::lua_State* s)
utils::hook::detour ui_get_formatted_build_number_hook;
const char* ui_get_formatted_build_number_stub()
{
ui_scripting::push_value(VERSION);
return 1;
const auto* const build_num = ui_get_formatted_build_number_hook.invoke<const char*>();
return utils::string::va("%s (%s)", VERSION, build_num);
}
void draw()
{
const auto font = game::R_RegisterFont("fonts/defaultBold.otf", 22);
game::R_AddCmdDrawText("h2-mod", 0x7FFFFFFF, font, 15.f,
15.f + static_cast<float>(font->pixelHeight),
1.f, 1.f, 0.f, color, 0);
const auto font = game::R_RegisterFont("fonts/fira_mono_bold.ttf", 22);
if (!font)
{
return;
}
const auto placement = game::ScrPlace_GetViewPlacement();
game::rectDef_s rect{};
rect.x = 0;
rect.y = 0;
rect.w = 500;
rect.horzAlign = 1;
rect.vertAlign = 0;
game::rectDef_s text_rect{};
game::UI_DrawWrappedText(placement, "h2-mod", &rect, font,
5.f, 13.f, 0.20f, color, 0, 0, &text_rect, 0);
}
}
@ -41,7 +59,7 @@ namespace branding
localized_strings::override("MENU_SP_CAMPAIGN", "H2-MOD");
utils::hook::jump(0x14033D550, get_build_number_stub, true);
ui_get_formatted_build_number_hook.create(0x1406057D0, ui_get_formatted_build_number_stub);
}
};
}

View File

@ -265,11 +265,12 @@ namespace fps
average))
+ 9.313225746154785e-10);
const auto font = fps_font;
const auto fps_string = utils::string::va("%i", fps);
const auto x = screen_max[0] - 15.f - game::R_TextWidth(fps_string, 0x7FFFFFFF, fps_font);
const auto x = screen_max[0] - 10.f - game::R_TextWidth(fps_string, 0x7FFFFFFF, font);
const auto color = fps >= 60 ? fps_color_good : (fps >= 30 ? fps_color_ok : fps_color_bad);
game::R_AddCmdDrawText(fps_string, 0x7FFFFFFF, fps_font, x, 35.f, 1.0f, 1.0f, 0.0f,
fps >= 60 ? fps_color_good : (fps >= 30 ? fps_color_ok : fps_color_bad), 1);
game::R_AddCmdDrawText(fps_string, 0x7FFFFFFF, font, x, 30.f, 1.0f, 1.0f, 0.0f, color, 1);
}
void draw_pos()
@ -335,6 +336,11 @@ namespace fps
void draw()
{
if (*dvars::cg_draw_2d && !(*dvars::cg_draw_2d)->current.enabled)
{
return;
}
check_resize();
draw_fps();

View File

@ -28,6 +28,8 @@ namespace dvars
game::dvar_t* g_enableElevators = nullptr;
game::dvar_t** cg_draw_2d = reinterpret_cast<game::dvar_t**>(0x141E39EC0);
std::string dvar_get_vector_domain(const int components, const game::dvar_limits& domain)
{
if (domain.vector.min == -FLT_MAX)

View File

@ -36,6 +36,8 @@ namespace dvars
extern game::dvar_t* g_enableElevators;
extern game::dvar_t** cg_draw_2d;
extern std::vector<dvar_info> dvar_list;
std::string dvar_get_vector_domain(const int components, const game::dvar_limits& domain);

View File

@ -175,7 +175,7 @@ namespace game
WEAK symbol<ScreenPlacement*()> ScrPlace_GetViewPlacement{0x1403E16A0};
WEAK symbol<ScreenPlacement*()> ScrPlace_GetView{0x1403E1660};
WEAK symbol<void(ScreenPlacement* scrPlace, float* x, float* y, float* w, float* h,
WEAK symbol<void(const ScreenPlacement* scrPlace, float* x, float* y, float* w, float* h,
int horzAlign, int vertAlign)> ScrPlace_ApplyRect{0x1403E0BF0};
WEAK symbol<const char*(scr_string_t stringValue)> SL_ConvertToString{0x1405BFBB0};