Branding & fps adjustments
This commit is contained in:
parent
58259baf15
commit
d2377fcf34
@ -20,10 +20,11 @@ namespace branding
|
|||||||
{
|
{
|
||||||
utils::hook::detour ui_get_formatted_build_number_hook;
|
utils::hook::detour ui_get_formatted_build_number_hook;
|
||||||
|
|
||||||
|
float color[4] = {0.666f, 0.666f, 0.666f, 0.666f};
|
||||||
|
|
||||||
const char* ui_get_formatted_build_number_stub()
|
const char* ui_get_formatted_build_number_stub()
|
||||||
{
|
{
|
||||||
const auto* const build_num = ui_get_formatted_build_number_hook.invoke<const char*>();
|
const auto* const build_num = ui_get_formatted_build_number_hook.invoke<const char*>();
|
||||||
|
|
||||||
return utils::string::va("%s (%s)", VERSION, build_num);
|
return utils::string::va("%s (%s)", VERSION, build_num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,8 +42,8 @@ namespace branding
|
|||||||
|
|
||||||
if (game::environment::is_mp())
|
if (game::environment::is_mp())
|
||||||
{
|
{
|
||||||
localized_strings::override("LUA_MENU_MULTIPLAYER_CAPS", "H1-Mod: MULTIPLAYER\n");
|
localized_strings::override("LUA_MENU_MULTIPLAYER_CAPS", "H1-MOD: MULTIPLAYER\n");
|
||||||
localized_strings::override("MENU_MULTIPLAYER_CAPS", "H1-Mod: MULTIPLAYER");
|
localized_strings::override("MENU_MULTIPLAYER_CAPS", "H1-MOD: MULTIPLAYER");
|
||||||
}
|
}
|
||||||
|
|
||||||
dvars::override::Dvar_SetString("version", utils::string::va("H1-Mod %s", VERSION));
|
dvars::override::Dvar_SetString("version", utils::string::va("H1-Mod %s", VERSION));
|
||||||
@ -52,22 +53,10 @@ namespace branding
|
|||||||
|
|
||||||
scheduler::loop([]()
|
scheduler::loop([]()
|
||||||
{
|
{
|
||||||
|
const auto font = game::R_RegisterFont("fonts/fira_mono_bold.ttf", 20);
|
||||||
|
|
||||||
const auto x = 4;
|
game::R_AddCmdDrawText("H1-Mod: " VERSION, 0x7FFFFFFF, font, 10.f,
|
||||||
const auto y = 4;
|
5.f + static_cast<float>(font->pixelHeight), 1.f, 1.f, 0.0f, color, 0);
|
||||||
const auto scale = 1.0f;
|
|
||||||
float color[4] = {0.666f, 0.666f, 0.666f, 0.666f};
|
|
||||||
|
|
||||||
const auto* text = "H1-Mod: " VERSION;
|
|
||||||
|
|
||||||
auto* font = game::R_RegisterFont("fonts/fira_mono_bold.ttf", 20);
|
|
||||||
|
|
||||||
if (!font) return;
|
|
||||||
|
|
||||||
game::R_AddCmdDrawText(text, 0x7FFFFFFF, font, static_cast<float>(x),
|
|
||||||
y + static_cast<float>(font->pixelHeight) * scale,
|
|
||||||
scale, scale, 0.0f, color, 0);
|
|
||||||
|
|
||||||
}, scheduler::pipeline::renderer);
|
}, scheduler::pipeline::renderer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -12,11 +12,12 @@ namespace fps
|
|||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
game::dvar_t* cg_drawfps;
|
||||||
|
game::dvar_t* cg_drawping;
|
||||||
|
|
||||||
float fps_color_good[4] = {0.6f, 1.0f, 0.0f, 1.0f};
|
float fps_color_good[4] = {0.6f, 1.0f, 0.0f, 1.0f};
|
||||||
float fps_color_ok[4] = {1.0f, 0.7f, 0.3f, 1.0f};
|
float fps_color_ok[4] = {1.0f, 0.7f, 0.3f, 1.0f};
|
||||||
float fps_color_bad[4] = {1.0f, 0.3f, 0.3f, 1.0f};
|
float fps_color_bad[4] = {1.0f, 0.3f, 0.3f, 1.0f};
|
||||||
|
|
||||||
//float origin_color[4] = {1.0f, 0.67f, 0.13f, 1.0f};
|
|
||||||
float ping_color[4] = {1.0f, 1.0f, 1.0f, 0.65f};
|
float ping_color[4] = {1.0f, 1.0f, 1.0f, 0.65f};
|
||||||
|
|
||||||
struct cg_perf_data
|
struct cg_perf_data
|
||||||
@ -90,57 +91,46 @@ namespace fps
|
|||||||
|
|
||||||
void cg_draw_fps()
|
void cg_draw_fps()
|
||||||
{
|
{
|
||||||
const auto* draw_fps = game::Dvar_FindVar("cg_drawFPS");
|
if (cg_drawfps->current.integer > 0)
|
||||||
if (draw_fps && draw_fps->current.integer > 0 /*&& game::CL_IsCgameInitialized()*/)
|
|
||||||
{
|
{
|
||||||
const auto fps = static_cast<std::int32_t>(static_cast<float>(1000.0f / static_cast<float>(cg_perf.
|
const auto fps = static_cast<std::int32_t>(static_cast<float>(1000.0f / static_cast<float>(cg_perf.
|
||||||
average))
|
average))
|
||||||
+ 9.313225746154785e-10);
|
+ 9.313225746154785e-10);
|
||||||
|
|
||||||
auto* font = game::R_RegisterFont("fonts/fira_mono_regular.ttf", 19);
|
const auto font = game::R_RegisterFont("fonts/fira_mono_regular.ttf", 25);
|
||||||
if (!font) return;
|
const auto fps_string = utils::string::va("%i", fps);
|
||||||
|
|
||||||
const auto* const fps_string = utils::string::va("%i", fps);
|
const auto x = (game::ScrPlace_GetViewPlacement()->realViewportSize[0] - 15.0f) - game::R_TextWidth(
|
||||||
|
fps_string, 0x7FFFFFFF, font);
|
||||||
const auto scale = 1.0f;
|
const auto y = font->pixelHeight + 10.f;
|
||||||
|
|
||||||
const auto x = (game::ScrPlace_GetViewPlacement()->realViewportSize[0] - 10.0f) - game::R_TextWidth(
|
|
||||||
fps_string, 0x7FFFFFFF, font) * scale;
|
|
||||||
|
|
||||||
const auto y = font->pixelHeight * 1.2f;
|
|
||||||
|
|
||||||
const auto fps_color = fps >= 60 ? fps_color_good : (fps >= 30 ? fps_color_ok : fps_color_bad);
|
const auto fps_color = fps >= 60 ? fps_color_good : (fps >= 30 ? fps_color_ok : fps_color_bad);
|
||||||
game::R_AddCmdDrawText(fps_string, 0x7FFFFFFF, font, x, y, scale, scale, 0.0f, fps_color, 6);
|
game::R_AddCmdDrawText(fps_string, 0x7FFFFFFF, font, x, y, 1.f, 1.f, 0.0f, fps_color, 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cg_draw_ping()
|
void cg_draw_ping()
|
||||||
{
|
{
|
||||||
const auto* draw_ping = game::Dvar_FindVar("cg_drawPing");
|
if (cg_drawping->current.integer > 0 && game::CL_IsCgameInitialized())
|
||||||
if (draw_ping && draw_ping->current.integer > 0 && game::CL_IsCgameInitialized())
|
|
||||||
{
|
{
|
||||||
const auto ping = *reinterpret_cast<int*>(0x142D106F0); // H1MP(1.4)
|
const auto ping = *reinterpret_cast<int*>(0x142D106F0);
|
||||||
|
|
||||||
auto* font = game::R_RegisterFont("fonts/consolefont", 20);
|
const auto font = game::R_RegisterFont("fonts/consolefont", 20);
|
||||||
if (!font) return;
|
const auto ping_string = utils::string::va("Ping: %i", ping);
|
||||||
|
|
||||||
auto* const ping_string = utils::string::va("Ping: %i", ping);
|
|
||||||
|
|
||||||
const auto scale = 1.0f;
|
|
||||||
|
|
||||||
const auto x = (game::ScrPlace_GetViewPlacement()->realViewportSize[0] - 375.0f) - game::R_TextWidth(
|
const auto x = (game::ScrPlace_GetViewPlacement()->realViewportSize[0] - 375.0f) - game::R_TextWidth(
|
||||||
ping_string, 0x7FFFFFFF, font) * scale;
|
ping_string, 0x7FFFFFFF, font);
|
||||||
|
|
||||||
const auto y = font->pixelHeight * 1.2f;
|
const auto y = font->pixelHeight + 15.f;
|
||||||
|
game::R_AddCmdDrawText(ping_string, 0x7FFFFFFF, font, x, y, 1.f, 1.f, 0.0f, ping_color, 6);
|
||||||
game::R_AddCmdDrawText(ping_string, 0x7FFFFFFF, font, x, y, scale, scale, 0.0f, ping_color, 6);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cg_draw_fps_register_stub(const char* name, const char** _enum, const int value, unsigned int /*flags*/,
|
game::dvar_t* cg_draw_fps_register_stub(const char* name, const char** _enum, const int value, unsigned int /*flags*/,
|
||||||
const char* desc)
|
const char* desc)
|
||||||
{
|
{
|
||||||
game::Dvar_RegisterEnum(name, _enum, value, game::DVAR_FLAG_SAVED);
|
cg_drawfps = dvars::register_int("cg_drawFps", 0, 0, 2, game::DVAR_FLAG_SAVED, false);
|
||||||
|
return cg_drawfps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,18 +146,24 @@ namespace fps
|
|||||||
|
|
||||||
// fps setup
|
// fps setup
|
||||||
cg_perf.perf_start = std::chrono::high_resolution_clock::now();
|
cg_perf.perf_start = std::chrono::high_resolution_clock::now();
|
||||||
utils::hook::call(SELECT_VALUE(0x14018D261, 0x14025B747), &perf_update); // H1(1.4)
|
utils::hook::call(SELECT_VALUE(0x14018D261, 0x14025B747), &perf_update);
|
||||||
|
|
||||||
// change cg_drawfps flags to saved
|
// change cg_drawfps flags to saved
|
||||||
utils::hook::call(SELECT_VALUE(0x140139F48, 0x1401A4B8E), &cg_draw_fps_register_stub); //h1sp
|
utils::hook::call(SELECT_VALUE(0x140139F48, 0x140222A46), &cg_draw_fps_register_stub);
|
||||||
|
|
||||||
scheduler::loop(cg_draw_fps, scheduler::pipeline::renderer);
|
scheduler::loop(cg_draw_fps, scheduler::pipeline::renderer);
|
||||||
|
|
||||||
|
if (game::environment::is_sp())
|
||||||
|
{
|
||||||
|
cg_drawfps = dvars::register_int("cg_drawFps", 0, 0, 2, game::DVAR_FLAG_SAVED, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (game::environment::is_mp())
|
if (game::environment::is_mp())
|
||||||
{
|
{
|
||||||
// fix ping value
|
// fix ping value
|
||||||
utils::hook::nop(0x14025AC41, 2); // H1MP(1.4)
|
utils::hook::nop(0x14025AC41, 2);
|
||||||
|
|
||||||
dvars::register_int("cg_drawPing", 0, 0, 1, game::DVAR_FLAG_SAVED, true);
|
cg_drawping = dvars::register_int("cg_drawPing", 0, 0, 1, game::DVAR_FLAG_SAVED, true);
|
||||||
|
|
||||||
scheduler::loop(cg_draw_ping, scheduler::pipeline::renderer);
|
scheduler::loop(cg_draw_ping, scheduler::pipeline::renderer);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user