treball en curs: correccions de tidy
This commit is contained in:
@@ -22,70 +22,52 @@ struct Offset {
|
||||
};
|
||||
|
||||
struct TextFile {
|
||||
int boxWidth; // Anchura de la caja de cada caracter en el png
|
||||
int boxHeight; // Altura de la caja de cada caracter en el png
|
||||
int box_width; // Anchura de la caja de cada caracter en el png
|
||||
int box_height; // Altura de la caja de cada caracter en el png
|
||||
Offset offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||
};
|
||||
|
||||
// Llena una estructuta TextFile desde un fichero
|
||||
auto LoadTextFile(const std::string &file, bool verbose = false) -> TextFile;
|
||||
auto loadTextFile(const std::string &file, bool verbose = false) -> TextFile;
|
||||
|
||||
// Llena una estructura TextFile desde bytes en memoria
|
||||
auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose = false) -> TextFile;
|
||||
auto loadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose = false) -> TextFile;
|
||||
|
||||
// Clase texto. Pinta texto en pantalla a partir de un bitmap
|
||||
class Text {
|
||||
private:
|
||||
// Objetos y punteros
|
||||
Sprite *sprite; // Objeto con los graficos para el texto
|
||||
Texture *texture; // Textura con los bitmaps del texto
|
||||
|
||||
// Variables
|
||||
int boxWidth; // Anchura de la caja de cada caracter en el png
|
||||
int boxHeight; // Altura de la caja de cada caracter en el png
|
||||
bool fixedWidth; // Indica si el texto se ha de escribir con longitud fija en todas las letras
|
||||
Offset offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Text(const std::string &bitmapFile, const std::string &textFile, SDL_Renderer *renderer);
|
||||
Text(const std::string &textFile, Texture *texture, SDL_Renderer *renderer);
|
||||
Text(TextFile *textFile, Texture *texture, SDL_Renderer *renderer);
|
||||
Text(const std::string &bitmap_file, const std::string &text_file, SDL_Renderer *renderer); // Constructor
|
||||
Text(const std::string &text_file, Texture *texture, SDL_Renderer *renderer);
|
||||
Text(TextFile *text_file, Texture *texture, SDL_Renderer *renderer);
|
||||
Text(const std::vector<uint8_t> &png_bytes, const std::vector<uint8_t> &txt_bytes, SDL_Renderer *renderer); // Constructor desde bytes en memoria: comparte ownership del texture (no lo libera)
|
||||
|
||||
// Constructor desde bytes en memoria: comparte ownership del texture (no lo libera)
|
||||
Text(const std::vector<uint8_t> &pngBytes, const std::vector<uint8_t> &txtBytes, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~Text();
|
||||
~Text(); // Destructor
|
||||
|
||||
// No copiable (gestiona memoria dinámica)
|
||||
Text(const Text &) = delete;
|
||||
auto operator=(const Text &) -> Text & = delete;
|
||||
|
||||
// Escribe el texto en pantalla
|
||||
void write(int x, int y, const std::string &text, int kerning = 1, int lenght = -1);
|
||||
void write(int x, int y, const std::string &text, int kerning = 1, int lenght = -1); // Escribe el texto en pantalla
|
||||
void writeColored(int x, int y, const std::string &text, Color color, int kerning = 1, int lenght = -1); // Escribe el texto con colores
|
||||
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(255, 255, 255), Uint8 shadow_distance = 1, Color shadow_color = Color(0, 0, 0), int lenght = -1); // Escribe texto con extras
|
||||
|
||||
// Escribe el texto con colores
|
||||
void writeColored(int x, int y, const std::string &text, Color color, int kerning = 1, int lenght = -1);
|
||||
auto lenght(const std::string &text, int kerning = 1) -> int; // Obtiene la longitud en pixels de una cadena
|
||||
|
||||
// Escribe el texto con sombra
|
||||
void writeShadowed(int x, int y, const std::string &text, Color color, Uint8 shadowDistance = 1, int kerning = 1, int lenght = -1);
|
||||
[[nodiscard]] auto getCharacterSize() const -> int; // Devuelve el valor de la variable
|
||||
|
||||
// Escribe el texto centrado en un punto x
|
||||
void writeCentered(int x, int y, const std::string &text, int kerning = 1, int lenght = -1);
|
||||
void reLoadTexture(); // Recarga la textura
|
||||
void setFixedWidth(bool value); // Establece si se usa un tamaño fijo de letra
|
||||
|
||||
// Escribe texto con extras
|
||||
void writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning = 1, Color textColor = Color(255, 255, 255), Uint8 shadowDistance = 1, Color shadowColor = Color(0, 0, 0), int lenght = -1);
|
||||
private:
|
||||
// Objetos y punteros
|
||||
Sprite *sprite_; // Objeto con los graficos para el texto
|
||||
Texture *texture_; // Textura con los bitmaps del texto
|
||||
|
||||
// Obtiene la longitud en pixels de una cadena
|
||||
auto lenght(const std::string &text, int kerning = 1) -> int;
|
||||
|
||||
// Devuelve el valor de la variable
|
||||
[[nodiscard]] auto getCharacterSize() const -> int;
|
||||
|
||||
// Recarga la textura
|
||||
void reLoadTexture();
|
||||
|
||||
// Establece si se usa un tamaño fijo de letra
|
||||
void setFixedWidth(bool value);
|
||||
// Variables
|
||||
int box_width_; // Anchura de la caja de cada caracter en el png
|
||||
int box_height_; // Altura de la caja de cada caracter en el png
|
||||
bool fixed_width_; // Indica si el texto se ha de escribir con longitud fija en todas las letras
|
||||
Offset offset_[128]; // Vector con las posiciones y ancho de cada letra
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user