RenderInfo amb tres estats (off/dalt/baix), temps de joc i persistència; ombra, mono-dígits i easing compartits (v0.14.0)
This commit is contained in:
1 parent
46a578fd86
commit
6f3fafbfff
17 files changed
+376
-97
No files matched your search
@@ -1,13 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "utils/defaults.hpp"
|
||||
|
||||
class Text;
|
||||
|
||||
// Overlay de debug que mostra FPS, driver GPU i shader + preset actiu. Es
|
||||
// dibuixa a la part superior de la pantalla amb una animació de lliscament
|
||||
// (RISING / ACTIVE / VANISHING / HIDDEN). L'activa la tecla F3 a l'escena.
|
||||
// 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&;
|
||||
@@ -17,29 +23,41 @@ class RenderInfo {
|
||||
auto operator=(const RenderInfo&) -> RenderInfo& = delete;
|
||||
auto operator=(RenderInfo&&) -> RenderInfo& = delete;
|
||||
|
||||
// Carrega la font 8bithud. S'ha de cridar després de configurar Screen.
|
||||
void init();
|
||||
|
||||
void update(int delta_ms);
|
||||
void render();
|
||||
void toggle();
|
||||
|
||||
[[nodiscard]] auto isActive() const -> bool { return status_ != Status::HIDDEN; }
|
||||
// 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();
|
||||
|
||||
// Alçada fixa de l'overlay: TEXT_SIZE (8) + padding vertical.
|
||||
static constexpr int HEIGHT = 10;
|
||||
static constexpr float SLIDE_SPEED = 120.0F;
|
||||
static constexpr float SLIDE_SPEED = 5.0F; // posició global (1/s)
|
||||
static constexpr float SEG_SPEED = 6.0F; // segments individuals (1/s)
|
||||
|
||||
private:
|
||||
enum class Status : std::uint8_t { HIDDEN,
|
||||
RISING,
|
||||
ACTIVE,
|
||||
VANISHING };
|
||||
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_;
|
||||
Status status_{Status::HIDDEN};
|
||||
float y_{static_cast<float>(-HEIGHT)};
|
||||
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};
|
||||
};
|
||||
Reference in new issue
Block a user