diff --git a/source/asset.cpp b/source/asset.cpp index 08bec10..a41590d 100644 --- a/source/asset.cpp +++ b/source/asset.cpp @@ -1,13 +1,14 @@ #include "asset.h" -#include +#include // Para SDL_LogCategory, SDL_LogInfo, SDL_LogError, SDL_LogWarn -#include -#include -#include -#include +#include // Para size_t +#include // Para exception +#include // Para basic_istream, basic_ifstream, ifstream, istringstream +#include // Para basic_istringstream +#include // Para runtime_error -#include "utils.h" +#include "utils.h" // Para getFileName // Singleton Asset *Asset::instance = nullptr; diff --git a/source/define_buttons.cpp b/source/define_buttons.cpp index 2a3bd0b..2670333 100644 --- a/source/define_buttons.cpp +++ b/source/define_buttons.cpp @@ -1,17 +1,18 @@ #include "define_buttons.h" -#include -#include -#include +#include // Para __all_of_fn, all_of +#include // Para identity +#include // Para allocator, unique_ptr, shared_ptr, make_unique, operator== -#include "input.h" -#include "input_types.h" -#include "lang.h" -#include "options.h" -#include "param.h" -#include "resource.h" -#include "text.h" -#include "ui/window_message.h" +#include "color.h" // Para Color +#include "input.h" // Para Input +#include "input_types.h" // Para InputAction +#include "lang.h" // Para getText +#include "options.h" // Para Gamepad +#include "param.h" // Para Param, ParamGame, param +#include "resource.h" // Para Resource +#include "ui/window_message.h" // Para WindowMessage +#include "utils.h" // Para Zone DefineButtons::DefineButtons() : input_(Input::get()) { diff --git a/source/director.cpp b/source/director.cpp index bc53483..27b117f 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -159,12 +159,12 @@ void Director::loadAssets() { #ifdef MACOS_BUNDLE const std::string prefix = "/../Resources"; #else - const std::string prefix; + const std::string PREFIX; #endif // Cargar la configuración de assets (también aplicar el prefijo al archivo de configuración) - std::string config_path = executable_path_ + prefix + "/data/config/assets.txt"; - Asset::get()->loadFromFile(config_path, prefix, system_folder_); + std::string config_path = executable_path_ + PREFIX + "/data/config/assets.txt"; + Asset::get()->loadFromFile(config_path, PREFIX, system_folder_); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Assets configuration loaded successfully"); diff --git a/source/global_events.cpp b/source/global_events.cpp index 63ec611..c228ec6 100644 --- a/source/global_events.cpp +++ b/source/global_events.cpp @@ -1,11 +1,15 @@ #include "global_events.h" -#include // Para SDL_LogInfo, SDL_LogCategory +#include // Para SDL_EventType, SDL_Event, SDL_LogInfo, SDL_LogCategory + +#include // Para size_t +#include // Para allocator, operator+, string +#include // Para vector #include "input.h" // Para Input -#include "lang.h" // Para Lang +#include "lang.h" // Para getText #include "mouse.h" // Para handleEvent -#include "options.h" // Para Options +#include "options.h" // Para GamepadManager, gamepad_manager #include "screen.h" // Para Screen #include "section.hpp" // Para Name, Options, name, options #include "ui/notifier.h" // Para Notifier diff --git a/source/global_inputs.cpp b/source/global_inputs.cpp index 3e252e7..ca6b073 100644 --- a/source/global_inputs.cpp +++ b/source/global_inputs.cpp @@ -1,15 +1,16 @@ #include "global_inputs.h" -#include // Para shared_ptr -#include // Para operator+, allocator, char_traits, to_string, string -#include // Para vector +#include // Para function +#include // Para allocator, shared_ptr +#include // Para operator+, char_traits, string, to_string +#include // Para pair +#include // Para vector -#include "asset.h" // Para Asset #include "audio.h" // Para Audio #include "input.h" // Para Input #include "input_types.h" // Para InputAction -#include "lang.h" // Para getText, Code, getNextLangCode, loadFromFile -#include "options.h" // Para Settings, settings, Video, Window, video, window, Audio, audio +#include "lang.h" // Para getText, getLangFile, getLangName, getNextLangCode, loadFromFile +#include "options.h" // Para Video, video, Settings, settings, Audio, audio, Window, window #include "screen.h" // Para Screen #include "section.hpp" // Para Name, name, Options, options, AttractMode, attract_mode #include "ui/notifier.h" // Para Notifier diff --git a/source/options.cpp b/source/options.cpp index 8f1b522..c0e534b 100644 --- a/source/options.cpp +++ b/source/options.cpp @@ -424,8 +424,7 @@ auto stringToPlayerId(std::string name) -> Player::Id { } if (name == Lang::getText("[SERVICE_MENU] PLAYER2")) { return Player::Id::PLAYER2; - } else { - return Player::Id::NO_PLAYER; } + return Player::Id::NO_PLAYER; } } // namespace Options \ No newline at end of file diff --git a/source/pause_manager.h b/source/pause_manager.h index 6a4f63b..8e01a4d 100644 --- a/source/pause_manager.h +++ b/source/pause_manager.h @@ -25,8 +25,13 @@ class PauseManager { return static_cast(static_cast(a) & static_cast(b)); } - friend auto operator~(Source a) -> Source { - return static_cast(~static_cast(a)); + friend auto operator~(Source a) -> uint8_t { + return ~static_cast(a); + } + + friend auto operator&=(Source& a, uint8_t b) -> Source& { + a = static_cast(static_cast(a) & b); + return a; } friend auto operator|=(Source& a, Source b) -> Source& { @@ -63,10 +68,9 @@ class PauseManager { if (enable) { flags_ |= source; } else { - flags_ &= ~source; + flags_ &= ~source; // Ahora funciona: Source &= uint8_t } - // Solo notifica si cambió el estado general de pausa if (was_paused != isPaused()) { notifyPauseChanged(); } @@ -125,7 +129,6 @@ class PauseManager { result += ", "; } result += "FocusLoss"; - first = false; } return result; diff --git a/source/player.cpp b/source/player.cpp index d7c232e..e5f1118 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -397,56 +397,56 @@ void Player::render() { // Calcula la animacion de moverse y disparar del jugador auto Player::computeAnimation() const -> std::pair { - const std::string baseAnim = (walking_state_ == State::WALKING_STOP) ? "stand" : "walk"; - std::string animName; - SDL_FlipMode flipMode = SDL_FLIP_NONE; + const std::string BASE_ANIM = (walking_state_ == State::WALKING_STOP) ? "stand" : "walk"; + std::string anim_name; + SDL_FlipMode flip_mode = SDL_FLIP_NONE; switch (firing_state_) { case State::FIRING_NONE: - animName = baseAnim; - flipMode = (walking_state_ == State::WALKING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; + anim_name = BASE_ANIM; + flip_mode = (walking_state_ == State::WALKING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; break; case State::FIRING_UP: - animName = baseAnim + "-fire-center"; - flipMode = (walking_state_ == State::WALKING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; + anim_name = BASE_ANIM + "-fire-center"; + flip_mode = (walking_state_ == State::WALKING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; break; case State::FIRING_LEFT: case State::FIRING_RIGHT: - animName = baseAnim + "-fire-side"; - flipMode = (firing_state_ == State::FIRING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; + anim_name = BASE_ANIM + "-fire-side"; + flip_mode = (firing_state_ == State::FIRING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; break; case State::RECOILING_UP: - animName = baseAnim + "-recoil-center"; - flipMode = (walking_state_ == State::WALKING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; + anim_name = BASE_ANIM + "-recoil-center"; + flip_mode = (walking_state_ == State::WALKING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; break; case State::RECOILING_LEFT: case State::RECOILING_RIGHT: - animName = baseAnim + "-recoil-side"; - flipMode = (firing_state_ == State::RECOILING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; + anim_name = BASE_ANIM + "-recoil-side"; + flip_mode = (firing_state_ == State::RECOILING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; break; case State::COOLING_UP: - animName = baseAnim + "-cool-center"; - flipMode = (walking_state_ == State::WALKING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; + anim_name = BASE_ANIM + "-cool-center"; + flip_mode = (walking_state_ == State::WALKING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; break; case State::COOLING_LEFT: case State::COOLING_RIGHT: - animName = baseAnim + "-cool-side"; - flipMode = (firing_state_ == State::COOLING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; + anim_name = BASE_ANIM + "-cool-side"; + flip_mode = (firing_state_ == State::COOLING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; break; default: - animName = baseAnim; - flipMode = (walking_state_ == State::WALKING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; + anim_name = BASE_ANIM; + flip_mode = (walking_state_ == State::WALKING_RIGHT) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; break; } - return {animName, flipMode}; + return {anim_name, flip_mode}; } // Establece la animación correspondiente al estado @@ -936,15 +936,15 @@ auto Player::isRenderable() const -> bool { // Añade una puntuación a la tabla de records void Player::addScoreToScoreBoard() const { if (hi_score_table_ == nullptr) { - return; // Verificar esto antes de crear el manager + return; // Verificar esto antes de crear el manager } - + const auto ENTRY = HiScoreEntry(trim(getLastEnterName()), getScore(), get1CC()); auto manager = std::make_unique(*hi_score_table_); - + if (glowing_entry_ != nullptr) { *glowing_entry_ = manager->add(ENTRY); } - + manager->saveToFile(Asset::get()->get("score.bin")); } \ No newline at end of file diff --git a/source/player.h b/source/player.h index 41e96ee..1c2abf7 100644 --- a/source/player.h +++ b/source/player.h @@ -1,10 +1,11 @@ #pragma once -#include // Para Uint32, SDL_FRect +#include // Para Uint32, SDL_FRect, SDL_FlipMode -#include // Para shared_ptr, allocator, unique_ptr -#include // Para string -#include // Para vector +#include // Para shared_ptr, allocator, unique_ptr +#include // Para string +#include // Para pair +#include // Para vector #include "animated_sprite.h" // Para AnimatedSprite #include "enter_name.h" // Para EnterName @@ -257,42 +258,42 @@ class Player { bool uses_keyboard_ = false; // Indica si usa el teclado como dispositivo de control // --- Métodos internos --- - void shiftColliders(); // Actualiza el círculo de colisión a la posición del jugador - void shiftSprite(); // Recoloca el sprite - void updateInvulnerable(); // Monitoriza el estado de invulnerabilidad - void updateContinueCounter(); // Actualiza el contador de continue - void updateEnterNameCounter(); // Actualiza el contador de entrar nombre - void updateShowingName(); // Actualiza el estado SHOWING_NAME - void decNameEntryCounter(); // Decrementa el contador de entrar nombre - void updateScoreboard(); // Actualiza el panel del marcador - void setScoreboardMode(Scoreboard::Mode mode) const; // Cambia el modo del marcador - void playSound(const std::string &name) const; // Hace sonar un sonido - [[nodiscard]] auto isRenderable() const -> bool; // Indica si se puede dibujar el objeto - void addScoreToScoreBoard() const; // Añade una puntuación a la tabla de records - void handleFiringCooldown(); // Gestiona el tiempo de espera después de disparar antes de permitir otro disparo - void handleRecoilAndCooling(); // Procesa simultáneamente el retroceso del arma y la transición al estado de enfriamiento si aplica - void handleCoolingState(); // Actualiza la lógica interna mientras el sistema está en estado de enfriamiento - void transitionToRecoiling(); // Cambia el estado actual al de retroceso después de disparar - void transitionToCooling(); // Cambia el estado actual al de enfriamiento (por ejemplo, tras una ráfaga o sobrecalentamiento) - void completeCooling(); // Finaliza el proceso de enfriamiento y restablece el estado listo para disparar - void handlePlayingMovement(); // Gestiona el movimiento del personaje u objeto durante el estado de juego activo - void handleRollingMovement(); // Actualiza la lógica de movimiento de "rodar" (posiblemente tras impacto o acción especial) - void handleRollingBoundaryCollision(); // Detecta y maneja colisiones del objeto rodante con los límites de la pantalla - void handleRollingGroundCollision(); // Gestiona la interacción del objeto rodante con el suelo (rebotes, frenado, etc.) - void handleRollingStop(); // Detiene el movimiento del objeto rodante cuando se cumplen las condiciones necesarias - void handleRollingBounce(); // Aplica una lógica de rebote al colisionar con superficies durante el rodamiento - void handleTitleAnimation(); // Ejecuta la animación del título en pantalla (ej. entrada, parpadeo o desplazamiento) - void handleContinueTimeOut(); // Gestiona el tiempo de espera en la pantalla de "Continuar" y decide si pasar a otro estado - void handleLeavingScreen(); // Lógica para salir de la pantalla actual (transición visual o cambio de escena) - void handleEnteringScreen(); // Lógica para entrar en una nueva pantalla, posiblemente con animación o retraso - void handlePlayer1Entering(); // Controla la animación o posición de entrada del Jugador 1 en pantalla - void handlePlayer2Entering(); // Controla la animación o posición de entrada del Jugador 2 en pantalla - void handleCreditsMovement(); // Movimiento general en la pantalla de créditos (desplazamiento vertical u horizontal) - void handleCreditsRightMovement(); // Lógica específica para mover los créditos hacia la derecha - void handleCreditsLeftMovement(); // Lógica específica para mover los créditos hacia la izquierda - void handleWaitingMovement(); // Controla la animación del jugador saludando - void updateWalkingStateForCredits(); // Actualiza el estado de caminata de algún personaje u elemento animado en los créditos - void setInputBasedOnPlayerId(); // Asocia las entradas de control en función del identificador del jugador (teclas, mando, etc.) - void updateStepCounter(); // Incrementa o ajusta el contador de pasos para animaciones o mecánicas relacionadas con movimiento - auto computeAnimation() const -> std::pair; // Calcula la animacion de moverse y disparar del jugador + void shiftColliders(); // Actualiza el círculo de colisión a la posición del jugador + void shiftSprite(); // Recoloca el sprite + void updateInvulnerable(); // Monitoriza el estado de invulnerabilidad + void updateContinueCounter(); // Actualiza el contador de continue + void updateEnterNameCounter(); // Actualiza el contador de entrar nombre + void updateShowingName(); // Actualiza el estado SHOWING_NAME + void decNameEntryCounter(); // Decrementa el contador de entrar nombre + void updateScoreboard(); // Actualiza el panel del marcador + void setScoreboardMode(Scoreboard::Mode mode) const; // Cambia el modo del marcador + void playSound(const std::string &name) const; // Hace sonar un sonido + [[nodiscard]] auto isRenderable() const -> bool; // Indica si se puede dibujar el objeto + void addScoreToScoreBoard() const; // Añade una puntuación a la tabla de records + void handleFiringCooldown(); // Gestiona el tiempo de espera después de disparar antes de permitir otro disparo + void handleRecoilAndCooling(); // Procesa simultáneamente el retroceso del arma y la transición al estado de enfriamiento si aplica + void handleCoolingState(); // Actualiza la lógica interna mientras el sistema está en estado de enfriamiento + void transitionToRecoiling(); // Cambia el estado actual al de retroceso después de disparar + void transitionToCooling(); // Cambia el estado actual al de enfriamiento (por ejemplo, tras una ráfaga o sobrecalentamiento) + void completeCooling(); // Finaliza el proceso de enfriamiento y restablece el estado listo para disparar + void handlePlayingMovement(); // Gestiona el movimiento del personaje u objeto durante el estado de juego activo + void handleRollingMovement(); // Actualiza la lógica de movimiento de "rodar" (posiblemente tras impacto o acción especial) + void handleRollingBoundaryCollision(); // Detecta y maneja colisiones del objeto rodante con los límites de la pantalla + void handleRollingGroundCollision(); // Gestiona la interacción del objeto rodante con el suelo (rebotes, frenado, etc.) + void handleRollingStop(); // Detiene el movimiento del objeto rodante cuando se cumplen las condiciones necesarias + void handleRollingBounce(); // Aplica una lógica de rebote al colisionar con superficies durante el rodamiento + void handleTitleAnimation(); // Ejecuta la animación del título en pantalla (ej. entrada, parpadeo o desplazamiento) + void handleContinueTimeOut(); // Gestiona el tiempo de espera en la pantalla de "Continuar" y decide si pasar a otro estado + void handleLeavingScreen(); // Lógica para salir de la pantalla actual (transición visual o cambio de escena) + void handleEnteringScreen(); // Lógica para entrar en una nueva pantalla, posiblemente con animación o retraso + void handlePlayer1Entering(); // Controla la animación o posición de entrada del Jugador 1 en pantalla + void handlePlayer2Entering(); // Controla la animación o posición de entrada del Jugador 2 en pantalla + void handleCreditsMovement(); // Movimiento general en la pantalla de créditos (desplazamiento vertical u horizontal) + void handleCreditsRightMovement(); // Lógica específica para mover los créditos hacia la derecha + void handleCreditsLeftMovement(); // Lógica específica para mover los créditos hacia la izquierda + void handleWaitingMovement(); // Controla la animación del jugador saludando + void updateWalkingStateForCredits(); // Actualiza el estado de caminata de algún personaje u elemento animado en los créditos + void setInputBasedOnPlayerId(); // Asocia las entradas de control en función del identificador del jugador (teclas, mando, etc.) + void updateStepCounter(); // Incrementa o ajusta el contador de pasos para animaciones o mecánicas relacionadas con movimiento + [[nodiscard]] auto computeAnimation() const -> std::pair; // Calcula la animacion de moverse y disparar del jugador }; \ No newline at end of file diff --git a/source/resource.cpp b/source/resource.cpp index cd4260f..efa4a20 100644 --- a/source/resource.cpp +++ b/source/resource.cpp @@ -2,29 +2,26 @@ #include // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError, SDL_SetRenderDrawColor, SDL_EventType, SDL_PollEvent, SDL_RenderFillRect, SDL_RenderRect, SDLK_ESCAPE, SDL_Event -#include // Para find_if, max +#include // Para find_if, max, find #include // Para array #include // Para exit -#include // Para printWithDots #include // Para runtime_error #include // Para move -#include "asset.h" // Para Asset, AssetType +#include "asset.h" // Para Asset #include "color.h" // Para Color #ifndef NO_AUDIO -#include "external/jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_LoadMusic, JA_LoadSound +#include "external/jail_audio.h" // Para JA_LoadMusic, JA_LoadSound, JA_DeleteMusic, JA_DeleteSound #endif #include "lang.h" // Para getText #include "param.h" // Para Param, param, ParamResource, ParamGame #include "screen.h" // Para Screen -#include "text.h" // Para Text, loadTextFile, TextFile (ptr only) +#include "text.h" // Para Text struct JA_Music_t; // lines 11-11 struct JA_Sound_t; // lines 12-12 // Declaraciones de funciones que necesitas implementar en otros archivos -extern AnimationsFileBuffer loadAnimationsFromFile(const std::string &filename); -extern DemoData loadDemoDataFromFile(const std::string &filename); // Singleton Resource *Resource::instance = nullptr; @@ -93,7 +90,7 @@ void Resource::loadTextFilesQuiet() { // Carga solo las texturas esenciales (fuentes) void Resource::loadEssentialTextures() { - const std::vector essential_textures = { + const std::vector ESSENTIAL_TEXTURES = { "04b_25.png", "04b_25_2x.png", "04b_25_metal.png", @@ -112,7 +109,7 @@ void Resource::loadEssentialTextures() { for (const auto &file : texture_list) { auto name = getFileName(file); // Solo cargar texturas esenciales - if (std::find(essential_textures.begin(), essential_textures.end(), name) != essential_textures.end()) { + if (std::find(ESSENTIAL_TEXTURES.begin(), ESSENTIAL_TEXTURES.end(), name) != ESSENTIAL_TEXTURES.end()) { // Buscar en nuestra lista y cargar auto it = std::find_if(textures_.begin(), textures_.end(), [&name](const auto &t) { return t.name == name; }); if (it != textures_.end()) { @@ -165,7 +162,7 @@ void Resource::initResourceLists() { loadDemoDataQuiet(); // Inicializa lista de objetos de texto (sin cargar el contenido) - const std::vector text_objects = { + const std::vector TEXT_OBJECTS = { "04b_25", "04b_25_2x", "04b_25_metal", @@ -180,7 +177,7 @@ void Resource::initResourceLists() { "smb2_grad"}; texts_.clear(); - for (const auto &text_name : text_objects) { + for (const auto &text_name : TEXT_OBJECTS) { texts_.emplace_back(text_name); // Constructor con nullptr por defecto } @@ -348,7 +345,7 @@ auto Resource::loadTextLazy(const std::string &name) -> std::shared_ptr { std::string text_file; }; - const std::vector text_mappings = { + const std::vector TEXT_MAPPINGS = { {"04b_25", "04b_25.png", "04b_25.txt"}, {"04b_25_2x", "04b_25_2x.png", "04b_25_2x.txt"}, {"04b_25_metal", "04b_25_metal.png", "04b_25.txt"}, @@ -362,7 +359,7 @@ auto Resource::loadTextLazy(const std::string &name) -> std::shared_ptr { {"smb2", "smb2.png", "smb2.txt"}, {"smb2_grad", "smb2_grad.png", "smb2.txt"}}; - for (const auto &mapping : text_mappings) { + for (const auto &mapping : TEXT_MAPPINGS) { if (mapping.key == name) { // Cargar las dependencias automáticamente auto texture = getTexture(mapping.texture_file); // Esto cargará la textura si no está cargada diff --git a/source/resource.h b/source/resource.h index a2d21ff..30700b1 100644 --- a/source/resource.h +++ b/source/resource.h @@ -40,10 +40,10 @@ class Resource { auto getDemoData(int index) -> DemoData &; // Obtiene los datos de demo por índice // --- Métodos de recarga de recursos --- - void reload(); // Recarga todos los recursos + void reload(); // Recarga todos los recursos // --- Método para obtener el modo de carga actual --- - auto getLoadingMode() const -> LoadingMode { return loading_mode_; } + [[nodiscard]] auto getLoadingMode() const -> LoadingMode { return loading_mode_; } private: // --- Estructuras para recursos individuales --- @@ -141,22 +141,22 @@ class Resource { void loadEssentialTextures(); // Carga solo las texturas esenciales (fuentes) void loadTextFilesQuiet(); // Carga ficheros de texto sin mostrar progreso (para modo lazy) // void addPalettes(); // Añade paletas a las texturas - void createPlayerTextures(); // Crea las texturas de jugadores con todas sus variantes de paleta - void createTextTextures(); // Crea las texturas a partir de los datos cargados - void createText(); // Crea los objetos de texto - void clear(); // Vacía todos los vectores de recursos - void load(); // Carga todos los recursos - void clearSounds(); // Vacía el vector de sonidos - void clearMusics(); // Vacía el vector de músicas + void createPlayerTextures(); // Crea las texturas de jugadores con todas sus variantes de paleta + void createTextTextures(); // Crea las texturas a partir de los datos cargados + void createText(); // Crea los objetos de texto + void clear(); // Vacía todos los vectores de recursos + void load(); // Carga todos los recursos + void clearSounds(); // Vacía el vector de sonidos + void clearMusics(); // Vacía el vector de músicas // --- Métodos para carga perezosa --- - void initResourceLists(); // Inicializa las listas de recursos sin cargar el contenido - auto loadSoundLazy(const std::string &name) -> JA_Sound_t *; // Carga un sonido específico bajo demanda - auto loadMusicLazy(const std::string &name) -> JA_Music_t *; // Carga una música específica bajo demanda - auto loadTextureLazy(const std::string &name) -> std::shared_ptr; // Carga una textura específica bajo demanda - auto loadTextFileLazy(const std::string &name) -> std::shared_ptr; // Carga un fichero de texto específico bajo demanda - auto loadTextLazy(const std::string &name) -> std::shared_ptr; // Carga un objeto de texto específico bajo demanda - auto loadAnimationLazy(const std::string &name) -> AnimationsFileBuffer; // Carga una animación específica bajo demanda + void initResourceLists(); // Inicializa las listas de recursos sin cargar el contenido + static auto loadSoundLazy(const std::string &name) -> JA_Sound_t *; // Carga un sonido específico bajo demanda + static auto loadMusicLazy(const std::string &name) -> JA_Music_t *; // Carga una música específica bajo demanda + static auto loadTextureLazy(const std::string &name) -> std::shared_ptr; // Carga una textura específica bajo demanda + static auto loadTextFileLazy(const std::string &name) -> std::shared_ptr; // Carga un fichero de texto específico bajo demanda + auto loadTextLazy(const std::string &name) -> std::shared_ptr; // Carga un objeto de texto específico bajo demanda + static auto loadAnimationLazy(const std::string &name) -> AnimationsFileBuffer; // Carga una animación específica bajo demanda // --- Métodos internos para gestionar el progreso --- void calculateTotalResources(); // Calcula el número de recursos para cargar diff --git a/source/sections/game.cpp b/source/sections/game.cpp index 3180cd7..f18c813 100644 --- a/source/sections/game.cpp +++ b/source/sections/game.cpp @@ -1,12 +1,11 @@ #include "game.h" -#include // Para SDL_GetTicks, SDL_SetRenderTarget, SDL_EventType, SDL_CreateTexture, SDL_Delay, SDL_DestroyTexture, SDL_Event, SDL_GetRenderTarget, SDL_PollEvent, SDL_RenderTexture, SDL_SetTextureBlendMode, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDLK_KP_MINUS, SDLK_KP_PLUS, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_Point, SDL_TextureAccess +#include // Para SDL_GetTicks, SDL_SetRenderTarget, SDL_CreateTexture, SDL_Delay, SDL_DestroyTexture, SDL_EventType, SDL_GetRenderTarget, SDL_PollEvent, SDL_RenderTexture, SDL_SetTextureBlendMode, SDL_BLENDMODE_BLEND, SDL_Event, SDL_PixelFormat, SDL_Point, SDL_TextureAccess -#include // Para max, find, clamp, find_if, min +#include // Para find, clamp, find_if, min #include // Para array #include // Para rand, size_t #include // Para function -#include // Para basic_ostream, basic_ostream::operator<<, cout, endl #include // Para size #include // Para shared_ptr, unique_ptr, __shared_ptr_access, allocator, make_unique, operator==, make_shared #include // Para move @@ -37,12 +36,16 @@ #include "screen.h" // Para Screen #include "section.hpp" // Para Name, name, AttractMode, Options, attract_mode, options #include "smart_sprite.h" // Para SmartSprite -#include "stage.h" // Para number, Stage, get, total_power, power, addPower, init, power_can_be_added, stages +#include "stage.h" // Para number, Stage, get, total_power, power, init, power_can_be_added, stages #include "tabe.h" // Para Tabe #include "text.h" // Para Text #include "texture.h" // Para Texture -#include "ui/notifier.h" // Para Notifier #include "ui/service_menu.h" // Para ServiceMenu +#ifdef _DEBUG +#include // Para Notifier + +#include "ui/notifier.h" // Para Notifier +#endif // Constructor Game::Game(Player::Id player_id, int current_stage, bool demo) diff --git a/source/sections/game.h b/source/sections/game.h index acd156c..cd04376 100644 --- a/source/sections/game.h +++ b/source/sections/game.h @@ -1,18 +1,16 @@ #pragma once -#include // Para SDL_Event, SDL_Renderer, SDL_Texture, Uint64, Uint8 +#include // Para SDL_Renderer, SDL_Texture, Uint64, Uint8 #include // Para shared_ptr, unique_ptr -#include // Para Set #include // Para string #include // Para vector #include "hit.h" // Para Hit #include "item.h" // Para Item, ItemType #include "manage_hiscore_table.h" // Para HiScoreEntry -#include "options.h" // Para SettingsOptions, settings +#include "options.h" // Para Settings, settings #include "path_sprite.h" // Para PathSprite, Path -#include "pause_manager.h" // Para PauseManager #include "player.h" // Para Player #include "smart_sprite.h" // Para SmartSprite #include "utils.h" // Para Demo @@ -23,11 +21,13 @@ class BalloonManager; class Bullet; class Fade; class Input; +class PauseManager; class Scoreboard; class Screen; class Tabe; class Texture; enum class BulletType : Uint8; + namespace Difficulty { enum class Code; } // namespace Difficulty diff --git a/source/sections/intro.cpp b/source/sections/intro.cpp index 423ae37..fc9d9c4 100644 --- a/source/sections/intro.cpp +++ b/source/sections/intro.cpp @@ -1,16 +1,15 @@ #include "intro.h" -#include // Para SDL_GetTicks, SDL_SetRenderDrawColor, SDL_FRect, SDL_RenderFillRect, SDL_GetRenderTarget, SDL_RenderClear, SDL_RenderRect, SDL_SetRenderTarget, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_PollEvent, SDL_RenderTexture, SDL_TextureAccess, SDLK_A, SDLK_C, SDLK_D, SDLK_F, SDLK_S, SDLK_V, SDLK_X, SDLK_Z, SDL_Event, SDL_EventType, Uint32 +#include // Para SDL_GetTicks, SDL_SetRenderDrawColor, SDL_FRect, SDL_RenderFillRect, SDL_GetRenderTarget, SDL_RenderClear, SDL_RenderRect, SDL_SetRenderTarget, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_PollEvent, SDL_RenderTexture, SDL_TextureAccess, SDL_Event, Uint32 #include // Para max #include // Para array #include // Para function -#include // Para basic_ostream, basic_ostream::operator<<, operator<<, cout, endl, hex -#include // Para char_traits, basic_string, string +#include // Para basic_string, string #include // Para move #include "audio.h" // Para Audio -#include "color.h" // Para Color, Zone, easeInOutExpo, easeInElastic, easeOutBounce, easeOutElastic, easeOutQuad, easeOutQuint +#include "color.h" // Para Color #include "global_events.h" // Para check #include "global_inputs.h" // Para check #include "input.h" // Para Input @@ -23,12 +22,8 @@ #include "text.h" // Para Text #include "texture.h" // Para Texture #include "tiled_bg.h" // Para TiledBG, TiledBGMode -#include "utils.h" -#include "writer.h" // Para Writer - -#ifdef _DEBUG -#include // Para operator<<, setfill, setw -#endif +#include "utils.h" // Para Zone, easeInOutExpo, easeInElastic, easeOutBounce, easeOutElastic, easeOutQuad, easeOutQuint +#include "writer.h" // Para Writer // Constructor Intro::Intro() @@ -52,14 +47,6 @@ Intro::Intro() void Intro::checkEvents() { SDL_Event event; while (SDL_PollEvent(&event)) { -#ifdef _DEBUG - if (event.type == SDL_EVENT_KEY_DOWN && static_cast(event.key.repeat) == 1) { - static Color color_ = param.intro.bg_color; - handleDebugColorKeys(event.key.key, color_); - tiled_bg_->setColor(color_); - printColorDebugInfo(color_); - } -#endif GlobalEvents::check(event); } } @@ -530,60 +517,4 @@ void Intro::renderTextRect() { static SDL_FRect rect_ = {0.0F, param.game.height - param.intro.text_distance_from_bottom - HEIGHT, param.game.width, HEIGHT * 3}; SDL_SetRenderDrawColor(Screen::get()->getRenderer(), param.intro.shadow_color.r, param.intro.shadow_color.g, param.intro.shadow_color.b, param.intro.shadow_color.a); SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_); -} - -#ifdef _DEBUG -// Helper functions for color adjustment -void Intro::adjustColorComponent(uint8_t &component, bool increase) { - if (increase && component < 255) { - ++component; - } else if (!increase && component > 0) { - --component; - } -} - -void Intro::adjustAllColorComponents(Color &color, bool increase) { - adjustColorComponent(color.r, increase); - adjustColorComponent(color.g, increase); - adjustColorComponent(color.b, increase); -} - -void Intro::handleDebugColorKeys(SDL_Keycode key, Color &color) { - switch (key) { - case SDLK_A: - adjustColorComponent(color.r, true); - break; - case SDLK_Z: - adjustColorComponent(color.r, false); - break; - case SDLK_S: - adjustColorComponent(color.g, true); - break; - case SDLK_X: - adjustColorComponent(color.g, false); - break; - case SDLK_D: - adjustColorComponent(color.b, true); - break; - case SDLK_C: - adjustColorComponent(color.b, false); - break; - case SDLK_F: - adjustAllColorComponents(color, true); - break; - case SDLK_V: - adjustAllColorComponents(color, false); - break; - default: - break; - } -} - -void Intro::printColorDebugInfo(const Color &color) { - std::cout << "#" - << std::hex << std::setw(2) << std::setfill('0') << (int)color.r - << std::setw(2) << std::setfill('0') << (int)color.g - << std::setw(2) << std::setfill('0') << (int)color.b - << std::endl; -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/source/sections/intro.h b/source/sections/intro.h index 7b3f52b..114fd49 100644 --- a/source/sections/intro.h +++ b/source/sections/intro.h @@ -1,10 +1,9 @@ #pragma once -#include // Para SDL_Keycode, Uint32, Uint64 +#include // Para Uint32, Uint64 -#include // Para uint8_t -#include // Para unique_ptr -#include // Para vector +#include // Para unique_ptr +#include // Para vector #include "color.h" // Para Color #include "param.h" // Para Param, ParamIntro, param @@ -57,8 +56,8 @@ class Intro { // --- Métodos internos --- void update(); // Actualiza las variables del objeto void render(); // Dibuja el objeto en pantalla - void checkEvents(); // Comprueba los eventos static void checkInput(); // Comprueba las entradas + static void checkEvents(); // Comprueba los eventos void updateScenes(); // Actualiza las escenas de la intro void initSprites(); // Inicializa las imágenes void initTexts(); // Inicializa los textos @@ -68,12 +67,6 @@ class Intro { void renderTexts(); // Dibuja los textos static void renderTextRect(); // Dibuja el rectangulo de fondo del texto; void updatePostState(); // Actualiza el estado POST -#ifdef _DEBUG - static void adjustColorComponent(uint8_t& component, bool increase); - static void adjustAllColorComponents(Color& color, bool increase); - static void handleDebugColorKeys(SDL_Keycode key, Color& color); - static void printColorDebugInfo(const Color& color); -#endif // --- Métodos para manejar cada escena individualmente --- void updateScene0(); diff --git a/source/sections/logo.cpp b/source/sections/logo.cpp index 17ab9b9..c09fa96 100644 --- a/source/sections/logo.cpp +++ b/source/sections/logo.cpp @@ -2,11 +2,10 @@ #include // Para SDL_GetTicks, SDL_PollEvent, SDL_Event, SDL_FRect -#include // Para max -#include // Para move +#include // Para move #include "audio.h" // Para Audio -#include "color.h" // Para Color, Zone +#include "color.h" // Para Color #include "global_events.h" // Para check #include "global_inputs.h" // Para check #include "input.h" // Para Input @@ -16,7 +15,7 @@ #include "section.hpp" // Para Name, name #include "sprite.h" // Para Sprite #include "texture.h" // Para Texture -#include "utils.h" +#include "utils.h" // Para Zone // Constructor Logo::Logo() diff --git a/source/sections/title.cpp b/source/sections/title.cpp index 5a81ca3..1ded865 100644 --- a/source/sections/title.cpp +++ b/source/sections/title.cpp @@ -1,15 +1,13 @@ #include "title.h" -#include // Para SDL_GetTicks, Uint32, SDL_Keycode, SDL_Event, SDL_PollEvent, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_A, SDLK_C, SDLK_D, SDLK_F, SDLK_S, SDLK_V, SDLK_X, SDLK_Z, SDL_EventType +#include // Para SDL_GetTicks, Uint32, SDL_Event, SDL_PollEvent, SDL_EventType #include // Para max, find_if -#include // Para basic_ostream, basic_ostream::operator<<, operator<<, cout, endl, hex -#include // Para char_traits, operator+, to_string, string, basic_string +#include // Para operator+, char_traits, to_string, string, basic_string #include // Para vector #include "audio.h" // Para Audio -#include "color.h" // Para Color, NO_TEXT_COLOR, TITLE_SHADOW_TEXT_COLOR -#include "define_buttons.h" // Para DefineButtons +#include "color.h" // Para NO_TEXT_COLOR, TITLE_SHADOW_TEXT_COLOR #include "fade.h" // Para Fade, FadeType #include "game_logo.h" // Para GameLogo #include "global_events.h" // Para check @@ -17,14 +15,14 @@ #include "input.h" // Para Input #include "input_types.h" // Para InputAction #include "lang.h" // Para getText -#include "options.h" // Para Gamepad, GamepadManager, gamepad_manager, Settings, settings, getPlayerWhoUsesKeyboard, swapControllers, swapKeyboard +#include "options.h" // Para Gamepad, GamepadManager, gamepad_manager, Settings, settings, Keyboard, keyboard, getPlayerWhoUsesKeyboard, swapControllers, swapKeyboard #include "param.h" // Para Param, param, ParamGame, ParamTitle, ParamFade #include "player.h" // Para Player #include "resource.h" // Para Resource #include "screen.h" // Para Screen #include "section.hpp" // Para Name, name, Options, options, AttractMode, attract_mode #include "sprite.h" // Para Sprite -#include "text.h" // Para Text::CENTER, Text::SHADOW, Text +#include "text.h" // Para Text #include "tiled_bg.h" // Para TiledBG, TiledBGMode #include "ui/notifier.h" // Para Notifier #include "ui/service_menu.h" // Para ServiceMenu @@ -34,6 +32,7 @@ class Texture; #ifdef _DEBUG #include // Para operator<<, setfill, setw +#include #endif // Constructor diff --git a/source/sections/title.h b/source/sections/title.h index b685b30..b61a705 100644 --- a/source/sections/title.h +++ b/source/sections/title.h @@ -1,9 +1,8 @@ #pragma once -#include // Para SDL_Keycode, SDL_Event, Uint64 +#include // Para SDL_Event, Uint64 -#include // Para uint8_t -#include // Para unique_ptr, shared_ptr +#include // Para shared_ptr, unique_ptr #include // Para string_view #include // Para vector @@ -15,10 +14,10 @@ class GameLogo; class Sprite; class Text; class TiledBG; + namespace Options { struct Gamepad; } // namespace Options -struct Color; // Textos constexpr std::string_view TEXT_COPYRIGHT = "@2020,2025 JailDesigner"; diff --git a/source/sprite.cpp b/source/sprite.cpp index 22e0531..1cbd077 100644 --- a/source/sprite.cpp +++ b/source/sprite.cpp @@ -1,7 +1,6 @@ #include "sprite.h" -#include // Para move -#include // Para vector +#include // Para vector #include "texture.h" // Para Texture @@ -45,7 +44,7 @@ void Sprite::clear() { } // Cambia la textura activa por índice -bool Sprite::setActiveTexture(size_t index) { +auto Sprite::setActiveTexture(size_t index) -> bool { if (index < textures_.size()) { texture_index_ = index; return true; diff --git a/source/sprite.h b/source/sprite.h index 63138d0..793b0a5 100644 --- a/source/sprite.h +++ b/source/sprite.h @@ -2,8 +2,9 @@ #include // Para SDL_FRect, SDL_FPoint -#include // Para shared_ptr -#include // Para vector +#include // Para size_t +#include // Para shared_ptr +#include // Para vector class Texture; @@ -53,12 +54,12 @@ class Sprite { [[nodiscard]] auto getTexture() const -> std::shared_ptr { return textures_.at(texture_index_); } void setTexture(std::shared_ptr texture) { textures_.at(texture_index_) = texture; } void addTexture(std::shared_ptr texture) { textures_.push_back(texture); } - bool setActiveTexture(size_t index); // Cambia la textura activa por índice - size_t getActiveTextureIndex() const { return texture_index_; } // Obtiene el índice de la textura activa - size_t getTextureCount() const { return textures_.size(); } // Obtiene el número total de texturas + auto setActiveTexture(size_t index) -> bool; // Cambia la textura activa por índice + [[nodiscard]] auto getActiveTextureIndex() const -> size_t { return texture_index_; } // Obtiene el índice de la textura activa + [[nodiscard]] auto getTextureCount() const -> size_t { return textures_.size(); } // Obtiene el número total de texturas protected: - std::shared_ptr& getTextureRef() { + auto getTextureRef() -> std::shared_ptr& { return textures_.at(texture_index_); } diff --git a/source/text.cpp b/source/text.cpp index ebc32c3..15fe0bb 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -1,17 +1,17 @@ #include "text.h" -#include // Para SDL_SetRenderTarget, SDL_GetRenderTarget, Uint8 +#include // Para Uint8, SDL_GetRenderTarget, SDL_RenderClear, SDL_SetRenderDrawColor, SDL_SetRenderTarget, SDL_FRect, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_TextureAccess -#include // Para size_t -#include // Para basic_ifstream, basic_istream, basic_ostream -#include // Para cerr -#include // Para runtime_error +#include // Para basic_ifstream, basic_istream, basic_ostream, operator<<, endl, ifstream +#include // Para cerr +#include // Para runtime_error +#include // Para string_view -#include "color.h" // Para Color, getFileName, printWithDots +#include "color.h" // Para Color #include "screen.h" // Para Screen #include "sprite.h" // Para Sprite #include "texture.h" // Para Texture -#include "utils.h" +#include "utils.h" // Para getFileName, printWithDots // Constructor Text::Text(std::shared_ptr texture, const std::string &text_file) { diff --git a/source/ui/menu_option.cpp b/source/ui/menu_option.cpp index bd60fcc..73bb462 100644 --- a/source/ui/menu_option.cpp +++ b/source/ui/menu_option.cpp @@ -1,8 +1,10 @@ #include "menu_option.h" -#include +#include // Para find +#include // Para distance +#include // Para allocator -#include "text.h" +#include "text.h" // Para Text auto ActionListOption::getValueAsString() const -> std::string { if (value_getter_) { diff --git a/source/ui/menu_option.h b/source/ui/menu_option.h index b743d09..e061a85 100644 --- a/source/ui/menu_option.h +++ b/source/ui/menu_option.h @@ -1,16 +1,15 @@ #pragma once -#include // para std::clamp -#include -#include -#include -#include +#include // Para max, clamp +#include // Para size_t +#include // Para function +#include // Para allocator, string, basic_string, to_string, operator==, char_traits +#include // Para move +#include // Para vector -#include "lang.h" // Para las traducciones -#include "options.h" // Para acceder a las variables de configuración -#include "section.hpp" // Para las acciones como Quit o Reset -#include "text.h" // Para poder calcular el ancho del texto -#include "ui/service_menu.h" // Necesitamos las enums como SettingsGroup +#include "lang.h" // Para getText +#include "text.h" // Para Text +#include "ui/service_menu.h" // Para ServiceMenu // --- Interfaz Base para todas las Opciones del Menú --- diff --git a/source/ui/menu_renderer.cpp b/source/ui/menu_renderer.cpp index cdea0e4..55ca35a 100644 --- a/source/ui/menu_renderer.cpp +++ b/source/ui/menu_renderer.cpp @@ -404,5 +404,5 @@ auto MenuRenderer::getTruncatedValue(const std::string &value, int available_wid return truncated; } -auto MenuRenderer::easeOut(float t) const -> float { return 1.0F - (1.0F - t) * (1.0F - t); } +auto MenuRenderer::easeOut(float t) -> float { return 1.0F - (1.0F - t) * (1.0F - t); } auto MenuRenderer::shouldShowContent() const -> bool { return !show_hide_animation_.active; } \ No newline at end of file diff --git a/source/ui/menu_renderer.h b/source/ui/menu_renderer.h index d8f388f..bb53019 100644 --- a/source/ui/menu_renderer.h +++ b/source/ui/menu_renderer.h @@ -124,6 +124,6 @@ class MenuRenderer { auto setRect(SDL_FRect rect) -> SDL_FRect; [[nodiscard]] auto getTruncatedValueWidth(const std::string &value, int available_width) const -> int; [[nodiscard]] auto getTruncatedValue(const std::string &value, int available_width) const -> std::string; - [[nodiscard]] auto easeOut(float t) const -> float; + [[nodiscard]] static auto easeOut(float t) -> float; [[nodiscard]] auto shouldShowContent() const -> bool; }; \ No newline at end of file diff --git a/source/ui/service_menu.cpp b/source/ui/service_menu.cpp index b93d38b..3f10e03 100644 --- a/source/ui/service_menu.cpp +++ b/source/ui/service_menu.cpp @@ -1,15 +1,14 @@ #include "ui/service_menu.h" -#include // Para max - #include "audio.h" // Para Audio #include "define_buttons.h" // Para DefineButtons #include "difficulty.h" // Para getCodeFromName, getNameFromCode #include "input.h" // Para Input +#include "input_types.h" // Para InputAction #include "lang.h" // Para getText, getCodeFromName, getNameFromCode -#include "menu_option.h" // Para MenuOption, ListOption, ActionOption, BoolOption, FolderOption, IntOption +#include "menu_option.h" // Para MenuOption, ActionOption, BoolOption, ListOption, FolderOption, IntOption, ActionListOption #include "menu_renderer.h" // Para MenuRenderer -#include "options.h" // Para PendingChanges, pending_changes, checkPendingChanges, GamepadManager, Video, gamepad_manager, video, Audio, Settings, audio, settings, Gamepad, Window, window, Music, Sound +#include "options.h" // Para GamepadManager, gamepad_manager, PendingChanges, Video, pending_changes, video, Audio, Gamepad, Settings, audio, checkPendingChanges, settings, Window, getPlayerWhoUsesKeyboard, playerIdToString, stringToPlayerId, window, Keyboard, Music, Sound, keyboard #include "param.h" // Para Param, param, ParamGame, ParamServiceMenu #include "player.h" // Para Player #include "resource.h" // Para Resource diff --git a/source/ui/service_menu.h b/source/ui/service_menu.h index d918e48..38bc1dc 100644 --- a/source/ui/service_menu.h +++ b/source/ui/service_menu.h @@ -1,14 +1,16 @@ #pragma once -#include -#include -#include -#include -#include -#include +#include // Para SDL_Event -#include "define_buttons.h" -#include "ui_message.h" +#include // Para size_t +#include // Para function +#include // Para unique_ptr +#include // Para string +#include // Para pair +#include // Para vector + +#include "define_buttons.h" // Para DefineButtons +#include "ui_message.h" // Para UIMessage class MenuOption; class MenuRenderer; diff --git a/source/ui/window_message.h b/source/ui/window_message.h index 806dc31..3196528 100644 --- a/source/ui/window_message.h +++ b/source/ui/window_message.h @@ -1,13 +1,14 @@ #pragma once -#include +#include // Para SDL_FPoint, SDL_FRect -#include -#include -#include +#include // Para min +#include // Para allocator, shared_ptr +#include // Para string +#include // Para vector -#include "color.h" -#include "text.h" +#include "color.h" // Para Color +#include "text.h" // Para Text class WindowMessage { public: @@ -24,21 +25,21 @@ class WindowMessage { Color text_color; // Espaciado y dimensiones - float padding{15.0f}; - float line_spacing{5.0f}; - float title_separator_spacing{10.0f}; // Espacio extra para separador del título + float padding{15.0F}; + float line_spacing{5.0F}; + float title_separator_spacing{10.0F}; // Espacio extra para separador del título // Límites de tamaño - float min_width{200.0f}; - float min_height{100.0f}; - float max_width_ratio{0.8f}; // % máximo de ancho de pantalla - float max_height_ratio{0.8f}; // % máximo de alto de pantalla + float min_width{200.0F}; + float min_height{100.0F}; + float max_width_ratio{0.8F}; // % máximo de ancho de pantalla + float max_height_ratio{0.8F}; // % máximo de alto de pantalla // Margen de seguridad para texto - float text_safety_margin{20.0f}; // Margen extra para evitar texto cortado + float text_safety_margin{20.0F}; // Margen extra para evitar texto cortado // Animaciones - float animation_duration{0.3f}; // Duración en segundos para todas las animaciones + float animation_duration{0.3F}; // Duración en segundos para todas las animaciones // Constructor con valores por defecto Config() @@ -123,7 +124,7 @@ class WindowMessage { // Posición y tamaño SDL_FRect rect_{0, 0, 300, 200}; PositionMode position_mode_ = PositionMode::CENTERED; - SDL_FPoint anchor_{0.0f, 0.0f}; + SDL_FPoint anchor_{0.0F, 0.0F}; // Animación de redimensionado struct ResizeAnimation { diff --git a/source/utils.cpp b/source/utils.cpp index df00c20..c59b4a0 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -1,13 +1,12 @@ #define _USE_MATH_DEFINES #include "utils.h" -#include // Para SDL_RenderPoint, SDL_FRect, SDL_CloseIO, SDL_IOFromFile, SDL_LogCategory, SDL_LogError, SDL_LogInfo, SDL_ReadIO, SDL_FPoint, SDL_Renderer +#include // Para SDL_RenderPoint, SDL_FRect, SDL_FPoint, SDL_CloseIO, SDL_IOFromFile, SDL_LogCategory, SDL_LogError, SDL_LogInfo, SDL_ReadIO, SDL_Renderer #include // Para clamp, find_if_not, find, transform #include // Para tolower, isspace -#include // Para pow, sin, M_PI, cos +#include // Para pow, sin, M_PI, cos, sqrt #include // Para operator<, __synth3way_t -#include // Para size_t #include // Para path #include // Para runtime_error #include // Para basic_string, allocator, string, operator==, operator+, char_traits