refactor(defaults): centralitza init hud, tips, hit timer, line thickness i debug overlay

This commit is contained in:
2026-05-21 09:45:55 +02:00
parent 08100f60e8
commit 7139dea7f6
8 changed files with 111 additions and 75 deletions
+15 -23
View File
@@ -4,21 +4,13 @@
#include <string>
#include "core/defaults.hpp"
#include "core/types.hpp"
namespace System {
namespace {
// Posición y tamaño del overlay en coordenadas lógicas (1280×720).
constexpr float OVERLAY_X = 12.0F;
constexpr float OVERLAY_Y_FPS = 12.0F;
constexpr float OVERLAY_LINE_HEIGHT = 18.0F; // separación entre líneas (scale 0.4 → ~16 px alto)
constexpr float OVERLAY_SCALE = 0.4F;
constexpr float OVERLAY_SPACING = 2.0F;
constexpr float OVERLAY_BRIGHTNESS = 1.0F;
// Cadencia de actualización del valor de FPS mostrado.
constexpr float FPS_UPDATE_INTERVAL = 0.5F;
namespace Cfg = Defaults::Hud::DebugOverlay;
} // namespace
DebugOverlay::DebugOverlay(Rendering::Renderer* renderer,
@@ -30,7 +22,7 @@ namespace System {
fps_accumulator_ += delta_time;
fps_frame_count_++;
if (fps_accumulator_ >= FPS_UPDATE_INTERVAL) {
if (fps_accumulator_ >= Cfg::FPS_UPDATE_INTERVAL) {
fps_display_ = static_cast<int>(fps_frame_count_ / fps_accumulator_);
fps_frame_count_ = 0;
fps_accumulator_ = 0.0F;
@@ -47,20 +39,20 @@ namespace System {
const std::string AA_TEXT = std::string("AA: ") + (rendering_cfg_->antialias == 1 ? "ON" : "OFF");
text_.render(FPS_TEXT,
Vec2{.x = OVERLAY_X, .y = OVERLAY_Y_FPS},
OVERLAY_SCALE,
OVERLAY_SPACING,
OVERLAY_BRIGHTNESS);
Vec2{.x = Cfg::X, .y = Cfg::Y_FPS},
Cfg::TEXT_SCALE,
Cfg::TEXT_SPACING,
Cfg::BRIGHTNESS);
text_.render(VSYNC_TEXT,
Vec2{.x = OVERLAY_X, .y = OVERLAY_Y_FPS + OVERLAY_LINE_HEIGHT},
OVERLAY_SCALE,
OVERLAY_SPACING,
OVERLAY_BRIGHTNESS);
Vec2{.x = Cfg::X, .y = Cfg::Y_FPS + Cfg::LINE_HEIGHT},
Cfg::TEXT_SCALE,
Cfg::TEXT_SPACING,
Cfg::BRIGHTNESS);
text_.render(AA_TEXT,
Vec2{.x = OVERLAY_X, .y = OVERLAY_Y_FPS + (2.0F * OVERLAY_LINE_HEIGHT)},
OVERLAY_SCALE,
OVERLAY_SPACING,
OVERLAY_BRIGHTNESS);
Vec2{.x = Cfg::X, .y = Cfg::Y_FPS + (2.0F * Cfg::LINE_HEIGHT)},
Cfg::TEXT_SCALE,
Cfg::TEXT_SPACING,
Cfg::BRIGHTNESS);
}
} // namespace System