From ea5cedfd265ce6d76f4f0c42bfc43fd4b6e44ca1 Mon Sep 17 00:00:00 2001 From: Sergio Date: Mon, 21 Jul 2025 13:18:43 +0200 Subject: [PATCH] mil merdertes --- .clang-format | 7 ------ CMakeLists.txt | 3 +-- ...es.sh => check_all_includes_with_pause.sh} | 2 +- linux_utils/check_one_file_includes.sh | 16 ++++++++++++ linux_utils/com_usar_clang-tidy.txt | 8 ++++-- source/animated_sprite.h | 5 ++-- source/asset.h | 6 ++--- source/audio.h | 4 +-- source/balloon_formations.cpp | 25 ++++++++++++------- source/balloon_formations.h | 14 +++++------ source/balloon_manager.h | 9 ++++--- source/director.cpp | 4 +-- source/explosions.cpp | 2 ++ source/global_events.cpp | 2 +- source/global_inputs.cpp | 4 +-- source/options.h | 7 +++--- source/screen.cpp | 2 +- source/section.cpp | 7 ------ source/{section.h => section.hpp} | 6 ++--- source/sections/credits.cpp | 2 +- source/sections/game.cpp | 4 +-- source/sections/hiscore_table.cpp | 2 +- source/sections/instructions.cpp | 2 +- source/sections/intro.cpp | 2 +- source/sections/logo.cpp | 2 +- source/sections/title.cpp | 4 +-- source/sections/title.h | 2 +- source/sprite.cpp | 2 +- source/stage.h | 2 +- source/ui/menu_option.h | 2 +- source/ui/menu_renderer.cpp | 4 +-- source/ui/menu_renderer.h | 1 + source/{ => ui}/notifier.cpp | 0 source/{ => ui}/notifier.h | 0 source/ui/service_menu.cpp | 4 +-- source/utils.h | 2 +- 36 files changed, 94 insertions(+), 76 deletions(-) rename linux_utils/{check_includes.sh => check_all_includes_with_pause.sh} (68%) create mode 100755 linux_utils/check_one_file_includes.sh delete mode 100644 source/section.cpp rename source/{section.h => section.hpp} (89%) rename source/{ => ui}/notifier.cpp (100%) rename source/{ => ui}/notifier.h (100%) diff --git a/.clang-format b/.clang-format index fcb677d..6c97bba 100644 --- a/.clang-format +++ b/.clang-format @@ -10,10 +10,3 @@ AlignOperands: false AlignAfterOpenBracket: DontAlign BinPackArguments: false BinPackParameters: false - -SortIncludes: CaseSensitive -IncludeBlocks: Merge -IncludeCategories: - - Regex: '.*' - Priority: 1 - SortPriority: -1 diff --git a/CMakeLists.txt b/CMakeLists.txt index eacc287..1c6d9bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,6 @@ set(APP_SOURCES # --- Archivos Principales del Sistema --- source/main.cpp source/director.cpp - source/section.cpp source/screen.cpp source/resource.cpp source/asset.cpp @@ -36,6 +35,7 @@ set(APP_SOURCES # --- UI (User Interface) --- source/ui/service_menu.cpp source/ui/menu_renderer.cpp + source/ui/notifier.cpp source/ui/ui_message.cpp # --- Lógica del Juego --- @@ -74,7 +74,6 @@ set(APP_SOURCES # --- Otros --- source/define_buttons.cpp source/mouse.cpp - source/notifier.cpp source/stage.cpp source/tabe.cpp source/text.cpp diff --git a/linux_utils/check_includes.sh b/linux_utils/check_all_includes_with_pause.sh similarity index 68% rename from linux_utils/check_includes.sh rename to linux_utils/check_all_includes_with_pause.sh index aee7ad2..84cc83d 100755 --- a/linux_utils/check_includes.sh +++ b/linux_utils/check_all_includes_with_pause.sh @@ -4,7 +4,7 @@ SOURCEPATH=../source/ for i in "$SOURCEPATH"/*.cpp do - include-what-you-use -D DEBUG -D VERBOSE -std=c++20 -Wall "$i" + include-what-you-use -D DEBUG -std=c++20 -Wall "$i" read -r -p "Presiona cualquier tecla para continuar..." clear done diff --git a/linux_utils/check_one_file_includes.sh b/linux_utils/check_one_file_includes.sh new file mode 100755 index 0000000..c17bd27 --- /dev/null +++ b/linux_utils/check_one_file_includes.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Verifica que se haya proporcionado un archivo como argumento +if [ $# -eq 0 ]; then + echo "Uso: $0 " + exit 1 +fi + +FILE="$1" + +include-what-you-use -D DEBUG -D VERBOSE -std=c++20 -Wall "$FILE" \ +-Xiwyu --mapping_file=sdl3_mapping.imp \ +-Xiwyu --update_comments \ +-Xiwyu --verbose=3 \ +| \ +python3 /usr/bin/fix_includes.py --update_comments diff --git a/linux_utils/com_usar_clang-tidy.txt b/linux_utils/com_usar_clang-tidy.txt index eb53dd3..62efbac 100644 --- a/linux_utils/com_usar_clang-tidy.txt +++ b/linux_utils/com_usar_clang-tidy.txt @@ -1,2 +1,6 @@ -Desde l'arrel del projecte executar: -clang-tidy source/fitxer.cpp -p build/ --fix \ No newline at end of file +# Per a un fitxer, desde l'arrel del projecte executar: +clang-tidy source/fitxer.cpp -p build/ --fix + +# Per a varios fitxers, desde l'arrel: +find source/ \( -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) | xargs -P4 -I{} clang-tidy {} -p build/ --fix + diff --git a/source/animated_sprite.h b/source/animated_sprite.h index 2f01068..1a4fa4c 100644 --- a/source/animated_sprite.h +++ b/source/animated_sprite.h @@ -2,9 +2,10 @@ #include // Para SDL_FRect +#include // Para max #include // Para size_t -#include // Para shared_ptr -#include // Para basic_string, string, hash +#include // Para allocator, shared_ptr +#include // Para string, hash #include // Para unordered_map #include // Para vector diff --git a/source/asset.h b/source/asset.h index 5bf8d31..5f5bce6 100644 --- a/source/asset.h +++ b/source/asset.h @@ -1,8 +1,8 @@ #pragma once -#include // Para string, basic_string -#include -#include // Para vector +#include // Para string +#include // Para move +#include // Para vector // Tipos de recursos gestionados por Asset enum class AssetType : int { diff --git a/source/audio.h b/source/audio.h index 9786cdd..3d4aa8a 100644 --- a/source/audio.h +++ b/source/audio.h @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include // Para string +#include // Para move // Clase Audio: gestor de audio (singleton) class Audio { diff --git a/source/balloon_formations.cpp b/source/balloon_formations.cpp index 55fefac..643ae33 100644 --- a/source/balloon_formations.cpp +++ b/source/balloon_formations.cpp @@ -1,13 +1,20 @@ -#include "asset.h" -#include "balloon.h" // Para BalloonType, BalloonSize, BALLOON_SIZE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_POSITIVE #include "balloon_formations.h" -#include "param.h" // Para Param, ParamGame, param -#include "utils.h" // Para Zone, BLOCK -#include // Para array -#include -#include -#include -#include + +#include // Para size_t + +#include // Para max +#include // Para array +#include // Para isdigit +#include // Para exception +#include // Para basic_istream, basic_ifstream, ifstream, istringstream +#include // Para map, operator== +#include // Para basic_istringstream +#include // Para allocator, char_traits, operator==, string, operator<=>, basic_string, stoi, getline + +#include "asset.h" // Para Asset +#include "balloon.h" // Para BALLOON_SIZE, BalloonSize, BalloonType, BALLOON_VELX_NEGATIVE, BALLOON_VELX_POSITIVE +#include "param.h" // Para Param, ParamGame, param +#include "utils.h" // Para Zone, BLOCK void BalloonFormations::initFormations() { // Calcular posiciones base diff --git a/source/balloon_formations.h b/source/balloon_formations.h index 8ccc781..870844e 100644 --- a/source/balloon_formations.h +++ b/source/balloon_formations.h @@ -1,12 +1,12 @@ #pragma once -#include "balloon.h" // Para BALLOON_VELX_NEGATIVE, BALLOON_VELX_POSITIVE -#include -#include -#include -#include -#include -#include +#include // Para copy +#include // Para map +#include // Para optional +#include // Para string +#include // Para vector + +#include "balloon.h" // Para BalloonSize, BalloonType // --- Constantes de configuración --- diff --git a/source/balloon_manager.h b/source/balloon_manager.h index ffc4704..5022b3e 100644 --- a/source/balloon_manager.h +++ b/source/balloon_manager.h @@ -2,10 +2,11 @@ #include // Para SDL_FRect -#include // Para array -#include // Para shared_ptr, unique_ptr -#include // Para string -#include // Para vector +#include // Para max +#include // Para array +#include // Para shared_ptr, unique_ptr +#include // Para string +#include // Para vector #include "balloon.h" // Para BALLOON_SPEED, Balloon, BalloonSize (ptr only), BalloonType (ptr only) #include "balloon_formations.h" // Para BalloonFormations diff --git a/source/director.cpp b/source/director.cpp index 05450ad..13464f3 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -21,12 +21,11 @@ #include "input.h" // Para Input, InputAction #include "lang.h" // Para setLanguage #include "manage_hiscore_table.h" // Para ManageHiScoreTable -#include "notifier.h" // Para Notifier #include "options.h" // Para GamepadOptions, controllers, loa... #include "param.h" // Para loadParamsFromFile #include "resource.h" // Para Resource #include "screen.h" // Para Screen -#include "section.h" // Para Name, Options, name, options +#include "section.hpp" // Para Name, Options, name, options #include "sections/credits.h" // Para Credits #include "sections/game.h" // Para Game, GAME_MODE_DEMO_OFF, GAME_M... #include "sections/hiscore_table.h" // Para HiScoreTable @@ -34,6 +33,7 @@ #include "sections/intro.h" // Para Intro #include "sections/logo.h" // Para Logo #include "sections/title.h" // Para Title +#include "ui/notifier.h" // Para Notifier #include "ui/service_menu.h" // Para ServiceMenu #include "utils.h" // Para Overrides, overrides, getPath diff --git a/source/explosions.cpp b/source/explosions.cpp index 91b2dd7..9c96a93 100644 --- a/source/explosions.cpp +++ b/source/explosions.cpp @@ -1,5 +1,7 @@ #include "explosions.h" +#include // Para max + #include "animated_sprite.h" // Para AnimatedSprite class Texture; // lines 4-4 diff --git a/source/global_events.cpp b/source/global_events.cpp index 9a08f1e..7311f4c 100644 --- a/source/global_events.cpp +++ b/source/global_events.cpp @@ -4,7 +4,7 @@ #include "mouse.h" // Para handleEvent #include "screen.h" -#include "section.h" // Para Name, Options, name, options +#include "section.hpp" // Para Name, Options, name, options namespace GlobalEvents { // Comprueba los eventos que se pueden producir en cualquier sección del juego diff --git a/source/global_inputs.cpp b/source/global_inputs.cpp index 080e9d4..b24639d 100644 --- a/source/global_inputs.cpp +++ b/source/global_inputs.cpp @@ -7,10 +7,10 @@ #include "audio.h" // Para Audio #include "input.h" // Para Input, INPUT_DO_NOT_ALLOW_REPEAT, Input... #include "lang.h" // Para getText, Code, getNextLangCode, loadFro... -#include "notifier.h" // Para Notifier #include "options.h" // Para SettingsOptions, settings, VideoOptions #include "screen.h" // Para Screen -#include "section.h" // Para Name, name, Options, options, AttractMode +#include "section.hpp" // Para Name, name, Options, options, AttractMode +#include "ui/notifier.h" // Para Notifier #include "ui/service_menu.h" // Para ServiceMenu #include "utils.h" // Para boolToOnOff diff --git a/source/options.h b/source/options.h index de5258d..636a1a7 100644 --- a/source/options.h +++ b/source/options.h @@ -2,9 +2,10 @@ #include // Para SDL_GamepadButton, SDL_ScaleMode -#include // Para string, basic_string -#include -#include // Para vector +#include // Para copy +#include // Para allocator, string +#include // Para move +#include // Para vector #include "input.h" // Para InputAction, InputDevice #include "lang.h" // Para Code diff --git a/source/screen.cpp b/source/screen.cpp index 336add8..110aa53 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -11,11 +11,11 @@ #include "asset.h" // Para Asset #include "external/jail_shader.h" // Para init, render #include "mouse.h" // Para updateCursorVisibility -#include "notifier.h" // Para Notifier #include "options.h" // Para VideoOptions, video, WindowOptions #include "param.h" // Para Param, param, ParamGame, ParamDebug #include "text.h" // Para Text, TEXT_COLOR, TEXT_STROKE #include "texture.h" // Para Texture +#include "ui/notifier.h" // Para Notifier #include "ui/service_menu.h" // Para ServiceMenu // Singleton diff --git a/source/section.cpp b/source/section.cpp deleted file mode 100644 index 11827ed..0000000 --- a/source/section.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "section.h" - -namespace Section { -Name name; -Options options; -AttractMode attract_mode; -} // namespace Section \ No newline at end of file diff --git a/source/section.h b/source/section.hpp similarity index 89% rename from source/section.h rename to source/section.hpp index df488e0..8b1c71c 100644 --- a/source/section.h +++ b/source/section.hpp @@ -42,7 +42,7 @@ enum class AttractMode { }; // --- Variables globales de estado --- -extern Name name; // Sección actual -extern Options options; // Opción seleccionada en la sección -extern AttractMode attract_mode; // Estado del Attract Mode +inline Name name = Name::RESET; +inline Options options = Options::NONE; +inline AttractMode attract_mode = AttractMode::TITLE_TO_DEMO; } // namespace Section \ No newline at end of file diff --git a/source/sections/credits.cpp b/source/sections/credits.cpp index 707d7fa..1415f29 100644 --- a/source/sections/credits.cpp +++ b/source/sections/credits.cpp @@ -21,7 +21,7 @@ #include "player.h" // Para Player, PlayerState #include "resource.h" // Para Resource #include "screen.h" // Para Screen -#include "section.h" // Para Name, name +#include "section.hpp" // Para Name, name #include "sprite.h" // Para Sprite #include "text.h" // Para Text, TEXT_CENTER, TEXT_SHADOW #include "texture.h" // Para Texture diff --git a/source/sections/game.cpp b/source/sections/game.cpp index 4bd2e9a..4d33549 100644 --- a/source/sections/game.cpp +++ b/source/sections/game.cpp @@ -21,19 +21,19 @@ #include "item.h" // Para Item, ItemType #include "lang.h" // Para getText #include "manage_hiscore_table.h" // Para HiScoreEntry, ManageHiScoreTable -#include "notifier.h" // Para Notifier #include "param.h" // Para Param, param, ParamGame, ParamScor... #include "path_sprite.h" // Para Path, PathSprite, createPath, Path... #include "player.h" // Para Player, PlayerState #include "resource.h" // Para Resource #include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREB... #include "screen.h" // Para Screen -#include "section.h" // Para Name, name, AttractMode, Options +#include "section.hpp" // Para Name, name, AttractMode, Options #include "smart_sprite.h" // Para SmartSprite #include "stage.h" // Para number, get, Stage, total_power #include "tabe.h" // Para Tabe, TabeState #include "text.h" // Para Text #include "texture.h" // Para Texture +#include "ui/notifier.h" // Para Notifier #include "ui/service_menu.h" // Para ServiceMenu // Constructor diff --git a/source/sections/hiscore_table.cpp b/source/sections/hiscore_table.cpp index cd2cf59..41f0eed 100644 --- a/source/sections/hiscore_table.cpp +++ b/source/sections/hiscore_table.cpp @@ -20,7 +20,7 @@ #include "path_sprite.h" // Para PathSprite, Path, PathType #include "resource.h" // Para Resource #include "screen.h" // Para Screen -#include "section.h" // Para Name, name, Options, options +#include "section.hpp" // Para Name, name, Options, options #include "sprite.h" // Para Sprite #include "text.h" // Para Text, TEXT_SHADOW, TEXT_COLOR #include "texture.h" // Para Texture diff --git a/source/sections/instructions.cpp b/source/sections/instructions.cpp index 3b6b037..141c099 100644 --- a/source/sections/instructions.cpp +++ b/source/sections/instructions.cpp @@ -17,7 +17,7 @@ #include "param.h" // Para Param, param, ParamGame, ParamFade, Param... #include "resource.h" // Para Resource #include "screen.h" // Para Screen -#include "section.h" // Para Name, name, Options, options +#include "section.hpp" // Para Name, name, Options, options #include "sprite.h" // Para Sprite #include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR, TEXT_SHADOW #include "tiled_bg.h" // Para TiledBG, TiledBGMode diff --git a/source/sections/intro.cpp b/source/sections/intro.cpp index 2c5b17d..785240b 100644 --- a/source/sections/intro.cpp +++ b/source/sections/intro.cpp @@ -18,7 +18,7 @@ #include "path_sprite.h" // Para PathSprite, PathType #include "resource.h" // Para Resource #include "screen.h" // Para Screen -#include "section.h" // Para Name, name, Options, options +#include "section.hpp" // Para Name, name, Options, options #include "text.h" // Para Text #include "texture.h" // Para Texture #include "tiled_bg.h" // Para TiledBG, TiledBGMode diff --git a/source/sections/logo.cpp b/source/sections/logo.cpp index d7a3086..c1b5998 100644 --- a/source/sections/logo.cpp +++ b/source/sections/logo.cpp @@ -12,7 +12,7 @@ #include "param.h" // Para Param, ParamGame, param #include "resource.h" // Para Resource #include "screen.h" // Para Screen -#include "section.h" // Para Name, name +#include "section.hpp" // Para Name, name #include "sprite.h" // Para Sprite #include "texture.h" // Para Texture #include "utils.h" // Para Color, Zone diff --git a/source/sections/title.cpp b/source/sections/title.cpp index 3bddd22..b891439 100644 --- a/source/sections/title.cpp +++ b/source/sections/title.cpp @@ -16,16 +16,16 @@ #include "global_inputs.h" // Para check #include "input.h" // Para Input, INPUT_DO_NOT_ALLOW_REPEAT, Input... #include "lang.h" // Para getText -#include "notifier.h" // Para Notifier #include "options.h" // Para GamepadOptions, controllers, getPlayerW... #include "param.h" // Para Param, param, ParamGame, ParamTitle #include "player.h" // Para Player, PlayerState #include "resource.h" // Para Resource #include "screen.h" // Para Screen -#include "section.h" // Para Name, name, Options, options, AttractMode +#include "section.hpp" // Para Name, name, Options, options, AttractMode #include "sprite.h" // Para Sprite #include "text.h" // Para TEXT_CENTER, TEXT_SHADOW, Text #include "tiled_bg.h" // Para TiledBG, TiledBGMode +#include "ui/notifier.h" // Para Notifier #include "ui/service_menu.h" // Para ServiceMenu #include "utils.h" // Para Color, Zone, NO_TEXT_COLOR, TITLE_SHADO... diff --git a/source/sections/title.h b/source/sections/title.h index 95da115..68e3411 100644 --- a/source/sections/title.h +++ b/source/sections/title.h @@ -6,7 +6,7 @@ #include #include -#include "section.h" // Para Options +#include "section.hpp" // Para Options class DefineButtons; class Fade; diff --git a/source/sprite.cpp b/source/sprite.cpp index 6ca76ff..ba4b267 100644 --- a/source/sprite.cpp +++ b/source/sprite.cpp @@ -1,6 +1,6 @@ #include "sprite.h" -#include +#include // Para move #include "texture.h" // Para Texture diff --git a/source/stage.h b/source/stage.h index 47148cb..ed17fd7 100644 --- a/source/stage.h +++ b/source/stage.h @@ -1,6 +1,6 @@ #pragma once -#include +#include // Para vector /* Namespace Stage: gestiona los datos y operaciones de las fases del juego. diff --git a/source/ui/menu_option.h b/source/ui/menu_option.h index 7b262ff..b4a3590 100644 --- a/source/ui/menu_option.h +++ b/source/ui/menu_option.h @@ -8,7 +8,7 @@ #include "lang.h" // Para las traducciones #include "options.h" // Para acceder a las variables de configuración -#include "section.h" // Para las acciones como Quit o Reset +#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 diff --git a/source/ui/menu_renderer.cpp b/source/ui/menu_renderer.cpp index 185a818..3de965f 100644 --- a/source/ui/menu_renderer.cpp +++ b/source/ui/menu_renderer.cpp @@ -1,7 +1,7 @@ #include "menu_renderer.h" -#include // Para max -#include // Para pair, move +#include // Para max +#include // Para pair, move #include "menu_option.h" // Para MenuOption #include "param.h" // Para Param, param, ParamServiceMenu, ParamGame diff --git a/source/ui/menu_renderer.h b/source/ui/menu_renderer.h index ee6e117..a9c7ef2 100644 --- a/source/ui/menu_renderer.h +++ b/source/ui/menu_renderer.h @@ -1,6 +1,7 @@ #pragma once #include // Para SDL_FRect, Uint32 + #include #include // Para size_t #include // Para shared_ptr, unique_ptr diff --git a/source/notifier.cpp b/source/ui/notifier.cpp similarity index 100% rename from source/notifier.cpp rename to source/ui/notifier.cpp diff --git a/source/notifier.h b/source/ui/notifier.h similarity index 100% rename from source/notifier.h rename to source/ui/notifier.h diff --git a/source/ui/service_menu.cpp b/source/ui/service_menu.cpp index 5095be8..ec09a13 100644 --- a/source/ui/service_menu.cpp +++ b/source/ui/service_menu.cpp @@ -1,6 +1,6 @@ #include "ui/service_menu.h" -#include // Para max +#include // Para max #include "audio.h" // Para Audio #include "lang.h" // Para getText, getCodeFromName, getNameFromCode @@ -10,7 +10,7 @@ #include "param.h" // Para Param, param, ParamGame, ParamServiceMenu #include "resource.h" // Para Resource #include "screen.h" // Para Screen -#include "section.h" // Para Name, name, Options, options +#include "section.hpp" // Para Name, name, Options, options #include "ui/ui_message.h" // Para UIMessage #include "utils.h" // Para Zone diff --git a/source/utils.h b/source/utils.h index a11940e..9b7b0e7 100644 --- a/source/utils.h +++ b/source/utils.h @@ -1,7 +1,7 @@ // IWYU pragma: no_include #pragma once -#include // Para Uint8, SDL_FRect, SDL_FPoint, SDL_Renderer +#include // Para Uint8, SDL_FRect, SDL_FPoint, SDL_Renderer #include // Para max, min #include // Para array