forked from jaildesigner-jailgames/jaildoctors_dilemma
Redistribuits els .cpp en carpetes
Actualitzat cmake Modificats els include de SDL2 a SDL3
This commit is contained in:
@@ -1,79 +1,78 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_stdinc.h> // Para Uint8
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <string> // Para string
|
||||
#include "s_sprite.h" // Para SSprite
|
||||
class Surface; // lines 8-8
|
||||
#include <SDL3/SDL_stdinc.h> // Para Uint8
|
||||
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <string> // Para string
|
||||
|
||||
#include "s_sprite.h" // Para SSprite
|
||||
class Surface; // lines 8-8
|
||||
|
||||
constexpr int TEXT_COLOR = 1;
|
||||
constexpr int TEXT_SHADOW = 2;
|
||||
constexpr int TEXT_CENTER = 4;
|
||||
constexpr int TEXT_STROKE = 8;
|
||||
|
||||
struct TextOffset
|
||||
{
|
||||
int x, y, w;
|
||||
struct TextOffset {
|
||||
int x, y, w;
|
||||
};
|
||||
|
||||
struct TextFile
|
||||
{
|
||||
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
|
||||
TextOffset offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||
struct TextFile {
|
||||
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
|
||||
TextOffset offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||
};
|
||||
|
||||
// Llena una estructuta TextFile desde un fichero
|
||||
std::shared_ptr<TextFile> loadTextFile(const std::string &file_path);
|
||||
std::shared_ptr<TextFile> loadTextFile(const std::string& file_path);
|
||||
|
||||
// Clase texto. Pinta texto en pantalla a partir de un bitmap
|
||||
class Text
|
||||
{
|
||||
private:
|
||||
// Objetos y punteros
|
||||
std::unique_ptr<SSprite> sprite_ = nullptr; // Objeto con los graficos para el texto
|
||||
class Text {
|
||||
private:
|
||||
// Objetos y punteros
|
||||
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
|
||||
int box_height_ = 0; // Altura de la caja de cada caracter en el png
|
||||
bool fixed_width_ = false; // Indica si el texto se ha de escribir con longitud fija en todas las letras
|
||||
TextOffset offset_[128] = {}; // Vector con las posiciones y ancho de cada letra
|
||||
// Variables
|
||||
int box_width_ = 0; // Anchura de la caja de cada caracter en el png
|
||||
int box_height_ = 0; // Altura de la caja de cada caracter en el png
|
||||
bool fixed_width_ = false; // Indica si el texto se ha de escribir con longitud fija en todas las letras
|
||||
TextOffset offset_[128] = {}; // Vector con las posiciones y ancho de cada letra
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Text(std::shared_ptr<Surface> surface, const std::string &text_file);
|
||||
Text(std::shared_ptr<Surface> surface, std::shared_ptr<TextFile> text_file);
|
||||
public:
|
||||
// Constructor
|
||||
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;
|
||||
// Destructor
|
||||
~Text() = default;
|
||||
|
||||
// Escribe el texto en pantalla
|
||||
void write(int x, int y, const std::string &text, int kerning = 1, int lenght = -1);
|
||||
// Escribe el texto en pantalla
|
||||
void write(int x, int y, const std::string& text, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto en una textura
|
||||
std::shared_ptr<Surface> writeToSurface(const std::string &text, int zoom = 1, int kerning = 1);
|
||||
// Escribe el texto en una textura
|
||||
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<Surface> writeDXToSurface(Uint8 flags, const std::string &text, int kerning = 1, Uint8 textColor = Uint8(), Uint8 shadow_distance = 1, Uint8 shadow_color = Uint8(), int lenght = -1);
|
||||
// Escribe el texto con extras en una textura
|
||||
std::shared_ptr<Surface> writeDXToSurface(Uint8 flags, const std::string& text, int kerning = 1, Uint8 textColor = Uint8(), Uint8 shadow_distance = 1, Uint8 shadow_color = Uint8(), int lenght = -1);
|
||||
|
||||
// Escribe el texto con colores
|
||||
void writeColored(int x, int y, const std::string &text, Uint8 color, int kerning = 1, int lenght = -1);
|
||||
// Escribe el texto con colores
|
||||
void writeColored(int x, int y, const std::string& text, Uint8 color, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto con sombra
|
||||
void writeShadowed(int x, int y, const std::string &text, Uint8 color, Uint8 shadow_distance = 1, int kerning = 1, int lenght = -1);
|
||||
// Escribe el texto con sombra
|
||||
void writeShadowed(int x, int y, const std::string& text, Uint8 color, Uint8 shadow_distance = 1, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto centrado en un punto x
|
||||
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 writeCentered(int x, int y, const std::string& text, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe texto con extras
|
||||
void writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning = 1, Uint8 textColor = Uint8(), Uint8 shadow_distance = 1, Uint8 shadow_color = Uint8(), int lenght = -1);
|
||||
// Escribe texto con extras
|
||||
void writeDX(Uint8 flags, int x, int y, const std::string& text, int kerning = 1, Uint8 textColor = Uint8(), Uint8 shadow_distance = 1, Uint8 shadow_color = Uint8(), int lenght = -1);
|
||||
|
||||
// Obtiene la longitud en pixels de una cadena
|
||||
int lenght(const std::string &text, int kerning = 1) const;
|
||||
// Obtiene la longitud en pixels de una cadena
|
||||
int lenght(const std::string& text, int kerning = 1) const;
|
||||
|
||||
// Devuelve el valor de la variable
|
||||
int getCharacterSize() const;
|
||||
// Devuelve el valor de la variable
|
||||
int getCharacterSize() const;
|
||||
|
||||
// Establece si se usa un tamaño fijo de letra
|
||||
void setFixedWidth(bool value);
|
||||
// Establece si se usa un tamaño fijo de letra
|
||||
void setFixedWidth(bool value);
|
||||
};
|
||||
Reference in New Issue
Block a user