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,29 +10,29 @@
namespace branding 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<float>(x),
y + static_cast<float>(font->pixelHeight) * scale,
scale, scale, 0.0f, color, 0);
}
class component final : public component_interface class component final : public component_interface
{ {
public: public:
void post_unpack() override void post_unpack() override
{ {
localized_strings::override("MENU_SP_CAMPAIGN", "H2-Mod"); 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<float>(x),
y + static_cast<float>(font->pixelHeight) * scale,
scale, scale, 0.0f, color, 0);
}, scheduler::pipeline::renderer);
} }
}; };
} }

View File

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

View File

@ -240,21 +240,21 @@ 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()
{
check_resize();
draw_fps();
if (!game::CL_IsCgameInitialized() || !game::g_entities[0].client)
{ {
check_resize(); return;
draw_fps();
if (!game::CL_IsCgameInitialized() || !game::g_entities[0].client)
{
return;
}
draw_pos();
draw_speed();
draw_speed_graph();
} }
draw_pos();
draw_speed();
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,25 +391,25 @@ 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()
{
check_resize();
if (*game::keyCatchers & 1)
{ {
check_resize(); if (!(*game::keyCatchers & 1))
if (*game::keyCatchers & 1)
{ {
if (!(*game::keyCatchers & 1)) con.output_visible = false;
{
con.output_visible = false;
}
if (con.output_visible)
{
draw_output_window();
}
draw_input();
} }
if (con.output_visible)
{
draw_output_window();
}
draw_input();
} }
} }
@ -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", []()