Transició a surface: vaig per title.cpp

This commit is contained in:
2025-03-02 21:56:19 +01:00
parent db3a0d7263
commit 8f1d1df5d6
27 changed files with 416 additions and 490 deletions

View File

@@ -3,9 +3,9 @@
#include <SDL2/SDL_stdinc.h> // Para Uint8
#include <memory> // Para unique_ptr, shared_ptr
#include <string> // Para string
#include "sprite.h" // Para Sprite
#include "s_sprite.h" // Para SSprite
#include "utils.h" // Para Color
class Texture; // lines 9-9
class Surface; // lines 9-9
constexpr int TEXT_COLOR = 1;
constexpr int TEXT_SHADOW = 2;
@@ -32,7 +32,7 @@ class Text
{
private:
// Objetos y punteros
std::unique_ptr<Sprite> sprite_ = nullptr; // Objeto con los graficos para el texto
std::unique_ptr<SSprite> sprite_ = nullptr; // Objeto con los graficos para el texto
// Variables
int box_width_ = 0; // Anchura de la caja de cada caracter en el png
@@ -42,21 +42,20 @@ private:
public:
// Constructor
Text(std::shared_ptr<Texture> texture, const std::string &text_file);
Text(std::shared_ptr<Texture> texture, std::shared_ptr<TextFile> text_file);
Text(std::shared_ptr<Surface> surface, const std::string &text_file);
Text(std::shared_ptr<Surface> surface, std::shared_ptr<TextFile> text_file);
// Destructor
~Text() = default;
// Escribe el texto en pantalla
void write(int x, int y, const std::string &text, int kerning = 1, int lenght = -1);
void write2X(int x, int y, const std::string &text, int kerning = 1);
// Escribe el texto en una textura
std::shared_ptr<Texture> writeToTexture(const std::string &text, int zoom = 1, int kerning = 1);
std::shared_ptr<Surface> writeToSurface(const std::string &text, int zoom = 1, int kerning = 1);
// Escribe el texto con extras en una textura
std::shared_ptr<Texture> writeDXToTexture(Uint8 flags, const std::string &text, int kerning = 1, Color textColor = Color(), Uint8 shadow_distance = 1, Color shadow_color = Color(), int lenght = -1);
std::shared_ptr<Surface> writeDXToSurface(Uint8 flags, const std::string &text, int kerning = 1, Color textColor = Color(), Uint8 shadow_distance = 1, Color shadow_color = Color(), int lenght = -1);
// Escribe el texto con colores
void writeColored(int x, int y, const std::string &text, Color color, int kerning = 1, int lenght = -1);
@@ -76,12 +75,6 @@ public:
// Devuelve el valor de la variable
int getCharacterSize() const;
// Recarga la textura
void reLoadTexture();
// Establece si se usa un tamaño fijo de letra
void setFixedWidth(bool value);
// Establece una paleta
void setPalette(int number);
};