tweak(hud): redueix els slots de vides a l'alçada real del glif i els pinta sense glow

This commit is contained in:
2026-05-29 20:52:17 +02:00
parent 0350063fb7
commit 9235e684e8
3 changed files with 16 additions and 5 deletions
+7 -2
View File
@@ -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
+4
View File
@@ -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;
+5 -3
View File
@@ -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<float>(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);
}
}