text: afegit TextStyle
This commit is contained in:
@@ -6,8 +6,9 @@
|
||||
#include <memory> // Para unique_ptr, shared_ptr
|
||||
#include <string> // Para string
|
||||
|
||||
#include "color.h" // Para Color
|
||||
#include "sprite.h" // Para Sprite
|
||||
#include "utils.h" // Para Color
|
||||
#include "utils.h"
|
||||
|
||||
class Texture;
|
||||
|
||||
@@ -28,6 +29,23 @@ struct TextFile {
|
||||
std::array<TextOffset, 128> offset = {}; // Vector con las posiciones y ancho de cada letra
|
||||
};
|
||||
|
||||
struct TextStyle {
|
||||
Color text_color;
|
||||
Color shadow_color;
|
||||
Uint8 shadow_distance;
|
||||
int kerning;
|
||||
|
||||
// Constructor con argumentos por defecto
|
||||
TextStyle(Color text = Color(),
|
||||
Color shadow = Color(),
|
||||
Uint8 distance = 1,
|
||||
int kern = 1)
|
||||
: text_color(text),
|
||||
shadow_color(shadow),
|
||||
shadow_distance(distance),
|
||||
kerning(kern) {}
|
||||
};
|
||||
|
||||
// Llena una estructura TextFile desde un fichero
|
||||
auto loadTextFile(const std::string &file_path) -> std::shared_ptr<TextFile>;
|
||||
|
||||
@@ -52,6 +70,7 @@ class Text {
|
||||
void writeShadowed(int x, int y, const std::string &text, Color color, Uint8 shadow_distance = 1, int kerning = 1, int lenght = -1); // Escribe el texto con sombra
|
||||
void writeCentered(int x, int y, const std::string &text, int kerning = 1, int lenght = -1); // Escribe el texto centrado en un punto x
|
||||
void writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning = 1, Color text_color = Color(), Uint8 shadow_distance = 1, Color shadow_color = Color(), int lenght = -1); // Escribe texto con extras
|
||||
void writeDX(Uint8 flags, int x, int y, const std::string &text, const TextStyle &style, int length = -1); // Escribe texto a partir de un TextStyle
|
||||
|
||||
// --- Utilidades ---
|
||||
[[nodiscard]] auto lenght(const std::string &text, int kerning = 1) const -> int; // Obtiene la longitud en pixels de una cadena
|
||||
|
||||
Reference in New Issue
Block a user