diff --git a/src/client/component/branding.cpp b/src/client/component/branding.cpp index 56578dc3..355345a6 100644 --- a/src/client/component/branding.cpp +++ b/src/client/component/branding.cpp @@ -10,29 +10,29 @@ namespace branding { + void draw() + { + 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); + } + class component final : public component_interface { public: void post_unpack() override { localized_strings::override("MENU_SP_CAMPAIGN", "H2-Mod"); - - scheduler::loop([]() - { - 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::pipeline::renderer); } }; } diff --git a/src/client/component/branding.hpp b/src/client/component/branding.hpp new file mode 100644 index 00000000..d3ef860d --- /dev/null +++ b/src/client/component/branding.hpp @@ -0,0 +1,6 @@ +#pragma once + +namespace branding +{ + void draw(); +} \ No newline at end of file diff --git a/src/client/component/fps.cpp b/src/client/component/fps.cpp index 5a8c69bb..122ebab5 100644 --- a/src/client/component/fps.cpp +++ b/src/client/component/fps.cpp @@ -240,21 +240,21 @@ namespace fps game::R_AddCmdDrawText(pos_string, 0x7FFFFFFF, font, x, 60.f, 1.0f, 1.0f, 0.0f, fps_color_ok, 0); } + } - void draw() + void draw() + { + check_resize(); + draw_fps(); + + if (!game::CL_IsCgameInitialized() || !game::g_entities[0].client) { - check_resize(); - draw_fps(); - - if (!game::CL_IsCgameInitialized() || !game::g_entities[0].client) - { - return; - } - - draw_pos(); - draw_speed(); - draw_speed_graph(); + return; } + + draw_pos(); + draw_speed(); + draw_speed_graph(); } class component final : public component_interface @@ -276,8 +276,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/fps.hpp b/src/client/component/fps.hpp new file mode 100644 index 00000000..6edceb69 --- /dev/null +++ b/src/client/component/fps.hpp @@ -0,0 +1,6 @@ +#pragma once + +namespace fps +{ + void draw(); +} \ No newline at end of file diff --git a/src/client/component/game_console.cpp b/src/client/component/game_console.cpp index 541d31b4..0bdcb3b3 100644 --- a/src/client/component/game_console.cpp +++ b/src/client/component/game_console.cpp @@ -391,25 +391,25 @@ namespace game_console draw_output_scrollbar(x, y, width, height); draw_output_text(x, y); } + } - void draw_console() + void draw_console() + { + check_resize(); + + if (*game::keyCatchers & 1) { - check_resize(); - - if (*game::keyCatchers & 1) + if (!(*game::keyCatchers & 1)) { - if (!(*game::keyCatchers & 1)) - { - con.output_visible = false; - } - - if (con.output_visible) - { - draw_output_window(); - } - - draw_input(); + con.output_visible = false; } + + if (con.output_visible) + { + draw_output_window(); + } + + draw_input(); } } @@ -683,8 +683,6 @@ namespace game_console public: void post_unpack() override { - scheduler::loop(draw_console, scheduler::pipeline::renderer); - con.cursor = 0; con.visible_line_count = 0; con.output_visible = false; diff --git a/src/client/component/game_console.hpp b/src/client/component/game_console.hpp index 7c4fc21a..4a9bec7c 100644 --- a/src/client/component/game_console.hpp +++ b/src/client/component/game_console.hpp @@ -9,6 +9,8 @@ namespace game_console con_type_info = 7 }; + void draw_console(); + void print(int type, const char* fmt, ...); bool console_char_event(int local_client_num, int key); diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index 362b5501..ea0e524b 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -7,6 +7,11 @@ #include "chat.hpp" #include "scheduler.hpp" #include "command.hpp" + +#include "game_console.hpp" +#include "fps.hpp" +#include "branding.hpp" + #include "ui_scripting.hpp" #include "game/ui_scripting/lua/engine.hpp" @@ -29,6 +34,9 @@ namespace ui_scripting scheduler::loop([]() { ui_scripting::lua::engine::run_frame(); + fps::draw(); + branding::draw(); + game_console::draw_console(); }, scheduler::pipeline::renderer); command::add("reloadmenus", []()