From fb90cc22dc3e7c6242985b3e29c7520e2c53afe1 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Wed, 15 Sep 2021 03:34:26 +0200 Subject: [PATCH] Make console, ... stay on top of ui elements --- src/client/component/branding.cpp | 31 +++++++++++++++------------ src/client/component/fps.cpp | 6 +++++- src/client/component/game_console.cpp | 6 +++++- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/client/component/branding.cpp b/src/client/component/branding.cpp index 56578dc3..3caa515c 100644 --- a/src/client/component/branding.cpp +++ b/src/client/component/branding.cpp @@ -10,6 +10,18 @@ namespace branding { + namespace + { + void draw_brand() + { + const auto font = game::R_RegisterFont("fonts/defaultBold.otf", 22); + float color[4] = {0.9f, 0.9f, 0.5f, 1.f}; + + game::R_AddCmdDrawText("h2-mod", 0x7FFFFFFF, font, 15.f, 15.f + static_cast(font->pixelHeight), + 1.f, 1.f, 0.0f, color, 0); + } + } + class component final : public component_interface { public: @@ -17,21 +29,12 @@ namespace branding { localized_strings::override("MENU_SP_CAMPAIGN", "H2-Mod"); - scheduler::loop([]() + scheduler::once([]() { - const auto x = 15.f; - const auto y = 15.f; - const auto scale = 1.0f; - float color[4] = {0.9f, 0.9f, 0.5f, 1.f}; - const auto* text = "h2-mod"; - - auto* font = game::R_RegisterFont("fonts/defaultBold.otf", 22); - - if (!font) return; - - game::R_AddCmdDrawText(text, 0x7FFFFFFF, font, static_cast(x), - y + static_cast(font->pixelHeight) * scale, - scale, scale, 0.0f, color, 0); + scheduler::loop([]() + { + draw_brand(); + }, scheduler::pipeline::renderer); }, scheduler::pipeline::renderer); } }; diff --git a/src/client/component/fps.cpp b/src/client/component/fps.cpp index 5a8c69bb..56e78a2b 100644 --- a/src/client/component/fps.cpp +++ b/src/client/component/fps.cpp @@ -262,6 +262,11 @@ namespace fps public: void post_unpack() override { + scheduler::once([]() + { + scheduler::loop(draw, scheduler::pipeline::renderer); + }, scheduler::pipeline::renderer); + cg_drawSpeed = dvars::register_int("cg_drawSpeed", 0, 0, 2, game::DVAR_FLAG_SAVED); cg_drawFps = dvars::register_int("cg_drawFPS", 0, 0, 4, game::DVAR_FLAG_SAVED, false); @@ -277,7 +282,6 @@ namespace fps cg_speedGraphWidth = dvars::register_int("cg_speedGraphWidth", 200, 0, 1000, game::DVAR_FLAG_SAVED); cg_speedGraphHeight = dvars::register_int("cg_speedGraphHeight", 80, 0, 1000, game::DVAR_FLAG_SAVED); - scheduler::loop(draw, scheduler::pipeline::renderer); } }; } diff --git a/src/client/component/game_console.cpp b/src/client/component/game_console.cpp index 541d31b4..eb267592 100644 --- a/src/client/component/game_console.cpp +++ b/src/client/component/game_console.cpp @@ -683,7 +683,11 @@ namespace game_console public: void post_unpack() override { - scheduler::loop(draw_console, scheduler::pipeline::renderer); + scheduler::once([]() + { + scheduler::loop(draw_console, scheduler::pipeline::renderer); + }, scheduler::pipeline::renderer); + con.cursor = 0; con.visible_line_count = 0;