Draw fps, console, branding on top of ui elements

This commit is contained in:
Federico Cecchetto 2021-09-19 18:20:15 +02:00
parent d44a55dc11
commit 1501929977
7 changed files with 66 additions and 48 deletions

View File

@ -10,19 +10,12 @@
namespace branding namespace branding
{ {
class component final : public component_interface void draw()
{
public:
void post_unpack() override
{
localized_strings::override("MENU_SP_CAMPAIGN", "H2-Mod");
scheduler::loop([]()
{ {
const auto x = 15.f; const auto x = 15.f;
const auto y = 15.f; const auto y = 15.f;
const auto scale = 1.0f; const auto scale = 1.0f;
float color[4] = {0.9f, 0.9f, 0.5f, 1.f}; float color[4] = { 0.9f, 0.9f, 0.5f, 1.f };
const auto* text = "h2-mod"; const auto* text = "h2-mod";
auto* font = game::R_RegisterFont("fonts/defaultBold.otf", 22); auto* font = game::R_RegisterFont("fonts/defaultBold.otf", 22);
@ -32,7 +25,14 @@ namespace branding
game::R_AddCmdDrawText(text, 0x7FFFFFFF, font, static_cast<float>(x), game::R_AddCmdDrawText(text, 0x7FFFFFFF, font, static_cast<float>(x),
y + static_cast<float>(font->pixelHeight) * scale, y + static_cast<float>(font->pixelHeight) * scale,
scale, scale, 0.0f, color, 0); scale, scale, 0.0f, color, 0);
}, scheduler::pipeline::renderer); }
class component final : public component_interface
{
public:
void post_unpack() override
{
localized_strings::override("MENU_SP_CAMPAIGN", "H2-Mod");
} }
}; };
} }

View File

@ -0,0 +1,6 @@
#pragma once
namespace branding
{
void draw();
}

View File

@ -240,6 +240,7 @@ namespace fps
game::R_AddCmdDrawText(pos_string, 0x7FFFFFFF, font, x, game::R_AddCmdDrawText(pos_string, 0x7FFFFFFF, font, x,
60.f, 1.0f, 1.0f, 0.0f, fps_color_ok, 0); 60.f, 1.0f, 1.0f, 0.0f, fps_color_ok, 0);
} }
}
void draw() void draw()
{ {
@ -255,7 +256,6 @@ namespace fps
draw_speed(); draw_speed();
draw_speed_graph(); draw_speed_graph();
} }
}
class component final : public component_interface 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_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); cg_speedGraphHeight = dvars::register_int("cg_speedGraphHeight", 80, 0, 1000, game::DVAR_FLAG_SAVED);
scheduler::loop(draw, scheduler::pipeline::renderer);
} }
}; };
} }

View File

@ -0,0 +1,6 @@
#pragma once
namespace fps
{
void draw();
}

View File

@ -391,6 +391,7 @@ namespace game_console
draw_output_scrollbar(x, y, width, height); draw_output_scrollbar(x, y, width, height);
draw_output_text(x, y); draw_output_text(x, y);
} }
}
void draw_console() void draw_console()
{ {
@ -411,7 +412,6 @@ namespace game_console
draw_input(); draw_input();
} }
} }
}
void print(const int type, const char* fmt, ...) void print(const int type, const char* fmt, ...)
{ {
@ -683,8 +683,6 @@ namespace game_console
public: public:
void post_unpack() override void post_unpack() override
{ {
scheduler::loop(draw_console, scheduler::pipeline::renderer);
con.cursor = 0; con.cursor = 0;
con.visible_line_count = 0; con.visible_line_count = 0;
con.output_visible = false; con.output_visible = false;

View File

@ -9,6 +9,8 @@ namespace game_console
con_type_info = 7 con_type_info = 7
}; };
void draw_console();
void print(int type, const char* fmt, ...); void print(int type, const char* fmt, ...);
bool console_char_event(int local_client_num, int key); bool console_char_event(int local_client_num, int key);

View File

@ -7,6 +7,11 @@
#include "chat.hpp" #include "chat.hpp"
#include "scheduler.hpp" #include "scheduler.hpp"
#include "command.hpp" #include "command.hpp"
#include "game_console.hpp"
#include "fps.hpp"
#include "branding.hpp"
#include "ui_scripting.hpp" #include "ui_scripting.hpp"
#include "game/ui_scripting/lua/engine.hpp" #include "game/ui_scripting/lua/engine.hpp"
@ -29,6 +34,9 @@ namespace ui_scripting
scheduler::loop([]() scheduler::loop([]()
{ {
ui_scripting::lua::engine::run_frame(); ui_scripting::lua::engine::run_frame();
fps::draw();
branding::draw();
game_console::draw_console();
}, scheduler::pipeline::renderer); }, scheduler::pipeline::renderer);
command::add("reloadmenus", []() command::add("reloadmenus", []()