64 lines
2.0 KiB
C++
64 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "utils/defaults.hpp"
|
|
|
|
class Text;
|
|
|
|
// Overlay de debug amb tres estats (OFF / TOP / BOTTOM). Mostra una barra
|
|
// d'info dividida en segments independents (fps, driver, shader, temps) que
|
|
// apareixen i desapareixen suaument. La posició es commuta amb una tecla
|
|
// (cicle OFF → TOP → BOTTOM) i el segment de temps es pot mostrar o amagar
|
|
// per separat; les dos opcions persisteixen a config.yaml.
|
|
class RenderInfo {
|
|
public:
|
|
static auto get() -> RenderInfo&;
|
|
|
|
RenderInfo(const RenderInfo&) = delete;
|
|
RenderInfo(RenderInfo&&) = delete;
|
|
auto operator=(const RenderInfo&) -> RenderInfo& = delete;
|
|
auto operator=(RenderInfo&&) -> RenderInfo& = delete;
|
|
|
|
void init();
|
|
|
|
void update(int delta_ms);
|
|
void render();
|
|
|
|
// Avança la posició OFF → TOP → BOTTOM → OFF i persisteix.
|
|
static void cyclePosition();
|
|
|
|
// Mostra/oculta el segment de temps i persisteix. Només té efecte visual
|
|
// quan la barra és visible (TOP/BOTTOM).
|
|
static void toggleShowTime();
|
|
|
|
static constexpr int HEIGHT = 10;
|
|
static constexpr float SLIDE_SPEED = 5.0F; // posició global (1/s)
|
|
static constexpr float SEG_SPEED = 6.0F; // segments individuals (1/s)
|
|
|
|
private:
|
|
static constexpr int SEGMENT_COUNT = 4; // fps · driver · shader · temps
|
|
|
|
struct Segment {
|
|
std::string text;
|
|
float anim{0.0F}; // 0 = fora, 1 = dins
|
|
bool visible{false}; // objectiu cap al que tendeix anim
|
|
bool mono_digits{false}; // true només al segment de temps
|
|
};
|
|
|
|
RenderInfo() = default;
|
|
~RenderInfo();
|
|
|
|
void refreshSegments();
|
|
[[nodiscard]] auto segmentWidth(const Segment& seg, int digit_cell_w) const -> int;
|
|
|
|
std::unique_ptr<Text> text_;
|
|
Defaults::RenderInfoPosition visible_pos_{Defaults::RenderInfoPosition::OFF};
|
|
float info_anim_{0.0F}; // 0..1, suavitzat amb outQuad al render
|
|
std::array<Segment, SEGMENT_COUNT> segments_{};
|
|
int elapsed_ms_{0};
|
|
};
|