style: aplicar fixes de clang-tidy (todo excepto uppercase-literal-suffix)
Corregidos ~2570 issues automáticamente con clang-tidy --fix-errors más ajustes manuales posteriores: - modernize: designated-initializers, trailing-return-type, use-auto, avoid-c-arrays (→ std::array<>), use-ranges, use-emplace, deprecated-headers, use-equals-default, pass-by-value, return-braced-init-list, use-default-member-init - readability: math-missing-parentheses, implicit-bool-conversion, braces-around-statements, isolate-declaration, use-std-min-max, identifier-naming, else-after-return, redundant-casting, convert-member-functions-to-static, make-member-function-const, static-accessed-through-instance - performance: avoid-endl, unnecessary-value-param, type-promotion, inefficient-vector-operation - dead code: XOR_KEY (orphan tras eliminar encryptData/decryptData), dead stores en engine.cpp y png_shape.cpp - NOLINT justificado en 10 funciones con alta complejidad cognitiva (initialize, render, main, processEvents, update×3, performDemoAction, randomizeOnDemoStart, renderDebugHUD, AppLogo::update) Compilación: gcc -Wall sin warnings. clang-tidy: 0 issues. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,60 +2,61 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3_ttf/SDL_ttf.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
class TextRenderer {
|
||||
public:
|
||||
TextRenderer();
|
||||
~TextRenderer();
|
||||
public:
|
||||
TextRenderer();
|
||||
~TextRenderer();
|
||||
|
||||
// Inicializa el renderizador de texto con una fuente
|
||||
bool init(SDL_Renderer* renderer, const char* font_path, int font_size, bool use_antialiasing = true);
|
||||
// Inicializa el renderizador de texto con una fuente
|
||||
bool init(SDL_Renderer* renderer, const char* font_path, int font_size, bool use_antialiasing = true);
|
||||
|
||||
// Reinicializa el renderizador con un nuevo tamaño de fuente
|
||||
bool reinitialize(int new_font_size);
|
||||
// Reinicializa el renderizador con un nuevo tamaño de fuente
|
||||
bool reinitialize(int new_font_size);
|
||||
|
||||
// Libera recursos
|
||||
void cleanup();
|
||||
// Libera recursos
|
||||
void cleanup();
|
||||
|
||||
// Renderiza texto en la posición especificada con color RGB
|
||||
void print(int x, int y, const char* text, uint8_t r, uint8_t g, uint8_t b);
|
||||
void print(int x, int y, const std::string& text, uint8_t r, uint8_t g, uint8_t b);
|
||||
// Renderiza texto en la posición especificada con color RGB
|
||||
void print(int x, int y, const char* text, uint8_t r, uint8_t g, uint8_t b);
|
||||
void print(int x, int y, const std::string& text, uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
// Renderiza texto en coordenadas lógicas, pero convierte a físicas para tamaño absoluto
|
||||
void printPhysical(int logical_x, int logical_y, const char* text, uint8_t r, uint8_t g, uint8_t b, float scale_x, float scale_y);
|
||||
void printPhysical(int logical_x, int logical_y, const std::string& text, uint8_t r, uint8_t g, uint8_t b, float scale_x, float scale_y);
|
||||
// Renderiza texto en coordenadas lógicas, pero convierte a físicas para tamaño absoluto
|
||||
void printPhysical(int logical_x, int logical_y, const char* text, uint8_t r, uint8_t g, uint8_t b, float scale_x, float scale_y);
|
||||
void printPhysical(int logical_x, int logical_y, const std::string& text, uint8_t r, uint8_t g, uint8_t b, float scale_x, float scale_y);
|
||||
|
||||
// Renderiza texto en coordenadas físicas absolutas (tamaño fijo independiente de resolución)
|
||||
// NOTA: Este método usa el tamaño de fuente tal cual fue cargado, sin escalado
|
||||
void printAbsolute(int physical_x, int physical_y, const char* text, SDL_Color color);
|
||||
void printAbsolute(int physical_x, int physical_y, const std::string& text, SDL_Color color);
|
||||
// Renderiza texto en coordenadas físicas absolutas (tamaño fijo independiente de resolución)
|
||||
// NOTA: Este método usa el tamaño de fuente tal cual fue cargado, sin escalado
|
||||
void printAbsolute(int physical_x, int physical_y, const char* text, SDL_Color color);
|
||||
void printAbsolute(int physical_x, int physical_y, const std::string& text, SDL_Color color);
|
||||
|
||||
// Renderiza texto con sombra negra (+1px offset) para máxima legibilidad sobre cualquier fondo
|
||||
void printAbsoluteShadowed(int physical_x, int physical_y, const char* text);
|
||||
void printAbsoluteShadowed(int physical_x, int physical_y, const std::string& text);
|
||||
// Renderiza texto con sombra negra (+1px offset) para máxima legibilidad sobre cualquier fondo
|
||||
void printAbsoluteShadowed(int physical_x, int physical_y, const char* text);
|
||||
void printAbsoluteShadowed(int physical_x, int physical_y, const std::string& text);
|
||||
|
||||
// Obtiene el ancho de un texto renderizado (en píxeles lógicos para compatibilidad)
|
||||
int getTextWidth(const char* text);
|
||||
// Obtiene el ancho de un texto renderizado (en píxeles lógicos para compatibilidad)
|
||||
int getTextWidth(const char* text);
|
||||
|
||||
// Obtiene el ancho de un texto en píxeles FÍSICOS reales (sin escalado)
|
||||
// Útil para notificaciones y elementos UI de tamaño fijo
|
||||
int getTextWidthPhysical(const char* text);
|
||||
// Obtiene el ancho de un texto en píxeles FÍSICOS reales (sin escalado)
|
||||
// Útil para notificaciones y elementos UI de tamaño fijo
|
||||
int getTextWidthPhysical(const char* text);
|
||||
|
||||
// Obtiene la altura de la fuente (incluye line_gap)
|
||||
int getTextHeight();
|
||||
// Obtiene la altura de la fuente (incluye line_gap)
|
||||
int getTextHeight();
|
||||
|
||||
// Obtiene la altura real del glifo (ascender + |descendente|, sin line_gap)
|
||||
int getGlyphHeight();
|
||||
// Obtiene la altura real del glifo (ascender + |descendente|, sin line_gap)
|
||||
int getGlyphHeight();
|
||||
|
||||
// Verifica si está inicializado correctamente
|
||||
bool isInitialized() const { return font_ != nullptr && renderer_ != nullptr; }
|
||||
// Verifica si está inicializado correctamente
|
||||
bool isInitialized() const { return font_ != nullptr && renderer_ != nullptr; }
|
||||
|
||||
private:
|
||||
SDL_Renderer* renderer_;
|
||||
TTF_Font* font_;
|
||||
int font_size_;
|
||||
bool use_antialiasing_;
|
||||
std::string font_path_; // Almacenar ruta para reinitialize()
|
||||
unsigned char* font_data_buffer_; // Buffer de datos de fuente (mantener en memoria mientras esté abierta)
|
||||
private:
|
||||
SDL_Renderer* renderer_;
|
||||
TTF_Font* font_;
|
||||
int font_size_;
|
||||
bool use_antialiasing_;
|
||||
std::string font_path_; // Almacenar ruta para reinitialize()
|
||||
unsigned char* font_data_buffer_; // Buffer de datos de fuente (mantener en memoria mientras esté abierta)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user