Small fix

This commit is contained in:
Federico Cecchetto 2021-04-26 16:43:34 +02:00
parent 2717e5061b
commit 8bd294ae03
2 changed files with 31 additions and 42 deletions

View File

@ -49,10 +49,12 @@ namespace fps
return total / history_count; return total / history_count;
} }
void draw_fps() void draw()
{ {
check_resize(); check_resize();
if (cg_drawfps->current.integer >= 1)
{
const auto now = std::chrono::high_resolution_clock::now(); const auto now = std::chrono::high_resolution_clock::now();
const auto frametime = now - lastframe; const auto frametime = now - lastframe;
lastframe = now; lastframe = now;
@ -73,34 +75,21 @@ namespace fps
fps >= 60 ? fps_color_good : (fps >= 30 ? fps_color_ok : fps_color_bad), 0); fps >= 60 ? fps_color_good : (fps >= 30 ? fps_color_ok : fps_color_bad), 0);
} }
void draw_pos() if (game::CL_IsCgameInitialized() && cg_drawfps->current.integer >= 2)
{
if (game::CL_IsCgameInitialized() && game::g_entities[0].origin)
{ {
const auto font = fps_font;
const auto pos_string = utils::string::va("%f %f %f", const auto pos_string = utils::string::va("%f %f %f",
game::g_entities[0].origin[0], game::g_entities[0].origin[0],
game::g_entities[0].origin[1], game::g_entities[0].origin[1],
game::g_entities[0].origin[2]); game::g_entities[0].origin[2]);
const auto x = screen_max[0] - 15.f - game::R_TextWidth(pos_string, 0x7FFFFFFF, fps_font); const auto x = screen_max[0] - 15.f - game::R_TextWidth(pos_string, 0x7FFFFFFF, font);
game::R_AddCmdDrawText(pos_string, 0x7FFFFFFF, fps_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()
{
if (cg_drawfps->current.integer >= 1)
{
draw_fps();
}
if (cg_drawfps->current.integer >= 2)
{
draw_pos();
}
}
} }
class component final : public component_interface class component final : public component_interface

View File

@ -186,11 +186,6 @@ namespace game_console
{ {
input = utils::string::to_lower(input); input = utils::string::to_lower(input);
if (game::Dvar_FindVar(input.data()))
{
suggestions.push_back(input.data());
}
for (const auto& dvar : dvars::dvar_list) for (const auto& dvar : dvars::dvar_list)
{ {
auto name = utils::string::to_lower(dvar); auto name = utils::string::to_lower(dvar);
@ -205,6 +200,11 @@ namespace game_console
} }
} }
if (suggestions.size() == 0 && game::Dvar_FindVar(input.data()))
{
suggestions.push_back(input.data());
}
game::cmd_function_s* cmd = (*game::cmd_functions); game::cmd_function_s* cmd = (*game::cmd_functions);
while (cmd) while (cmd)
{ {