fix: enum class amb base std::uint8_t (33 troballes)

This commit is contained in:
2026-05-14 22:32:57 +02:00
parent 058f7b118a
commit ac93cfa7d7
35 changed files with 120 additions and 113 deletions

View File

@@ -24,14 +24,14 @@ struct SDLFreeDeleter {
}; };
// --- Public Enums --- // --- Public Enums ---
enum JA_Channel_state { enum JA_Channel_state : uint8_t {
JA_CHANNEL_INVALID, JA_CHANNEL_INVALID,
JA_CHANNEL_FREE, JA_CHANNEL_FREE,
JA_CHANNEL_PLAYING, JA_CHANNEL_PLAYING,
JA_CHANNEL_PAUSED, JA_CHANNEL_PAUSED,
JA_SOUND_DISABLED, JA_SOUND_DISABLED,
}; };
enum JA_Music_state { enum JA_Music_state : uint8_t {
JA_MUSIC_INVALID, JA_MUSIC_INVALID,
JA_MUSIC_PLAYING, JA_MUSIC_PLAYING,
JA_MUSIC_PAUSED, JA_MUSIC_PAUSED,

View File

@@ -2,9 +2,9 @@
#include <SDL3/SDL.h> // Para SDL_GetGamepadAxis, SDL_GamepadAxis, SDL_GamepadButton, SDL_GetError, SDL_JoystickID, SDL_AddGamepadMappingsFromFile, SDL_Event, SDL_EventType, SDL_GetGamepadButton, SDL_GetKeyboardState, SDL_INIT_GAMEPAD, SDL_InitSubSystem, SDL_LogError, SDL_OpenGamepad, SDL_PollEvent, SDL_WasInit, Sint16, SDL_Gamepad, SDL_LogCategory, SDL_Scancode #include <SDL3/SDL.h> // Para SDL_GetGamepadAxis, SDL_GamepadAxis, SDL_GamepadButton, SDL_GetError, SDL_JoystickID, SDL_AddGamepadMappingsFromFile, SDL_Event, SDL_EventType, SDL_GetGamepadButton, SDL_GetKeyboardState, SDL_INIT_GAMEPAD, SDL_InitSubSystem, SDL_LogError, SDL_OpenGamepad, SDL_PollEvent, SDL_WasInit, Sint16, SDL_Gamepad, SDL_LogCategory, SDL_Scancode
#include <algorithm> // Para ranges::any_of
#include <iostream> // Para basic_ostream, operator<<, cout, cerr #include <iostream> // Para basic_ostream, operator<<, cout, cerr
#include <memory> // Para shared_ptr, __shared_ptr_access, allocator, operator==, make_shared #include <memory> // Para shared_ptr, __shared_ptr_access, allocator, operator==, make_shared
#include <algorithm> // Para ranges::any_of
#include <ranges> // Para __find_if_fn, find_if #include <ranges> // Para __find_if_fn, find_if
#include <unordered_map> // Para unordered_map, _Node_iterator, operator==, _Node_iterator_base, _Node_const_iterator #include <unordered_map> // Para unordered_map, _Node_iterator, operator==, _Node_iterator_base, _Node_const_iterator
#include <utility> // Para pair, move #include <utility> // Para pair, move
@@ -184,8 +184,7 @@ auto Input::checkAnyInput(bool check_keyboard, const std::shared_ptr<Gamepad>& g
// --- Comprobación del Teclado --- // --- Comprobación del Teclado ---
// Llegim l'estat pre-calculat per Input::update() (sense tornar a cridar SDL_GetKeyboardState). // Llegim l'estat pre-calculat per Input::update() (sense tornar a cridar SDL_GetKeyboardState).
if (check_keyboard && std::ranges::any_of(keyboard_.bindings, if (check_keyboard && std::ranges::any_of(keyboard_.bindings, [](const auto& pair) { return pair.second.just_pressed; })) {
[](const auto& pair) { return pair.second.just_pressed; })) {
return true; return true;
} }
@@ -197,8 +196,7 @@ auto Input::checkAnyInput(bool check_keyboard, const std::shared_ptr<Gamepad>& g
// --- Comprobación del Mando --- // --- Comprobación del Mando ---
// Iterem sobre totes les accions del mandos pre-calculades per Input::update(). // Iterem sobre totes les accions del mandos pre-calculades per Input::update().
if (active_gamepad != nullptr && std::ranges::any_of(active_gamepad->bindings, if (active_gamepad != nullptr && std::ranges::any_of(active_gamepad->bindings, [](const auto& pair) { return pair.second.just_pressed; })) {
[](const auto& pair) { return pair.second.just_pressed; })) {
return true; return true;
} }
@@ -230,8 +228,7 @@ auto Input::getControllerName(const std::shared_ptr<Gamepad>& gamepad) -> std::s
auto Input::getControllerNames() const -> std::vector<std::string> { auto Input::getControllerNames() const -> std::vector<std::string> {
std::vector<std::string> names; std::vector<std::string> names;
names.reserve(gamepads_.size()); names.reserve(gamepads_.size());
std::ranges::transform(gamepads_, std::back_inserter(names), std::ranges::transform(gamepads_, std::back_inserter(names), [](const auto& gamepad) { return gamepad->name; });
[](const auto& gamepad) { return gamepad->name; });
return names; return names;
} }

View File

@@ -2,11 +2,12 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <cstdint>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
// --- Enums --- // --- Enums ---
enum class InputAction : int { // Acciones de entrada posibles en el juego enum class InputAction : std::uint8_t { // Acciones de entrada posibles en el juego
// Inputs de movimiento // Inputs de movimiento
LEFT, LEFT,
RIGHT, RIGHT,

View File

@@ -3,6 +3,7 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <array> #include <array>
#include <cstdint>
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <string> #include <string>
@@ -14,7 +15,7 @@ using Palette = std::array<Uint32, 256>;
class Surface; class Surface;
// Modo de ordenación de paletas // Modo de ordenación de paletas
enum class PaletteSortMode : int { enum class PaletteSortMode : std::uint8_t {
ORIGINAL = 0, // Paleta tal cual viene del fichero ORIGINAL = 0, // Paleta tal cual viene del fichero
LUMINANCE = 1, // Ordenada por luminancia percibida LUMINANCE = 1, // Ordenada por luminancia percibida
SPECTRUM = 2, // Reordenada para imitar la paleta ZX Spectrum SPECTRUM = 2, // Reordenada para imitar la paleta ZX Spectrum

View File

@@ -1,7 +1,8 @@
#pragma once #pragma once
#include <memory> // Para shared_ptr #include <cstdint> // Para uint8_t
#include <vector> // Para vector #include <memory> // Para shared_ptr
#include <vector> // Para vector
class Surface; class Surface;
@@ -10,7 +11,7 @@ class Surface;
class PixelReveal { class PixelReveal {
public: public:
// Modo de revelado: aleatorio por fila o en orden de bisección (dithering ordenado 1D) // Modo de revelado: aleatorio por fila o en orden de bisección (dithering ordenado 1D)
enum class RevealMode { RANDOM, enum class RevealMode : std::uint8_t { RANDOM,
ORDERED }; ORDERED };
// Constructor // Constructor

View File

@@ -1,5 +1,7 @@
#pragma once #pragma once
#include <cstdint> // Para uint8_t
class RenderInfo { class RenderInfo {
public: public:
// Singleton // Singleton
@@ -20,7 +22,7 @@ class RenderInfo {
static constexpr float SLIDE_SPEED = 120.0F; static constexpr float SLIDE_SPEED = 120.0F;
private: private:
enum class Status { HIDDEN, enum class Status : std::uint8_t { HIDDEN,
RISING, RISING,
ACTIVE, ACTIVE,
VANISHING }; VANISHING };

View File

@@ -4,6 +4,7 @@
#include <SDL3/SDL_pixels.h> // Para Uint32 #include <SDL3/SDL_pixels.h> // Para Uint32
#include <cstddef> // Para size_t #include <cstddef> // Para size_t
#include <cstdint> // Para uint8_t
#include <memory> // Para shared_ptr, __shared_ptr_access #include <memory> // Para shared_ptr, __shared_ptr_access
#include <string> // Para string #include <string> // Para string
#include <utility> // Para std::pair #include <utility> // Para std::pair
@@ -18,7 +19,7 @@ class Text;
class Screen { class Screen {
public: public:
// Tipos de filtro // Tipos de filtro
enum class Filter : Uint32 { enum class Filter : std::uint8_t {
NEAREST = 0, NEAREST = 0,
LINEAR = 1, LINEAR = 1,
}; };

View File

@@ -2,13 +2,14 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <cstdint>
#include <string> #include <string>
#include <utility> #include <utility>
namespace Rendering { namespace Rendering {
/** @brief Identificador del shader de post-procesado activo */ /** @brief Identificador del shader de post-procesado activo */
enum class ShaderType { POSTFX, enum class ShaderType : std::uint8_t { POSTFX,
CRTPI }; CRTPI };
/** /**

View File

@@ -2,14 +2,15 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <cstdint> // Para uint8_t
#include <memory> // Para shared_ptr
#include "core/rendering/sprite/animated_sprite.hpp" // Para SurfaceAnimatedSprite #include "core/rendering/sprite/animated_sprite.hpp" // Para SurfaceAnimatedSprite
class Surface; class Surface;
// Direcció de la dissolució // Direcció de la dissolució
enum class DissolveDirection { NONE, enum class DissolveDirection : std::uint8_t { NONE,
DOWN, DOWN,
UP }; UP };
@@ -41,7 +42,7 @@ class DissolveSprite : public AnimatedSprite {
void setColorReplace(Uint8 source, Uint8 target); void setColorReplace(Uint8 source, Uint8 target);
private: private:
enum class TransitionMode { NONE, enum class TransitionMode : std::uint8_t { NONE,
DISSOLVING, DISSOLVING,
GENERATING }; GENERATING };

View File

@@ -1,7 +1,8 @@
#pragma once #pragma once
#include <memory> // Para shared_ptr #include <cstdint> // Para uint8_t
#include <string> // Para string #include <memory> // Para shared_ptr
#include <string> // Para string
#include <utility> #include <utility>
#include <vector> // Para vector #include <vector> // Para vector
@@ -54,7 +55,7 @@ namespace Resource {
}; };
// Etapas del loader incremental // Etapas del loader incremental
enum class LoadStage { enum class LoadStage : std::uint8_t {
SOUNDS, SOUNDS,
MUSICS, MUSICS,
SURFACES, SURFACES,

View File

@@ -12,7 +12,7 @@ namespace Resource {
class List { class List {
public: public:
// --- Enums --- // --- Enums ---
enum class Type : int { enum class Type : std::uint8_t {
DATA, // Datos DATA, // Datos
BITMAP, // Imágenes BITMAP, // Imágenes
ANIMATION, // Animaciones ANIMATION, // Animaciones

View File

@@ -6,19 +6,18 @@
#include <SDL3/SDL_filesystem.h> #include <SDL3/SDL_filesystem.h>
#include <algorithm> #include <algorithm>
#include <numeric>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <numeric>
namespace Resource { namespace Resource {
// Calculate CRC32 checksum for data verification // Calculate CRC32 checksum for data verification
auto Pack::calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t { // NOLINT(readability-convert-member-functions-to-static) auto Pack::calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t { // NOLINT(readability-convert-member-functions-to-static)
return std::accumulate(data.begin(), data.end(), uint32_t{0x12345678}, return std::accumulate(data.begin(), data.end(), uint32_t{0x12345678}, [](uint32_t acc, unsigned char byte) -> uint32_t {
[](uint32_t acc, unsigned char byte) -> uint32_t { return ((acc << 5) + acc) + byte;
return ((acc << 5) + acc) + byte; });
});
} }
// XOR encryption (symmetric - same function for encrypt/decrypt) // XOR encryption (symmetric - same function for encrypt/decrypt)

View File

@@ -61,7 +61,8 @@ namespace {
} // namespace } // namespace
// Constructor // Constructor
Director::Director() : executable_path_(getExecutablePath()) { Director::Director()
: executable_path_(getExecutablePath()) {
std::cout << "Game start" << '\n'; std::cout << "Game start" << '\n';
// Crea la carpeta del sistema donde guardar datos // Crea la carpeta del sistema donde guardar datos

View File

@@ -2,10 +2,11 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <array> // Para array #include <array> // Para array
#include <limits> // Para numeric_limits #include <cstdint> // Para uint8_t
#include <memory> // Para shared_ptr, __shared_ptr_access #include <limits> // Para numeric_limits
#include <string> // Para string #include <memory> // Para shared_ptr, __shared_ptr_access
#include <string> // Para string
#include <utility> #include <utility>
#include "core/rendering/sprite/animated_sprite.hpp" // Para SAnimatedSprite #include "core/rendering/sprite/animated_sprite.hpp" // Para SAnimatedSprite
@@ -18,14 +19,14 @@ struct JA_Sound_t; // lines 13-13
class Player { class Player {
public: public:
// --- Enums y Structs --- // --- Enums y Structs ---
enum class State { enum class State : std::uint8_t {
ON_GROUND, // En suelo plano o conveyor belt ON_GROUND, // En suelo plano o conveyor belt
ON_SLOPE, // En rampa/pendiente ON_SLOPE, // En rampa/pendiente
JUMPING, JUMPING,
FALLING, FALLING,
}; };
enum class Direction { enum class Direction : std::uint8_t {
LEFT, LEFT,
RIGHT, RIGHT,
UP, UP,

View File

@@ -2,7 +2,8 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <vector> // Para vector #include <cstdint> // Para uint8_t
#include <vector> // Para vector
#include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical #include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical
@@ -18,7 +19,7 @@
class CollisionMap { class CollisionMap {
public: public:
// Enumeración de tipos de tile (para colisiones) // Enumeración de tipos de tile (para colisiones)
enum class Tile { enum class Tile : std::uint8_t {
EMPTY, EMPTY,
WALL, WALL,
PASSABLE, PASSABLE,

View File

@@ -2,9 +2,10 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <cstdint> // Para uint8_t
#include <string> // Para string #include <memory> // Para shared_ptr
#include <vector> // Para vector #include <string> // Para string
#include <vector> // Para vector
#include "game/entities/enemy.hpp" // Para EnemyData #include "game/entities/enemy.hpp" // Para EnemyData
#include "game/entities/item.hpp" // Para ItemData #include "game/entities/item.hpp" // Para ItemData
@@ -20,7 +21,7 @@ class TilemapRenderer;
class Room { class Room {
public: public:
// -- Enumeraciones y estructuras --- // -- Enumeraciones y estructuras ---
enum class Border : int { enum class Border : std::uint8_t {
TOP = 0, TOP = 0,
RIGHT = 1, RIGHT = 1,
BOTTOM = 2, BOTTOM = 2,
@@ -28,7 +29,7 @@ class Room {
NONE = 4 NONE = 4
}; };
enum class Tile { enum class Tile : std::uint8_t {
EMPTY, EMPTY,
WALL, WALL,
PASSABLE, PASSABLE,

View File

@@ -133,8 +133,7 @@ void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const
for (const auto& row_node : tilemap_node) { for (const auto& row_node : tilemap_node) {
std::vector<int> row; std::vector<int> row;
row.reserve(32); row.reserve(32);
std::ranges::transform(row_node, std::back_inserter(row), std::ranges::transform(row_node, std::back_inserter(row), [](const auto& tile_node) { return tile_node.template get_value<int>(); });
[](const auto& tile_node) { return tile_node.template get_value<int>(); });
tilemap_2d.push_back(std::move(row)); tilemap_2d.push_back(std::move(row));
} }

View File

@@ -37,8 +37,7 @@ Scoreboard::Scoreboard(std::shared_ptr<Data> data)
// Inicializa el vector de colores // Inicializa el vector de colores
const std::vector<std::string> COLORS = {"blue", "magenta", "green", "cyan", "yellow", "white", "bright_blue", "bright_magenta", "bright_green", "bright_cyan", "bright_yellow", "bright_white"}; const std::vector<std::string> COLORS = {"blue", "magenta", "green", "cyan", "yellow", "white", "bright_blue", "bright_magenta", "bright_green", "bright_cyan", "bright_yellow", "bright_white"};
color_.reserve(COLORS.size()); color_.reserve(COLORS.size());
std::ranges::transform(COLORS, std::back_inserter(color_), std::ranges::transform(COLORS, std::back_inserter(color_), [](const auto& color) { return stringToColor(color); });
[](const auto& color) { return stringToColor(color); });
} }
// Pinta el objeto en pantalla // Pinta el objeto en pantalla

View File

@@ -1,5 +1,7 @@
#pragma once #pragma once
#include <cstdint> // Para uint8_t
/* /*
Namespace SceneManager: gestiona el flujo entre las diferentes escenas del juego. Namespace SceneManager: gestiona el flujo entre las diferentes escenas del juego.
@@ -10,7 +12,7 @@
namespace SceneManager { namespace SceneManager {
// --- Escenas del programa --- // --- Escenas del programa ---
enum class Scene { enum class Scene : std::uint8_t {
BOOT_LOADER, // Carga inicial de recursos dirigida por iterate() BOOT_LOADER, // Carga inicial de recursos dirigida por iterate()
LOGO, // Pantalla del logo LOGO, // Pantalla del logo
LOADING_SCREEN, // Pantalla de carga LOADING_SCREEN, // Pantalla de carga
@@ -26,7 +28,7 @@ namespace SceneManager {
}; };
// --- Opciones para transiciones entre escenas --- // --- Opciones para transiciones entre escenas ---
enum class Options { enum class Options : std::uint8_t {
NONE, // Sin opciones especiales NONE, // Sin opciones especiales
LOGO_TO_LOADING_SCREEN, // Del logo a la intro LOGO_TO_LOADING_SCREEN, // Del logo a la intro
LOGO_TO_TITLE, // Del logo al título LOGO_TO_TITLE, // Del logo al título

View File

@@ -2,9 +2,10 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <cstdint> // Para uint8_t
#include <string> // Para string #include <memory> // Para shared_ptr
#include <vector> // Para vector #include <string> // Para string
#include <vector> // Para vector
#include "game/scenes/scene.hpp" // Para Scene #include "game/scenes/scene.hpp" // Para Scene
class AnimatedSprite; // lines 11-11 class AnimatedSprite; // lines 11-11
@@ -24,7 +25,7 @@ class Credits : public Scene {
private: private:
// --- Tipos anidados --- // --- Tipos anidados ---
enum class State { enum class State : std::uint8_t {
REVEALING_TEXT, REVEALING_TEXT,
PAUSE_1, PAUSE_1,
REVEALING_TEXT_2, REVEALING_TEXT_2,

View File

@@ -2,9 +2,10 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <cstdint> // Para uint8_t
#include <string> // Para string #include <memory> // Para shared_ptr
#include <vector> // Para vector #include <string> // Para string
#include <vector> // Para vector
#include "game/scenes/scene.hpp" // Para Scene #include "game/scenes/scene.hpp" // Para Scene
class Sprite; // lines 8-8 class Sprite; // lines 8-8
@@ -24,7 +25,7 @@ class Ending : public Scene {
private: private:
// --- Enumeraciones --- // --- Enumeraciones ---
enum class State { enum class State : std::uint8_t {
WARMING_UP, WARMING_UP,
SCENE_0, SCENE_0,
SCENE_1, SCENE_1,

View File

@@ -32,8 +32,7 @@ Ending2::Ending2()
// Inicializa el vector de colores // Inicializa el vector de colores
const std::vector<std::string> COLORS = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"}; const std::vector<std::string> COLORS = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"};
colors_.reserve(COLORS.size()); colors_.reserve(COLORS.size());
std::ranges::transform(COLORS, std::back_inserter(colors_), std::ranges::transform(COLORS, std::back_inserter(colors_), [](const auto& color) { return stringToColor(color); });
[](const auto& color) { return stringToColor(color); });
Screen::get()->setBorderColor(static_cast<Uint8>(PaletteColor::BLACK)); // Cambia el color del borde Screen::get()->setBorderColor(static_cast<Uint8>(PaletteColor::BLACK)); // Cambia el color del borde
iniSpriteList(); // Inicializa la lista de sprites iniSpriteList(); // Inicializa la lista de sprites

View File

@@ -2,9 +2,10 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <cstdint> // Para uint8_t
#include <string> // Para string #include <memory> // Para shared_ptr
#include <vector> // Para vector #include <string> // Para string
#include <vector> // Para vector
#include "core/rendering/sprite/dissolve_sprite.hpp" // Para SurfaceDissolveSprite #include "core/rendering/sprite/dissolve_sprite.hpp" // Para SurfaceDissolveSprite
#include "game/scenes/scene.hpp" // Para Scene #include "game/scenes/scene.hpp" // Para Scene
@@ -25,7 +26,7 @@ class Ending2 : public Scene {
private: private:
// --- Enumeraciones --- // --- Enumeraciones ---
enum class EndingState : int { enum class EndingState : std::uint8_t {
PRE_CREDITS, // Estado previo a los créditos PRE_CREDITS, // Estado previo a los créditos
CREDITS, // Estado de los créditos CREDITS, // Estado de los créditos
POST_CREDITS, // Estado posterior a los créditos POST_CREDITS, // Estado posterior a los créditos

View File

@@ -2,7 +2,7 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <cmath> // Para std::sqrt, std::min #include <cmath> // Para std::sqrt, std::min
#include <numeric> // Para std::accumulate #include <numeric> // Para std::accumulate
#include <utility> #include <utility>
#include <vector> // Para vector #include <vector> // Para vector
@@ -867,8 +867,7 @@ auto Game::checkEndGame() -> bool {
// Obtiene la cantidad total de items que hay en el mapeado del juego // Obtiene la cantidad total de items que hay en el mapeado del juego
auto Game::getTotalItems() -> int { auto Game::getTotalItems() -> int {
const auto& rooms = Resource::Cache::get()->getRooms(); const auto& rooms = Resource::Cache::get()->getRooms();
return static_cast<int>(std::accumulate(rooms.begin(), rooms.end(), size_t{0}, return static_cast<int>(std::accumulate(rooms.begin(), rooms.end(), size_t{0}, [](size_t acc, const auto& room) { return acc + room.room->items.size(); }));
[](size_t acc, const auto& room) { return acc + room.room->items.size(); }));
} }
// Pone el juego en pausa // Pone el juego en pausa

View File

@@ -2,6 +2,7 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <cstdint> // Para uint8_t
#include <initializer_list> // Para initializer_list #include <initializer_list> // Para initializer_list
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
#include <string> // Para string #include <string> // Para string
@@ -19,12 +20,12 @@ class Surface;
class Game : public Scene { class Game : public Scene {
public: public:
// --- Estructuras --- // --- Estructuras ---
enum class Mode { enum class Mode : std::uint8_t {
DEMO, DEMO,
GAME GAME
}; };
enum class State { enum class State : std::uint8_t {
PLAYING, // Normal gameplay PLAYING, // Normal gameplay
BLACK_SCREEN, // Black screen after death (0.30s) BLACK_SCREEN, // Black screen after death (0.30s)
GAME_OVER, // Intermediate state before changing scene GAME_OVER, // Intermediate state before changing scene

View File

@@ -39,8 +39,7 @@ GameOver::GameOver()
// Inicializa el vector de colores (de brillante a oscuro para fade) // Inicializa el vector de colores (de brillante a oscuro para fade)
const std::vector<std::string> COLORS = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"}; const std::vector<std::string> COLORS = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"};
colors_.reserve(COLORS.size()); colors_.reserve(COLORS.size());
std::ranges::transform(COLORS, std::back_inserter(colors_), std::ranges::transform(COLORS, std::back_inserter(colors_), [](const auto& color) { return stringToColor(color); });
[](const auto& color) { return stringToColor(color); });
color_ = colors_.back(); // Empieza en black color_ = colors_.back(); // Empieza en black
} }

View File

@@ -2,8 +2,9 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <cstdint> // Para uint8_t
#include <vector> // Para vector #include <memory> // Para shared_ptr
#include <vector> // Para vector
#include "game/scenes/scene.hpp" // Para Scene #include "game/scenes/scene.hpp" // Para Scene
class AnimatedSprite; // lines 7-7 class AnimatedSprite; // lines 7-7
@@ -21,7 +22,7 @@ class GameOver : public Scene {
private: private:
// --- Enumeraciones --- // --- Enumeraciones ---
enum class State { enum class State : std::uint8_t {
WAITING, // Espera inicial antes de empezar WAITING, // Espera inicial antes de empezar
FADE_IN, // Fade in de colores desde black FADE_IN, // Fade in de colores desde black
DISPLAY, // Mostrando contenido con color brillante DISPLAY, // Mostrando contenido con color brillante

View File

@@ -2,8 +2,9 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <array> // Para std::array #include <array> // Para std::array
#include <memory> // Para shared_ptr #include <cstdint> // Para uint8_t
#include <memory> // Para shared_ptr
#include "game/scenes/scene.hpp" // Para Scene #include "game/scenes/scene.hpp" // Para Scene
#include "utils/delta_timer.hpp" // Para DeltaTimer #include "utils/delta_timer.hpp" // Para DeltaTimer
@@ -24,7 +25,7 @@ class LoadingScreen : public Scene {
private: private:
// --- Enumeraciones --- // --- Enumeraciones ---
// Estados de la secuencia de carga // Estados de la secuencia de carga
enum class State { enum class State : std::uint8_t {
SILENT1, // Pausa inicial antes de empezar SILENT1, // Pausa inicial antes de empezar
HEADER1, // Cabecera HEADER1, // Cabecera
DATA1, // Datos DATA1, // Datos
@@ -37,7 +38,7 @@ class LoadingScreen : public Scene {
}; };
// Tipos de borde para la pantalla de carga // Tipos de borde para la pantalla de carga
enum class Border { enum class Border : std::uint8_t {
NONE, NONE,
YELLOW_AND_BLUE, YELLOW_AND_BLUE,
RED_AND_CYAN, RED_AND_CYAN,

View File

@@ -2,6 +2,7 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <cstdint> // Para uint8_t
#include <functional> // Para std::function #include <functional> // Para std::function
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
#include <vector> // Para vector #include <vector> // Para vector
@@ -17,7 +18,7 @@ class Logo : public Scene {
using EasingFunction = std::function<float(float)>; // Función de easing (permite lambdas) using EasingFunction = std::function<float(float)>; // Función de easing (permite lambdas)
// --- Enumeraciones --- // --- Enumeraciones ---
enum class State { enum class State : std::uint8_t {
INITIAL, // Espera inicial INITIAL, // Espera inicial
JAILGAMES_SLIDE_IN, // Las líneas de JAILGAMES se deslizan hacia el centro JAILGAMES_SLIDE_IN, // Las líneas de JAILGAMES se deslizan hacia el centro
SINCE_1998_FADE_IN, // Aparición gradual del texto "Since 1998" SINCE_1998_FADE_IN, // Aparición gradual del texto "Since 1998"

View File

@@ -2,10 +2,11 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <array> // Para std::array #include <array> // Para std::array
#include <memory> // Para shared_ptr #include <cstdint> // Para uint8_t
#include <string> // Para string #include <memory> // Para shared_ptr
#include <vector> // Para vector #include <string> // Para string
#include <vector> // Para vector
#include "game/scene_manager.hpp" // Para SceneManager::Scene #include "game/scene_manager.hpp" // Para SceneManager::Scene
#include "game/scenes/scene.hpp" // Para Scene #include "game/scenes/scene.hpp" // Para Scene
@@ -34,7 +35,7 @@ class Title : public Scene {
bool enabled{false}; // Solo se escriben y mueven si estan habilitadas bool enabled{false}; // Solo se escriben y mueven si estan habilitadas
}; };
enum class State { enum class State : std::uint8_t {
SHOW_LOADING_SCREEN, SHOW_LOADING_SCREEN,
FADE_LOADING_SCREEN, FADE_LOADING_SCREEN,
MAIN_MENU, MAIN_MENU,

View File

@@ -3,8 +3,8 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <algorithm> // Para ranges::transform #include <algorithm> // Para ranges::transform
#include <numeric> // Para std::accumulate
#include <cctype> // Para toupper #include <cctype> // Para toupper
#include <numeric> // Para std::accumulate
#include <sstream> // Para std::istringstream #include <sstream> // Para std::istringstream
#include <string> // Para string #include <string> // Para string
#include <vector> // Para vector #include <vector> // Para vector
@@ -182,8 +182,7 @@ void Console::update(float delta_time) { // NOLINT(readability-function-cogniti
// Efecto typewriter: revelar letras una a una (solo cuando ACTIVE) // Efecto typewriter: revelar letras una a una (solo cuando ACTIVE)
if (status_ == Status::ACTIVE) { if (status_ == Status::ACTIVE) {
const int total_chars = std::accumulate(msg_lines_.begin(), msg_lines_.end(), 0, const int total_chars = std::accumulate(msg_lines_.begin(), msg_lines_.end(), 0, [](int acc, const auto& line) { return acc + static_cast<int>(line.size()); });
[](int acc, const auto& line) { return acc + static_cast<int>(line.size()); });
if (typewriter_chars_ < total_chars) { if (typewriter_chars_ < total_chars) {
typewriter_timer_ += delta_time; typewriter_timer_ += delta_time;
while (typewriter_timer_ >= TYPEWRITER_CHAR_DELAY && typewriter_chars_ < total_chars) { while (typewriter_timer_ >= TYPEWRITER_CHAR_DELAY && typewriter_chars_ < total_chars) {
@@ -339,8 +338,7 @@ void Console::handleEvent(const SDL_Event& event) { // NOLINT(readability-funct
if (SPACE_POS == std::string::npos) { if (SPACE_POS == std::string::npos) {
// Modo comando: ciclar keywords visibles que empiecen por el prefijo // Modo comando: ciclar keywords visibles que empiecen por el prefijo
const auto KEYWORDS = registry_.getVisibleKeywords(); const auto KEYWORDS = registry_.getVisibleKeywords();
std::ranges::copy_if(KEYWORDS, std::back_inserter(tab_matches_), std::ranges::copy_if(KEYWORDS, std::back_inserter(tab_matches_), [&upper](const auto& kw) { return upper.empty() || kw.starts_with(upper); });
[&upper](const auto& kw) { return upper.empty() || kw.starts_with(upper); });
} else { } else {
const std::string BASE_CMD = upper.substr(0, SPACE_POS); const std::string BASE_CMD = upper.substr(0, SPACE_POS);
const std::string SUB_PREFIX = upper.substr(SPACE_POS + 1); const std::string SUB_PREFIX = upper.substr(SPACE_POS + 1);
@@ -356,8 +354,7 @@ void Console::handleEvent(const SDL_Event& event) { // NOLINT(readability-funct
if (tab_matches_.empty()) { break; } if (tab_matches_.empty()) { break; }
tab_index_ = (tab_index_ + 1) % static_cast<int>(tab_matches_.size()); tab_index_ = (tab_index_ + 1) % static_cast<int>(tab_matches_.size());
std::string result = tab_matches_[static_cast<size_t>(tab_index_)]; std::string result = tab_matches_[static_cast<size_t>(tab_index_)];
std::ranges::transform(result, result.begin(), std::ranges::transform(result, result.begin(), [](char c) { return static_cast<char>(std::tolower(static_cast<unsigned char>(c))); });
[](char c) { return static_cast<char>(std::tolower(static_cast<unsigned char>(c))); });
input_line_ = result; input_line_ = result;
break; break;
} }
@@ -403,8 +400,7 @@ void Console::processCommand() {
// Typewriter: instantáneo si el comando lo requiere, letra a letra si no // Typewriter: instantáneo si el comando lo requiere, letra a letra si no
if (instant) { if (instant) {
typewriter_chars_ = std::accumulate(msg_lines_.begin(), msg_lines_.end(), 0, typewriter_chars_ = std::accumulate(msg_lines_.begin(), msg_lines_.end(), 0, [](int acc, const auto& l) { return acc + static_cast<int>(l.size()); });
[](int acc, const auto& l) { return acc + static_cast<int>(l.size()); });
} else { } else {
typewriter_chars_ = 0; typewriter_chars_ = 0;
} }

View File

@@ -2,6 +2,7 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <cstdint> // Para uint8_t
#include <deque> // Para deque (historial) #include <deque> // Para deque (historial)
#include <functional> // Para function #include <functional> // Para function
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
@@ -43,7 +44,7 @@ class Console {
std::function<void(bool)> on_toggle; std::function<void(bool)> on_toggle;
private: private:
enum class Status { enum class Status : std::uint8_t {
HIDDEN, HIDDEN,
RISING, RISING,
ACTIVE, ACTIVE,

View File

@@ -1013,8 +1013,7 @@ void CommandRegistry::registerHandlers() { // NOLINT(readability-function-cogni
std::vector<std::string> result = {"NEXT", "PREV", "SORT", "DEFAULT"}; std::vector<std::string> result = {"NEXT", "PREV", "SORT", "DEFAULT"};
if (Screen::get() != nullptr) { if (Screen::get() != nullptr) {
const auto NAMES = Screen::get()->getPaletteNames(); const auto NAMES = Screen::get()->getPaletteNames();
std::ranges::transform(NAMES, std::back_inserter(result), std::ranges::transform(NAMES, std::back_inserter(result), [](const auto& name) { return toUpper(name); });
[](const auto& name) { return toUpper(name); });
} }
return result; return result;
}; };
@@ -1120,8 +1119,7 @@ void CommandRegistry::load(const std::string& yaml_path) { // NOLINT(readabilit
if (cat_node.contains("scope")) { if (cat_node.contains("scope")) {
const auto& scope_node = cat_node["scope"]; const auto& scope_node = cat_node["scope"];
if (scope_node.is_sequence()) { if (scope_node.is_sequence()) {
std::ranges::transform(scope_node, std::back_inserter(cat_scopes), std::ranges::transform(scope_node, std::back_inserter(cat_scopes), [](const auto& s) { return s.template get_value<std::string>(); });
[](const auto& s) { return s.template get_value<std::string>(); });
} else { } else {
cat_scopes.push_back(scope_node.get_value<std::string>()); cat_scopes.push_back(scope_node.get_value<std::string>());
} }
@@ -1162,8 +1160,7 @@ void CommandRegistry::load(const std::string& yaml_path) { // NOLINT(readabilit
for (auto it = completions_node.begin(); it != completions_node.end(); ++it) { for (auto it = completions_node.begin(); it != completions_node.end(); ++it) {
auto path = it.key().get_value<std::string>(); auto path = it.key().get_value<std::string>();
std::vector<std::string> opts; std::vector<std::string> opts;
std::ranges::transform(*it, std::back_inserter(opts), std::ranges::transform(*it, std::back_inserter(opts), [](const auto& opt) { return opt.template get_value<std::string>(); });
[](const auto& opt) { return opt.template get_value<std::string>(); });
def.completions[path] = std::move(opts); def.completions[path] = std::move(opts);
} }
} }
@@ -1182,8 +1179,7 @@ void CommandRegistry::load(const std::string& yaml_path) { // NOLINT(readabilit
for (auto it = extras_completions.begin(); it != extras_completions.end(); ++it) { for (auto it = extras_completions.begin(); it != extras_completions.end(); ++it) {
auto path = it.key().get_value<std::string>(); auto path = it.key().get_value<std::string>();
std::vector<std::string> opts; std::vector<std::string> opts;
std::ranges::transform(*it, std::back_inserter(opts), std::ranges::transform(*it, std::back_inserter(opts), [](const auto& opt) { return opt.template get_value<std::string>(); });
[](const auto& opt) { return opt.template get_value<std::string>(); });
def.completions[path] = std::move(opts); def.completions[path] = std::move(opts);
} }
} }

View File

@@ -306,7 +306,6 @@ auto Notifier::getVisibleHeight() const -> int {
auto Notifier::getCodes() -> std::vector<std::string> { auto Notifier::getCodes() -> std::vector<std::string> {
std::vector<std::string> codes; std::vector<std::string> codes;
codes.reserve(notifications_.size()); codes.reserve(notifications_.size());
std::ranges::transform(notifications_, std::back_inserter(codes), std::ranges::transform(notifications_, std::back_inserter(codes), [](const auto& notification) { return notification.code; });
[](const auto& notification) { return notification.code; });
return codes; return codes;
} }

View File

@@ -2,24 +2,25 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <cstdint> // Para uint8_t
#include <string> // Para string, basic_string #include <memory> // Para shared_ptr
#include <vector> // Para vector #include <string> // Para string, basic_string
class Sprite; // lines 8-8 #include <vector> // Para vector
class Surface; // lines 10-10 class Sprite; // lines 8-8
class Text; // lines 9-9 class Surface; // lines 10-10
class DeltaTimer; // lines 11-11 class Text; // lines 9-9
class DeltaTimer; // lines 11-11
class Notifier { class Notifier {
public: public:
// Justificado para las notificaciones // Justificado para las notificaciones
enum class TextAlign { enum class TextAlign : std::uint8_t {
LEFT, LEFT,
CENTER, CENTER,
}; };
// Forma de las notificaciones // Forma de las notificaciones
enum class Shape { enum class Shape : std::uint8_t {
ROUNDED, ROUNDED,
SQUARED, SQUARED,
}; };
@@ -65,7 +66,7 @@ class Notifier {
private: private:
// Tipos anidados // Tipos anidados
enum class Status { enum class Status : std::uint8_t {
RISING, RISING,
STAY, STAY,
VANISHING, VANISHING,