neteja tidy a source/core i encamina Texture::loadFromFile pel ResourceHelper

This commit is contained in:
2026-05-14 20:22:54 +02:00
parent 88fa3f296f
commit 1912200b21
40 changed files with 699 additions and 578 deletions
+19 -18
View File
@@ -2,8 +2,9 @@
#include <SDL3/SDL.h>
#include <string> // for string, basic_string
#include <vector> // for vector
#include <cstdint> // for uint8_t
#include <string> // for string, basic_string
#include <vector> // for vector
// Valores de repetición
constexpr bool REPEAT_TRUE = true;
@@ -14,7 +15,7 @@ constexpr int INPUT_USE_KEYBOARD = 0;
constexpr int INPUT_USE_GAMECONTROLLER = 1;
constexpr int INPUT_USE_ANY = 2;
enum inputs_e {
enum inputs_e : std::uint8_t {
// Inputs obligatorios
input_null,
input_up,
@@ -43,7 +44,7 @@ enum inputs_e {
input_number_of_inputs
};
enum i_disable_e {
enum i_disable_e : std::uint8_t {
d_notDisabled,
d_forever,
d_keyPressed
@@ -69,17 +70,17 @@ class Input {
std::vector<keyBindings_t> keyBindings; // Vector con las teclas asociadas a los inputs predefinidos
std::vector<GameControllerBindings_t> gameControllerBindings; // Vector con las teclas asociadas a los inputs predefinidos
std::vector<std::string> controllerNames; // Vector con los nombres de los mandos
int numGamepads; // Numero de mandos conectados
int numGamepads{0}; // Numero de mandos conectados
std::string dbPath; // Ruta al archivo gamecontrollerdb.txt
bool verbose; // Indica si ha de mostrar mensajes
i_disable_e disabledUntil; // Tiempo que esta deshabilitado
bool enabled; // Indica si está habilitado
bool verbose{true}; // Indica si ha de mostrar mensajes
i_disable_e 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)
std::string buildControllerName(SDL_Gamepad *pad, int padIndex);
static auto buildControllerName(SDL_Gamepad *pad, int padIndex) -> std::string;
// Constructor privado (usar Input::init)
explicit Input(const std::string &file);
explicit Input(std::string file);
// Instancia única
static Input *instance;
@@ -103,30 +104,30 @@ class Input {
void bindGameControllerButton(Uint8 input, SDL_GamepadButton button);
// Comprueba si un input esta activo
bool checkInput(Uint8 input, bool repeat = true, int device = INPUT_USE_ANY, int index = 0);
auto checkInput(Uint8 input, bool repeat = true, int device = INPUT_USE_ANY, int index = 0) -> bool;
// Comprueba si hay almenos un input activo
bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0);
auto checkAnyInput(int device = INPUT_USE_ANY, int index = 0) -> bool;
// Busca si hay un mando conectado
bool discoverGameController();
auto discoverGameController() -> bool;
// Procesa un evento SDL_EVENT_GAMEPAD_ADDED. Devuelve true si el mando se ha añadido
// (no estaba ya registrado) y escribe el nombre visible en outName.
bool handleGamepadAdded(SDL_JoystickID jid, std::string &outName);
auto handleGamepadAdded(SDL_JoystickID jid, std::string &outName) -> bool;
// Procesa un evento SDL_EVENT_GAMEPAD_REMOVED. Devuelve true si se ha encontrado y
// eliminado, y escribe el nombre visible en outName.
bool handleGamepadRemoved(SDL_JoystickID jid, std::string &outName);
auto handleGamepadRemoved(SDL_JoystickID jid, std::string &outName) -> bool;
// Comprueba si hay algun mando conectado
bool gameControllerFound();
[[nodiscard]] auto gameControllerFound() const -> bool;
// Obten el numero de mandos conectados
int getNumControllers();
[[nodiscard]] auto getNumControllers() const -> int;
// Obten el nombre de un mando de juego
std::string getControllerName(int index);
auto getControllerName(int index) -> std::string;
// Establece si ha de mostrar mensajes
void setVerbose(bool value);