clang-tidy
clang-format
This commit is contained in:
2025-08-10 22:01:18 +02:00
parent 659a4ced44
commit 41e3fd1d8d
29 changed files with 235 additions and 302 deletions

View File

@@ -1,13 +1,14 @@
#include "asset.h"
#include <SDL3/SDL.h>
#include <SDL3/SDL.h> // Para SDL_LogCategory, SDL_LogInfo, SDL_LogError, SDL_LogWarn
#include <algorithm>
#include <filesystem>
#include <fstream>
#include <sstream>
#include <cstddef> // Para size_t
#include <exception> // Para exception
#include <fstream> // Para basic_istream, basic_ifstream, ifstream, istringstream
#include <sstream> // Para basic_istringstream
#include <stdexcept> // Para runtime_error
#include "utils.h"
#include "utils.h" // Para getFileName
// Singleton
Asset *Asset::instance = nullptr;

View File

@@ -1,17 +1,18 @@
#include "define_buttons.h"
#include <algorithm>
#include <functional>
#include <memory>
#include <algorithm> // Para __all_of_fn, all_of
#include <functional> // Para identity
#include <memory> // 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()) {

View File

@@ -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");

View File

@@ -1,11 +1,15 @@
#include "global_events.h"
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory
#include <SDL3/SDL.h> // Para SDL_EventType, SDL_Event, SDL_LogInfo, SDL_LogCategory
#include <cstddef> // Para size_t
#include <string> // Para allocator, operator+, string
#include <vector> // 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

View File

@@ -1,15 +1,16 @@
#include "global_inputs.h"
#include <memory> // Para shared_ptr
#include <string> // Para operator+, allocator, char_traits, to_string, string
#include <functional> // Para function
#include <memory> // Para allocator, shared_ptr
#include <string> // Para operator+, char_traits, string, to_string
#include <utility> // Para pair
#include <vector> // 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

View File

@@ -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

View File

@@ -25,8 +25,13 @@ class PauseManager {
return static_cast<Source>(static_cast<uint8_t>(a) & static_cast<uint8_t>(b));
}
friend auto operator~(Source a) -> Source {
return static_cast<Source>(~static_cast<uint8_t>(a));
friend auto operator~(Source a) -> uint8_t {
return ~static_cast<uint8_t>(a);
}
friend auto operator&=(Source& a, uint8_t b) -> Source& {
a = static_cast<Source>(static_cast<uint8_t>(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;

View File

@@ -397,56 +397,56 @@ void Player::render() {
// Calcula la animacion de moverse y disparar del jugador
auto Player::computeAnimation() const -> std::pair<std::string, SDL_FlipMode> {
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

View File

@@ -1,9 +1,10 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint32, SDL_FRect
#include <SDL3/SDL.h> // Para Uint32, SDL_FRect, SDL_FlipMode
#include <memory> // Para shared_ptr, allocator, unique_ptr
#include <string> // Para string
#include <utility> // Para pair
#include <vector> // Para vector
#include "animated_sprite.h" // Para AnimatedSprite
@@ -294,5 +295,5 @@ class Player {
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<std::string, SDL_FlipMode>; // Calcula la animacion de moverse y disparar del jugador
[[nodiscard]] auto computeAnimation() const -> std::pair<std::string, SDL_FlipMode>; // Calcula la animacion de moverse y disparar del jugador
};

View File

@@ -2,29 +2,26 @@
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError, SDL_SetRenderDrawColor, SDL_EventType, SDL_PollEvent, SDL_RenderFillRect, SDL_RenderRect, SDLK_ESCAPE, SDL_Event
#include <algorithm> // Para find_if, max
#include <algorithm> // Para find_if, max, find
#include <array> // Para array
#include <cstdlib> // Para exit
#include <iostream> // Para printWithDots
#include <stdexcept> // Para runtime_error
#include <utility> // 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<std::string> essential_textures = {
const std::vector<std::string> 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<std::string> text_objects = {
const std::vector<std::string> 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<Text> {
std::string text_file;
};
const std::vector<TextMapping> text_mappings = {
const std::vector<TextMapping> 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<Text> {
{"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

View File

@@ -43,7 +43,7 @@ class Resource {
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 ---
@@ -151,12 +151,12 @@ class Resource {
// --- 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<Texture>; // Carga una textura específica bajo demanda
auto loadTextFileLazy(const std::string &name) -> std::shared_ptr<Text::File>; // Carga un fichero de texto específico bajo demanda
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<Texture>; // Carga una textura específica bajo demanda
static auto loadTextFileLazy(const std::string &name) -> std::shared_ptr<Text::File>; // Carga un fichero de texto específico bajo demanda
auto loadTextLazy(const std::string &name) -> std::shared_ptr<Text>; // Carga un objeto de texto específico bajo demanda
auto loadAnimationLazy(const std::string &name) -> AnimationsFileBuffer; // Carga una animación específica 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

View File

@@ -1,12 +1,11 @@
#include "game.h"
#include <SDL3/SDL.h> // 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 <SDL3/SDL.h> // 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 <algorithm> // Para max, find, clamp, find_if, min
#include <algorithm> // Para find, clamp, find_if, min
#include <array> // Para array
#include <cstdlib> // Para rand, size_t
#include <functional> // Para function
#include <iostream> // Para basic_ostream, basic_ostream::operator<<, cout, endl
#include <iterator> // Para size
#include <memory> // Para shared_ptr, unique_ptr, __shared_ptr_access, allocator, make_unique, operator==, make_shared
#include <utility> // 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 <iostream> // Para Notifier
#include "ui/notifier.h" // Para Notifier
#endif
// Constructor
Game::Game(Player::Id player_id, int current_stage, bool demo)

View File

@@ -1,18 +1,16 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_Event, SDL_Renderer, SDL_Texture, Uint64, Uint8
#include <SDL3/SDL.h> // Para SDL_Renderer, SDL_Texture, Uint64, Uint8
#include <memory> // Para shared_ptr, unique_ptr
#include <set> // Para Set
#include <string> // Para string
#include <vector> // 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

View File

@@ -1,16 +1,15 @@
#include "intro.h"
#include <SDL3/SDL.h> // 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 <SDL3/SDL.h> // 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 <algorithm> // Para max
#include <array> // Para array
#include <functional> // Para function
#include <iostream> // Para basic_ostream, basic_ostream::operator<<, operator<<, cout, endl, hex
#include <string> // Para char_traits, basic_string, string
#include <string> // Para basic_string, string
#include <utility> // 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,13 +22,9 @@
#include "text.h" // Para Text
#include "texture.h" // Para Texture
#include "tiled_bg.h" // Para TiledBG, TiledBGMode
#include "utils.h"
#include "utils.h" // Para Zone, easeInOutExpo, easeInElastic, easeOutBounce, easeOutElastic, easeOutQuad, easeOutQuint
#include "writer.h" // Para Writer
#ifdef _DEBUG
#include <iomanip> // Para operator<<, setfill, setw
#endif
// Constructor
Intro::Intro()
: tiled_bg_(std::make_unique<TiledBG>(param.game.game_area.rect, TiledBGMode::DIAGONAL)) {
@@ -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<int>(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);
}
}
@@ -531,59 +518,3 @@ void Intro::renderTextRect() {
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

View File

@@ -1,8 +1,7 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_Keycode, Uint32, Uint64
#include <SDL3/SDL.h> // Para Uint32, Uint64
#include <cstdint> // Para uint8_t
#include <memory> // Para unique_ptr
#include <vector> // Para vector
@@ -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();

View File

@@ -2,11 +2,10 @@
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_PollEvent, SDL_Event, SDL_FRect
#include <algorithm> // Para max
#include <utility> // 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()

View File

@@ -1,15 +1,13 @@
#include "title.h"
#include <SDL3/SDL.h> // 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 <SDL3/SDL.h> // Para SDL_GetTicks, Uint32, SDL_Event, SDL_PollEvent, SDL_EventType
#include <algorithm> // Para max, find_if
#include <iostream> // Para basic_ostream, basic_ostream::operator<<, operator<<, cout, endl, hex
#include <string> // Para char_traits, operator+, to_string, string, basic_string
#include <string> // Para operator+, char_traits, to_string, string, basic_string
#include <vector> // 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 <iomanip> // Para operator<<, setfill, setw
#include <iostream>
#endif
// Constructor

View File

@@ -1,9 +1,8 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_Keycode, SDL_Event, Uint64
#include <SDL3/SDL.h> // Para SDL_Event, Uint64
#include <cstdint> // Para uint8_t
#include <memory> // Para unique_ptr, shared_ptr
#include <memory> // Para shared_ptr, unique_ptr
#include <string_view> // Para string_view
#include <vector> // 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";

View File

@@ -1,6 +1,5 @@
#include "sprite.h"
#include <utility> // Para move
#include <vector> // 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;

View File

@@ -2,6 +2,7 @@
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_FPoint
#include <cstddef> // Para size_t
#include <memory> // Para shared_ptr
#include <vector> // Para vector
@@ -53,12 +54,12 @@ class Sprite {
[[nodiscard]] auto getTexture() const -> std::shared_ptr<Texture> { return textures_.at(texture_index_); }
void setTexture(std::shared_ptr<Texture> texture) { textures_.at(texture_index_) = texture; }
void addTexture(std::shared_ptr<Texture> 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<Texture>& getTextureRef() {
auto getTextureRef() -> std::shared_ptr<Texture>& {
return textures_.at(texture_index_);
}

View File

@@ -1,17 +1,17 @@
#include "text.h"
#include <SDL3/SDL.h> // Para SDL_SetRenderTarget, SDL_GetRenderTarget, Uint8
#include <SDL3/SDL.h> // Para Uint8, SDL_GetRenderTarget, SDL_RenderClear, SDL_SetRenderDrawColor, SDL_SetRenderTarget, SDL_FRect, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_TextureAccess
#include <cstddef> // Para size_t
#include <fstream> // Para basic_ifstream, basic_istream, basic_ostream
#include <fstream> // Para basic_ifstream, basic_istream, basic_ostream, operator<<, endl, ifstream
#include <iostream> // Para cerr
#include <stdexcept> // Para runtime_error
#include <string_view> // 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> texture, const std::string &text_file) {

View File

@@ -1,8 +1,10 @@
#include "menu_option.h"
#include <algorithm>
#include <algorithm> // Para find
#include <iterator> // Para distance
#include <memory> // Para allocator
#include "text.h"
#include "text.h" // Para Text
auto ActionListOption::getValueAsString() const -> std::string {
if (value_getter_) {

View File

@@ -1,16 +1,15 @@
#pragma once
#include <algorithm> // para std::clamp
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include <algorithm> // Para max, clamp
#include <cstddef> // Para size_t
#include <functional> // Para function
#include <string> // Para allocator, string, basic_string, to_string, operator==, char_traits
#include <utility> // Para move
#include <vector> // 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ú ---

View File

@@ -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; }

View File

@@ -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;
};

View File

@@ -1,15 +1,14 @@
#include "ui/service_menu.h"
#include <algorithm> // 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

View File

@@ -1,14 +1,16 @@
#pragma once
#include <cstddef>
#include <functional>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <SDL3/SDL.h> // Para SDL_Event
#include "define_buttons.h"
#include "ui_message.h"
#include <cstddef> // Para size_t
#include <functional> // Para function
#include <memory> // Para unique_ptr
#include <string> // Para string
#include <utility> // Para pair
#include <vector> // Para vector
#include "define_buttons.h" // Para DefineButtons
#include "ui_message.h" // Para UIMessage
class MenuOption;
class MenuRenderer;

View File

@@ -1,13 +1,14 @@
#pragma once
#include <SDL3/SDL.h>
#include <SDL3/SDL.h> // Para SDL_FPoint, SDL_FRect
#include <memory>
#include <string>
#include <vector>
#include <algorithm> // Para min
#include <memory> // Para allocator, shared_ptr
#include <string> // Para string
#include <vector> // 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 {

View File

@@ -1,13 +1,12 @@
#define _USE_MATH_DEFINES
#include "utils.h"
#include <SDL3/SDL.h> // Para SDL_RenderPoint, SDL_FRect, SDL_CloseIO, SDL_IOFromFile, SDL_LogCategory, SDL_LogError, SDL_LogInfo, SDL_ReadIO, SDL_FPoint, SDL_Renderer
#include <SDL3/SDL.h> // Para SDL_RenderPoint, SDL_FRect, SDL_FPoint, SDL_CloseIO, SDL_IOFromFile, SDL_LogCategory, SDL_LogError, SDL_LogInfo, SDL_ReadIO, SDL_Renderer
#include <algorithm> // Para clamp, find_if_not, find, transform
#include <cctype> // Para tolower, isspace
#include <cmath> // Para pow, sin, M_PI, cos
#include <cmath> // Para pow, sin, M_PI, cos, sqrt
#include <compare> // Para operator<, __synth3way_t
#include <cstdlib> // Para size_t
#include <filesystem> // Para path
#include <stdexcept> // Para runtime_error
#include <string> // Para basic_string, allocator, string, operator==, operator+, char_traits