From 9235e684e85a46622cc617dbf9927fe9c00fffce Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 29 May 2026 20:52:17 +0200 Subject: [PATCH] =?UTF-8?q?tweak(hud):=20redueix=20els=20slots=20de=20vide?= =?UTF-8?q?s=20a=20l'al=C3=A7ada=20real=20del=20glif=20i=20els=20pinta=20s?= =?UTF-8?q?ense=20glow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/core/graphics/vector_text.cpp | 9 +++++++-- source/core/graphics/vector_text.hpp | 4 ++++ source/game/systems/init_hud_animator.cpp | 8 +++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/source/core/graphics/vector_text.cpp b/source/core/graphics/vector_text.cpp index c916980..1f6f59f 100644 --- a/source/core/graphics/vector_text.cpp +++ b/source/core/graphics/vector_text.cpp @@ -11,8 +11,9 @@ namespace Graphics { // Constants para mides base dels caràcters - constexpr float BASE_CHAR_WIDTH = 20.0F; // Amplada base del caràcter - constexpr float BASE_CHAR_HEIGHT = 40.0F; // Altura base del caràcter + constexpr float BASE_CHAR_WIDTH = 20.0F; // Amplada base del caràcter (cel·la) + constexpr float BASE_CHAR_HEIGHT = 40.0F; // Altura base del caràcter (cel·la, amb marge) + constexpr float BASE_GLYPH_HEIGHT = 20.0F; // Altura real del glif (la majúscula/dígit ocupa 20 dels 40) VectorText::VectorText(Rendering::Renderer* renderer) : renderer_(renderer) { @@ -287,4 +288,8 @@ namespace Graphics { return BASE_CHAR_HEIGHT * scale; } + auto VectorText::getGlyphHeight(float scale) -> float { + return BASE_GLYPH_HEIGHT * scale; + } + } // namespace Graphics diff --git a/source/core/graphics/vector_text.hpp b/source/core/graphics/vector_text.hpp index 7db6dff..363023f 100644 --- a/source/core/graphics/vector_text.hpp +++ b/source/core/graphics/vector_text.hpp @@ -46,6 +46,10 @@ namespace Graphics { // Calcular altura del texto (útil para centrado vertical). [[nodiscard]] static auto getTextHeight(float scale = 1.0F) -> float; + // Altura real del glif (la majúscula/dígit, sense el marge vertical de la + // cel·la). Útil per dimensionar icones que han de casar amb el text. + [[nodiscard]] static auto getGlyphHeight(float scale = 1.0F) -> float; + // Verificar si un carácter está soportado [[nodiscard]] auto isSupported(char c) const -> bool; diff --git a/source/game/systems/init_hud_animator.cpp b/source/game/systems/init_hud_animator.cpp index 80f886f..d4c7083 100644 --- a/source/game/systems/init_hud_animator.cpp +++ b/source/game/systems/init_hud_animator.cpp @@ -92,9 +92,10 @@ namespace Systems::InitHud { Graphics::VectorText::getTextWidth("0", scale, spacing); } - // Mida d'un slot = alçada de la majúscula del dígit (mètrica del glif). + // Mida d'un slot = alçada real del glif del dígit (no la cel·la, que té + // marge vertical: usar la cel·la feia les naus el doble de grans). auto slotSize(float scale) -> float { - return Graphics::VectorText::getTextHeight(scale); + return Graphics::VectorText::getGlyphHeight(scale); } // Ample del bloc de slots: constant, independent de les vides. NUM_SLOTS @@ -131,7 +132,8 @@ namespace Systems::InitHud { for (int i = 0; i < NUM_SLOTS; i++) { const SDL_Color COLOR = (i < FILLED) ? bright : dim; const Vec2 POS = {.x = x_left + (SIZE / 2.0F) + (static_cast(i) * PITCH), .y = center_y}; - Rendering::renderShape(renderer, shape, POS, 0.0F, ICON_SCALE, 1.0F, 1.0F, COLOR); + // glow=false: el marcador es manté net, com els dígits del text. + Rendering::renderShape(renderer, shape, POS, 0.0F, ICON_SCALE, 1.0F, 1.0F, COLOR, 0.0F, 1.0F, false); } }