renomena tipus _t/_e a CamelCase (Circle, Color, Section, ...)
This commit is contained in:
@@ -380,7 +380,7 @@ void Input::setVerbose(bool value) {
|
||||
}
|
||||
|
||||
// Deshabilita las entradas durante un periodo de tiempo
|
||||
void Input::disableUntil(i_disable_e value) {
|
||||
void Input::disableUntil(InputDisable value) {
|
||||
disabledUntil = value;
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ constexpr int INPUT_USE_KEYBOARD = 0;
|
||||
constexpr int INPUT_USE_GAMECONTROLLER = 1;
|
||||
constexpr int INPUT_USE_ANY = 2;
|
||||
|
||||
enum inputs_e : std::uint8_t {
|
||||
enum InputAction : std::uint8_t {
|
||||
// Inputs obligatorios
|
||||
input_null,
|
||||
input_up,
|
||||
@@ -44,7 +44,7 @@ enum inputs_e : std::uint8_t {
|
||||
input_number_of_inputs
|
||||
};
|
||||
|
||||
enum i_disable_e : std::uint8_t {
|
||||
enum InputDisable : std::uint8_t {
|
||||
d_notDisabled,
|
||||
d_forever,
|
||||
d_keyPressed
|
||||
@@ -73,7 +73,7 @@ class Input {
|
||||
int numGamepads{0}; // Numero de mandos conectados
|
||||
std::string dbPath; // Ruta al archivo gamecontrollerdb.txt
|
||||
bool verbose{true}; // Indica si ha de mostrar mensajes
|
||||
i_disable_e disabledUntil{d_notDisabled}; // Tiempo que esta deshabilitado
|
||||
InputDisable disabledUntil{d_notDisabled}; // Tiempo que esta deshabilitado
|
||||
bool enabled{true}; // Indica si está habilitado
|
||||
|
||||
// Construye el nombre visible de un mando (name truncado + sufijo #N)
|
||||
@@ -133,7 +133,7 @@ class Input {
|
||||
void setVerbose(bool value);
|
||||
|
||||
// Deshabilita las entradas durante un periodo de tiempo
|
||||
void disableUntil(i_disable_e value);
|
||||
void disableUntil(InputDisable value);
|
||||
|
||||
// Hablita las entradas
|
||||
void enable();
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#include "core/resources/resource_helper.h" // for loadFile (pack + filesystem fallback)
|
||||
|
||||
// Parser compartido: lee un istream con el formato .ani
|
||||
static auto parseAnimationStream(std::istream &file, Texture *texture, const std::string &filename, bool verbose) -> animatedSprite_t {
|
||||
animatedSprite_t as;
|
||||
static auto parseAnimationStream(std::istream &file, Texture *texture, const std::string &filename, bool verbose) -> AnimatedSpriteData {
|
||||
AnimatedSpriteData as;
|
||||
as.texture = texture;
|
||||
int framesPerRow = 0;
|
||||
int frameWidth = 0;
|
||||
@@ -32,7 +32,7 @@ static auto parseAnimationStream(std::istream &file, Texture *texture, const std
|
||||
while (std::getline(file, line)) {
|
||||
strip_cr(line);
|
||||
if (line == "[animation]") {
|
||||
animation_t buffer;
|
||||
Animation buffer;
|
||||
buffer.speed = 0;
|
||||
buffer.loop = -1;
|
||||
buffer.counter = 0;
|
||||
@@ -98,14 +98,14 @@ static auto parseAnimationStream(std::istream &file, Texture *texture, const std
|
||||
}
|
||||
|
||||
// Carga la animación desde un fichero (vía ResourceHelper: pack si està inicialitzat, filesystem si no)
|
||||
auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool verbose) -> animatedSprite_t {
|
||||
auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool verbose) -> AnimatedSpriteData {
|
||||
const std::string filename = filePath.substr(filePath.find_last_of("\\/") + 1);
|
||||
auto bytes = ResourceHelper::loadFile(filePath);
|
||||
if (bytes.empty()) {
|
||||
if (verbose) {
|
||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << '\n';
|
||||
}
|
||||
animatedSprite_t as;
|
||||
AnimatedSpriteData as;
|
||||
as.texture = texture;
|
||||
return as;
|
||||
}
|
||||
@@ -113,9 +113,9 @@ auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool v
|
||||
}
|
||||
|
||||
// Carga la animación desde bytes en memoria
|
||||
auto loadAnimationFromMemory(Texture *texture, const std::vector<uint8_t> &bytes, const std::string &nameForLogs, bool verbose) -> animatedSprite_t {
|
||||
auto loadAnimationFromMemory(Texture *texture, const std::vector<uint8_t> &bytes, const std::string &nameForLogs, bool verbose) -> AnimatedSpriteData {
|
||||
if (bytes.empty()) {
|
||||
animatedSprite_t as;
|
||||
AnimatedSpriteData as;
|
||||
as.texture = texture;
|
||||
return as;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, const s
|
||||
|
||||
// Carga las animaciones
|
||||
if (!file.empty()) {
|
||||
animatedSprite_t as = loadAnimationFromFile(texture, file);
|
||||
AnimatedSpriteData as = loadAnimationFromFile(texture, file);
|
||||
|
||||
// Copia los datos de las animaciones
|
||||
animation.insert(animation.end(), as.animations.begin(), as.animations.end());
|
||||
@@ -145,7 +145,7 @@ AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, const s
|
||||
}
|
||||
|
||||
// Constructor
|
||||
AnimatedSprite::AnimatedSprite(SDL_Renderer *renderer, animatedSprite_t *animation)
|
||||
AnimatedSprite::AnimatedSprite(SDL_Renderer *renderer, AnimatedSpriteData *animation)
|
||||
: currentAnimation(0) {
|
||||
// Copia los punteros
|
||||
setTexture(animation->texture);
|
||||
@@ -299,7 +299,7 @@ auto AnimatedSprite::loadFromVector(std::vector<std::string> *source) -> bool {
|
||||
|
||||
// Si la linea contiene el texto [animation] se realiza el proceso de carga de una animación
|
||||
if (line == "[animation]") {
|
||||
animation_t buffer;
|
||||
Animation buffer;
|
||||
buffer.speed = 0;
|
||||
buffer.loop = -1;
|
||||
buffer.counter = 0;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "core/rendering/movingsprite.h" // for MovingSprite
|
||||
class Texture;
|
||||
|
||||
struct animation_t {
|
||||
struct Animation {
|
||||
std::string name; // Nombre de la animacion
|
||||
std::vector<SDL_Rect> frames; // Cada uno de los frames que componen la animación
|
||||
int speed; // Velocidad de la animación
|
||||
@@ -19,27 +19,27 @@ struct animation_t {
|
||||
int counter; // Contador para las animaciones
|
||||
};
|
||||
|
||||
struct animatedSprite_t {
|
||||
std::vector<animation_t> animations; // Vector con las diferentes animaciones
|
||||
struct AnimatedSpriteData {
|
||||
std::vector<Animation> animations; // Vector con las diferentes animaciones
|
||||
Texture *texture; // Textura con los graficos para el sprite
|
||||
};
|
||||
|
||||
// Carga la animación desde un fichero
|
||||
auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool verbose = false) -> animatedSprite_t;
|
||||
auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool verbose = false) -> AnimatedSpriteData;
|
||||
|
||||
// Carga la animación desde bytes en memoria
|
||||
auto loadAnimationFromMemory(Texture *texture, const std::vector<uint8_t> &bytes, const std::string &nameForLogs = "", bool verbose = false) -> animatedSprite_t;
|
||||
auto loadAnimationFromMemory(Texture *texture, const std::vector<uint8_t> &bytes, const std::string &nameForLogs = "", bool verbose = false) -> AnimatedSpriteData;
|
||||
|
||||
class AnimatedSprite : public MovingSprite {
|
||||
private:
|
||||
// Variables
|
||||
std::vector<animation_t> animation; // Vector con las diferentes animaciones
|
||||
std::vector<Animation> animation; // Vector con las diferentes animaciones
|
||||
int currentAnimation; // Animacion activa
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
explicit AnimatedSprite(Texture *texture = nullptr, SDL_Renderer *renderer = nullptr, const std::string &file = "", std::vector<std::string> *buffer = nullptr);
|
||||
AnimatedSprite(SDL_Renderer *renderer, animatedSprite_t *animation);
|
||||
AnimatedSprite(SDL_Renderer *renderer, AnimatedSpriteData *animation);
|
||||
|
||||
// Destructor
|
||||
~AnimatedSprite() override;
|
||||
|
||||
@@ -157,7 +157,7 @@ Screen::~Screen() {
|
||||
}
|
||||
|
||||
// Limpia la pantalla
|
||||
void Screen::clean(color_t color) {
|
||||
void Screen::clean(Color color) {
|
||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
}
|
||||
@@ -327,7 +327,7 @@ void Screen::toggleVSync() {
|
||||
}
|
||||
|
||||
// Cambia el color del borde
|
||||
void Screen::setBorderColor(color_t color) {
|
||||
void Screen::setBorderColor(Color color) {
|
||||
borderColor = color;
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ void Screen::applyLogicalPresentation(bool fullscreen) {
|
||||
// ============================================================================
|
||||
|
||||
// Muestra una notificación en la línea superior durante durationMs
|
||||
void Screen::notify(const std::string &text, color_t textColor, color_t outlineColor, Uint32 durationMs) {
|
||||
void Screen::notify(const std::string &text, Color textColor, Color outlineColor, Uint32 durationMs) {
|
||||
notificationMessage = text;
|
||||
notificationTextColor = textColor;
|
||||
notificationOutlineColor = outlineColor;
|
||||
@@ -570,8 +570,8 @@ void Screen::setShaderEnabled(bool enabled) {
|
||||
// Si enabled=false, blit() forçarà POSTFX+zero per frame — no cal tocar
|
||||
// res ara.
|
||||
#endif
|
||||
const color_t CYAN = {0x00, 0xFF, 0xFF};
|
||||
const color_t BLACK = {0x00, 0x00, 0x00};
|
||||
const Color CYAN = {0x00, 0xFF, 0xFF};
|
||||
const Color BLACK = {0x00, 0x00, 0x00};
|
||||
const Uint32 DUR_MS = 1500;
|
||||
notify(enabled ? "Shader: ON" : "Shader: OFF", CYAN, BLACK, DUR_MS);
|
||||
}
|
||||
@@ -590,8 +590,8 @@ void Screen::setActiveShader(Rendering::ShaderType type) {
|
||||
if (Options::video.shader.enabled) {
|
||||
applyShaderParams();
|
||||
}
|
||||
const color_t MAGENTA = {0xFF, 0x00, 0xFF};
|
||||
const color_t BLACK = {0x00, 0x00, 0x00};
|
||||
const Color MAGENTA = {0xFF, 0x00, 0xFF};
|
||||
const Color BLACK = {0x00, 0x00, 0x00};
|
||||
const Uint32 DUR_MS = 1500;
|
||||
notify(type == Rendering::ShaderType::CRTPI ? "Shader: CRTPI" : "Shader: POSTFX", MAGENTA, BLACK, DUR_MS);
|
||||
}
|
||||
@@ -703,8 +703,8 @@ auto Screen::nextPreset() -> bool {
|
||||
applyCurrentCrtPiPreset();
|
||||
}
|
||||
|
||||
const color_t GREEN = {0x00, 0xFF, 0x80};
|
||||
const color_t BLACK = {0x00, 0x00, 0x00};
|
||||
const Color GREEN = {0x00, 0xFF, 0x80};
|
||||
const Color BLACK = {0x00, 0x00, 0x00};
|
||||
const Uint32 DUR_MS = 1500;
|
||||
notify(std::string("Preset: ") + getCurrentPresetName(), GREEN, BLACK, DUR_MS);
|
||||
return true;
|
||||
@@ -734,8 +734,8 @@ auto Screen::prevPreset() -> bool {
|
||||
applyCurrentCrtPiPreset();
|
||||
}
|
||||
|
||||
const color_t GREEN = {0x00, 0xFF, 0x80};
|
||||
const color_t BLACK = {0x00, 0x00, 0x00};
|
||||
const Color GREEN = {0x00, 0xFF, 0x80};
|
||||
const Color BLACK = {0x00, 0x00, 0x00};
|
||||
const Uint32 DUR_MS = 1500;
|
||||
notify(std::string("Preset: ") + getCurrentPresetName(), GREEN, BLACK, DUR_MS);
|
||||
return true;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
|
||||
#include "utils/utils.h" // for color_t
|
||||
#include "utils/utils.h" // for Color
|
||||
|
||||
#ifndef NO_SHADERS
|
||||
#include "core/rendering/shader_backend.hpp" // for Rendering::ShaderType
|
||||
@@ -38,7 +38,7 @@ class Screen {
|
||||
~Screen();
|
||||
|
||||
// Render loop
|
||||
void clean(color_t color = {0x00, 0x00, 0x00}); // Limpia la pantalla
|
||||
void clean(Color color = {0x00, 0x00, 0x00}); // Limpia la pantalla
|
||||
void start(); // Prepara para empezar a dibujar en la textura de juego
|
||||
void blit(); // Vuelca el contenido del renderizador en pantalla
|
||||
|
||||
@@ -56,11 +56,11 @@ class Screen {
|
||||
auto setWindowZoom(int zoom) -> bool; // Establece el zoom de la ventana (devuelve true si cambió)
|
||||
|
||||
// Borde
|
||||
void setBorderColor(color_t color); // Cambia el color del borde
|
||||
void setBorderColor(Color color); // Cambia el color del borde
|
||||
|
||||
// Notificaciones
|
||||
void initNotifications(); // Enllaça el Text de notificacions amb `Resource`. A cridar després de `Resource::init(...)`.
|
||||
void notify(const std::string &text, color_t textColor, color_t outlineColor, Uint32 durationMs); // Muestra una notificación en la línea superior del canvas durante durationMs. Sobrescribe cualquier notificación activa (sin apilación).
|
||||
void notify(const std::string &text, Color textColor, Color outlineColor, Uint32 durationMs); // Muestra una notificación en la línea superior del canvas durante durationMs. Sobrescribe cualquier notificación activa (sin apilación).
|
||||
void clearNotification(); // Limpia la notificación actual
|
||||
|
||||
// GPU / shaders (post-procesado). En builds con NO_SHADERS (Emscripten) son no-op.
|
||||
@@ -121,13 +121,13 @@ class Screen {
|
||||
int gameCanvasWidth; // Resolución interna del juego. Es el ancho de la textura donde se dibuja el juego
|
||||
int gameCanvasHeight; // Resolución interna del juego. Es el alto de la textura donde se dibuja el juego
|
||||
SDL_Rect dest; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
||||
color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
||||
Color borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
||||
|
||||
// Notificaciones - una sola activa, sin apilación ni animaciones
|
||||
Text *notificationText; // Fuente 8bithud dedicada a las notificaciones
|
||||
std::string notificationMessage; // Texto a mostrar
|
||||
color_t notificationTextColor; // Color del texto
|
||||
color_t notificationOutlineColor; // Color del outline
|
||||
Color notificationTextColor; // Color del texto
|
||||
Color notificationOutlineColor; // Color del outline
|
||||
Uint32 notificationEndTime; // SDL_GetTicks() hasta el cual se muestra
|
||||
int notificationY; // Fila vertical en el canvas virtual
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
#include "core/rendering/sprite.h" // for Sprite
|
||||
#include "core/rendering/texture.h" // for Texture
|
||||
#include "core/resources/resource_helper.h" // for loadFile (pack + filesystem fallback)
|
||||
#include "utils/utils.h" // for color_t
|
||||
#include "utils/utils.h" // for Color
|
||||
|
||||
// Parser compartido: rellena un textFile_t desde cualquier istream
|
||||
static void parseTextFileStream(std::istream &rfile, textFile_t &tf) {
|
||||
// Parser compartido: rellena un TextFile desde cualquier istream
|
||||
static void parseTextFileStream(std::istream &rfile, TextFile &tf) {
|
||||
std::string buffer;
|
||||
std::getline(rfile, buffer);
|
||||
std::getline(rfile, buffer);
|
||||
@@ -32,22 +32,22 @@ static void parseTextFileStream(std::istream &rfile, textFile_t &tf) {
|
||||
}
|
||||
}
|
||||
|
||||
static void computeTextFileOffsets(textFile_t &tf) {
|
||||
static void computeTextFileOffsets(TextFile &tf) {
|
||||
for (int i = 32; i < 128; ++i) {
|
||||
tf.offset[i].x = ((i - 32) % 15) * tf.boxWidth;
|
||||
tf.offset[i].y = ((i - 32) / 15) * tf.boxHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// Llena una estructuta textFile_t desde un fichero (vía ResourceHelper: pack o filesystem)
|
||||
auto LoadTextFile(const std::string &file, bool verbose) -> textFile_t {
|
||||
// Llena una estructuta TextFile desde un fichero (vía ResourceHelper: pack o filesystem)
|
||||
auto LoadTextFile(const std::string &file, bool verbose) -> TextFile {
|
||||
const std::string filename = file.substr(file.find_last_of("\\/") + 1);
|
||||
auto bytes = ResourceHelper::loadFile(file);
|
||||
if (bytes.empty()) {
|
||||
if (verbose) {
|
||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << '\n';
|
||||
}
|
||||
textFile_t tf;
|
||||
TextFile tf;
|
||||
tf.boxWidth = 0;
|
||||
tf.boxHeight = 0;
|
||||
for (auto &i : tf.offset) {
|
||||
@@ -64,9 +64,9 @@ auto LoadTextFile(const std::string &file, bool verbose) -> textFile_t {
|
||||
return LoadTextFileFromMemory(bytes, verbose);
|
||||
}
|
||||
|
||||
// Llena una estructura textFile_t desde bytes en memoria
|
||||
auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose) -> textFile_t {
|
||||
textFile_t tf;
|
||||
// Llena una estructura TextFile desde bytes en memoria
|
||||
auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose) -> TextFile {
|
||||
TextFile tf;
|
||||
tf.boxWidth = 0;
|
||||
tf.boxHeight = 0;
|
||||
for (auto &i : tf.offset) {
|
||||
@@ -89,7 +89,7 @@ auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose) ->
|
||||
// Constructor
|
||||
Text::Text(const std::string &bitmapFile, const std::string &textFile, SDL_Renderer *renderer) {
|
||||
// Carga los offsets desde el fichero
|
||||
textFile_t tf = LoadTextFile(textFile);
|
||||
TextFile tf = LoadTextFile(textFile);
|
||||
|
||||
// Inicializa variables desde la estructura
|
||||
boxHeight = tf.boxHeight;
|
||||
@@ -111,7 +111,7 @@ Text::Text(const std::string &bitmapFile, const std::string &textFile, SDL_Rende
|
||||
// Constructor
|
||||
Text::Text(const std::string &textFile, Texture *texture, SDL_Renderer *renderer) {
|
||||
// Carga los offsets desde el fichero
|
||||
textFile_t tf = LoadTextFile(textFile);
|
||||
TextFile tf = LoadTextFile(textFile);
|
||||
|
||||
// Inicializa variables desde la estructura
|
||||
boxHeight = tf.boxHeight;
|
||||
@@ -131,7 +131,7 @@ Text::Text(const std::string &textFile, Texture *texture, SDL_Renderer *renderer
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer) {
|
||||
Text::Text(TextFile *textFile, Texture *texture, SDL_Renderer *renderer) {
|
||||
// Inicializa variables desde la estructura
|
||||
boxHeight = textFile->boxHeight;
|
||||
boxWidth = textFile->boxWidth;
|
||||
@@ -151,7 +151,7 @@ Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer) {
|
||||
|
||||
// Constructor desde bytes
|
||||
Text::Text(const std::vector<uint8_t> &pngBytes, const std::vector<uint8_t> &txtBytes, SDL_Renderer *renderer) {
|
||||
textFile_t tf = LoadTextFileFromMemory(txtBytes);
|
||||
TextFile tf = LoadTextFileFromMemory(txtBytes);
|
||||
boxHeight = tf.boxHeight;
|
||||
boxWidth = tf.boxWidth;
|
||||
for (int i = 0; i < 128; ++i) {
|
||||
@@ -195,14 +195,14 @@ void Text::write(int x, int y, const std::string &text, int kerning, int lenght)
|
||||
}
|
||||
|
||||
// Escribe el texto con colores
|
||||
void Text::writeColored(int x, int y, const std::string &text, color_t color, int kerning, int lenght) {
|
||||
void Text::writeColored(int x, int y, const std::string &text, Color color, int kerning, int lenght) {
|
||||
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
||||
write(x, y, text, kerning, lenght);
|
||||
sprite->getTexture()->setColor(255, 255, 255);
|
||||
}
|
||||
|
||||
// Escribe el texto con sombra
|
||||
void Text::writeShadowed(int x, int y, const std::string &text, color_t color, Uint8 shadowDistance, int kerning, int lenght) {
|
||||
void Text::writeShadowed(int x, int y, const std::string &text, Color color, Uint8 shadowDistance, int kerning, int lenght) {
|
||||
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
||||
write(x + shadowDistance, y + shadowDistance, text, kerning, lenght);
|
||||
sprite->getTexture()->setColor(255, 255, 255);
|
||||
@@ -216,7 +216,7 @@ void Text::writeCentered(int x, int y, const std::string &text, int kerning, int
|
||||
}
|
||||
|
||||
// Escribe texto con extras
|
||||
void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning, color_t textColor, Uint8 shadowDistance, color_t shadowColor, int lenght) {
|
||||
void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning, Color textColor, Uint8 shadowDistance, Color shadowColor, int lenght) {
|
||||
const bool centered = ((flags & TXT_CENTER) == TXT_CENTER);
|
||||
const bool shadowed = ((flags & TXT_SHADOW) == TXT_SHADOW);
|
||||
const bool colored = ((flags & TXT_COLOR) == TXT_COLOR);
|
||||
|
||||
@@ -15,23 +15,23 @@ constexpr int TXT_SHADOW = 2;
|
||||
constexpr int TXT_CENTER = 4;
|
||||
constexpr int TXT_STROKE = 8;
|
||||
|
||||
struct offset_t {
|
||||
struct Offset {
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
};
|
||||
|
||||
struct textFile_t {
|
||||
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
|
||||
offset_t offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||
Offset offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||
};
|
||||
|
||||
// Llena una estructuta textFile_t desde un fichero
|
||||
auto LoadTextFile(const std::string &file, bool verbose = false) -> textFile_t;
|
||||
// Llena una estructuta TextFile desde un fichero
|
||||
auto LoadTextFile(const std::string &file, bool verbose = false) -> TextFile;
|
||||
|
||||
// Llena una estructura textFile_t desde bytes en memoria
|
||||
auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose = false) -> textFile_t;
|
||||
// Llena una estructura TextFile desde bytes en memoria
|
||||
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 {
|
||||
@@ -44,13 +44,13 @@ class Text {
|
||||
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_t offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||
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_t *textFile, Texture *texture, SDL_Renderer *renderer);
|
||||
Text(TextFile *textFile, Texture *texture, SDL_Renderer *renderer);
|
||||
|
||||
// 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);
|
||||
@@ -66,16 +66,16 @@ class Text {
|
||||
void write(int x, int y, const std::string &text, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto con colores
|
||||
void writeColored(int x, int y, const std::string &text, color_t color, int kerning = 1, int lenght = -1);
|
||||
void writeColored(int x, int y, const std::string &text, Color color, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto con sombra
|
||||
void writeShadowed(int x, int y, const std::string &text, color_t color, Uint8 shadowDistance = 1, int kerning = 1, int lenght = -1);
|
||||
void writeShadowed(int x, int y, const std::string &text, Color color, Uint8 shadowDistance = 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 texto con extras
|
||||
void writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning = 1, color_t textColor = color_t(255, 255, 255), Uint8 shadowDistance = 1, color_t shadowColor = color_t(0, 0, 0), int lenght = -1);
|
||||
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);
|
||||
|
||||
// Obtiene la longitud en pixels de una cadena
|
||||
auto lenght(const std::string &text, int kerning = 1) -> int;
|
||||
|
||||
@@ -30,7 +30,7 @@ Asset::Asset(const std::string &executablePath)
|
||||
}
|
||||
|
||||
// Añade un elemento a la lista
|
||||
void Asset::add(const std::string &file, enum assetType type, bool required, bool absolute) {
|
||||
void Asset::add(const std::string &file, enum AssetType type, bool required, bool absolute) {
|
||||
item_t temp;
|
||||
temp.file = absolute ? file : executablePath + file;
|
||||
temp.type = type;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <string> // for string, basic_string
|
||||
#include <vector> // for vector
|
||||
|
||||
enum assetType : std::uint8_t {
|
||||
enum AssetType : std::uint8_t {
|
||||
t_bitmap,
|
||||
t_music,
|
||||
t_sound,
|
||||
@@ -23,7 +23,7 @@ class Asset {
|
||||
// Estructura para definir un item
|
||||
struct item_t {
|
||||
std::string file; // Ruta del fichero desde la raiz del directorio
|
||||
enum assetType type; // Indica el tipo de recurso
|
||||
enum AssetType type; // Indica el tipo de recurso
|
||||
bool required; // Indica si es un fichero que debe de existir
|
||||
};
|
||||
|
||||
@@ -53,7 +53,7 @@ class Asset {
|
||||
static auto get() -> Asset *; // Obtiene el puntero a la instancia
|
||||
|
||||
// Añade un elemento a la lista
|
||||
void add(const std::string &file, enum assetType type, bool required = true, bool absolute = false);
|
||||
void add(const std::string &file, enum AssetType type, bool required = true, bool absolute = false);
|
||||
|
||||
// Devuelve un elemento de la lista a partir de una cadena
|
||||
auto get(const std::string &text) -> std::string;
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
#include <vector> // for vector
|
||||
|
||||
#include "core/audio/audio.hpp" // for Audio::init, Audio::destroy
|
||||
#include "core/input/input.h" // for Input, inputs_e, INPUT_USE_GAME...
|
||||
#include "core/input/input.h" // for Input, InputAction, INPUT_USE_GAME...
|
||||
#include "core/input/mouse.hpp" // for Mouse::handleEvent, Mouse::upda...
|
||||
#include "core/locale/lang.h" // for Lang, MAX_LANGUAGES, ba_BA, en_UK
|
||||
#include "core/rendering/screen.h" // for Screen
|
||||
#include "core/rendering/texture.h" // for Texture
|
||||
#include "core/resources/asset.h" // for Asset, assetType
|
||||
#include "core/resources/asset.h" // for Asset, AssetType
|
||||
#include "core/resources/resource.h"
|
||||
#include "core/resources/resource_helper.h"
|
||||
#include "game/defaults.hpp" // for SECTION_PROG_LOGO, GAMECANVAS_H...
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "game/scenes/intro.h" // for Intro
|
||||
#include "game/scenes/logo.h" // for Logo
|
||||
#include "game/scenes/title.h" // for Title
|
||||
#include "utils/utils.h" // for input_t, boolToString
|
||||
#include "utils/utils.h" // for InputDevice, boolToString
|
||||
|
||||
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__)
|
||||
#include <pwd.h>
|
||||
@@ -43,7 +43,7 @@
|
||||
Director::Director(int argc, const char *argv[]) {
|
||||
std::cout << "Game start" << '\n';
|
||||
// Inicializa variables
|
||||
section = new section_t();
|
||||
section = new Section();
|
||||
section->name = SECTION_PROG_LOGO;
|
||||
|
||||
// Inicializa las opciones del programa (defaults + dispositivos d'entrada)
|
||||
@@ -630,16 +630,16 @@ auto Director::handleEvent(SDL_Event *event) -> SDL_AppResult {
|
||||
std::string name;
|
||||
if (Input::get()->handleGamepadAdded(event->gdevice.which, name)) {
|
||||
Screen::get()->notify(name + " " + Lang::get()->getText(94),
|
||||
color_t{0x40, 0xFF, 0x40},
|
||||
color_t{0, 0, 0},
|
||||
Color{0x40, 0xFF, 0x40},
|
||||
Color{0, 0, 0},
|
||||
2500);
|
||||
}
|
||||
} else if (event->type == SDL_EVENT_GAMEPAD_REMOVED) {
|
||||
std::string name;
|
||||
if (Input::get()->handleGamepadRemoved(event->gdevice.which, name)) {
|
||||
Screen::get()->notify(name + " " + Lang::get()->getText(95),
|
||||
color_t{0xFF, 0x50, 0x50},
|
||||
color_t{0, 0, 0},
|
||||
Color{0xFF, 0x50, 0x50},
|
||||
Color{0, 0, 0},
|
||||
2500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class Game;
|
||||
class Intro;
|
||||
class Logo;
|
||||
class Title;
|
||||
struct section_t;
|
||||
struct Section;
|
||||
|
||||
// Secciones activas del Director
|
||||
enum class ActiveSection : std::uint8_t { None,
|
||||
@@ -23,7 +23,7 @@ class Director {
|
||||
// Objetos y punteros
|
||||
SDL_Window *window; // La ventana donde dibujamos
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
section_t *section; // Sección y subsección actual del programa;
|
||||
Section *section; // Sección y subsección actual del programa;
|
||||
|
||||
// Secciones del juego
|
||||
ActiveSection activeSection;
|
||||
|
||||
Reference in New Issue
Block a user