noves coses chules en la clase text

This commit is contained in:
2025-08-17 14:25:17 +02:00
parent fe0083abd4
commit ff2a51a507
7 changed files with 184 additions and 19 deletions

View File

@@ -54,6 +54,8 @@ class Text {
// --- Constructores y destructor ---
Text(const std::shared_ptr<Texture> &texture, const std::string &text_file);
Text(const std::shared_ptr<Texture> &texture, const std::shared_ptr<Text::File> &text_file);
Text(const std::shared_ptr<Texture> &texture, const std::shared_ptr<Texture> &white_texture, const std::string &text_file);
Text(const std::shared_ptr<Texture> &texture, const std::shared_ptr<Texture> &white_texture, const std::shared_ptr<Text::File> &text_file);
~Text() = default;
// --- Métodos de escritura en pantalla ---
@@ -81,9 +83,14 @@ class Text {
// --- Métodos estáticos ---
static auto loadFile(const std::string &file_path) -> std::shared_ptr<Text::File>; // Llena una estructura Text::File desde un fichero
// --- Métodos privados ---
void writeColoredWithSprite(Sprite* sprite, int x, int y, const std::string &text, Color color, int kerning = 1, int length = -1); // Escribe con un sprite específico
void writeStrokeWithAlpha(int x, int y, const std::string &text, int kerning, Color stroke_color, Uint8 shadow_distance, int length = -1); // Escribe stroke con alpha correcto
private:
// --- Objetos y punteros ---
std::unique_ptr<Sprite> sprite_ = nullptr; // Objeto con los gráficos para el texto
std::unique_ptr<Sprite> sprite_ = nullptr; // Objeto con los gráficos para el texto
std::unique_ptr<Sprite> white_sprite_ = nullptr; // Objeto con los gráficos en blanco para efectos
// --- Variables de estado ---
std::array<Offset, 128> offset_ = {}; // Vector con las posiciones y ancho de cada letra