diff --git a/source/audio.cpp b/source/audio.cpp index d6fd0fe..2ccb4b9 100644 --- a/source/audio.cpp +++ b/source/audio.cpp @@ -20,8 +20,8 @@ // clang-format on #include "external/jail_audio.hpp" // Para JA_FadeOutMusic, JA_Init, JA_PauseM... -#include "options.hpp" // Para AudioOptions, audio, MusicOptions -#include "resource.hpp" // Para Resource +#include "options.hpp" // Para AudioOptions, audio, MusicOptions +#include "resource.hpp" // Para Resource // Singleton Audio* Audio::instance = nullptr; diff --git a/source/demo.cpp b/source/demo.cpp index dae1e06..513412b 100644 --- a/source/demo.cpp +++ b/source/demo.cpp @@ -6,7 +6,7 @@ #include // Para runtime_error #include "resource_helper.hpp" // Para ResourceHelper -#include "utils.hpp" // Para getFileName +#include "utils.hpp" // Para getFileName // Carga el fichero de datos para la demo auto loadDemoDataFromFile(const std::string& file_path) -> DemoData { diff --git a/source/director.cpp b/source/director.cpp index e6764ac..e17059e 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -3,15 +3,13 @@ #include // Para SDL_SetLogPriority, SDL_LogCategory, SDL_LogPriority, SDL_Quit -#include // Para srand, exit, rand, EXIT_FAILURE -#include // Para time -#include // Para path, absolute -#include // Para ifstream, ofstream -#include // Para basic_ostream, operator<<, cerr -#include // Para make_unique, unique_ptr -#include // Para span -#include // Para runtime_error -#include // Para allocator, basic_string, char_traits, operator+, string, operator== +#include // Para srand, exit, rand, EXIT_FAILURE +#include // Para time +#include // Para ifstream, ofstream +#include // Para basic_ostream, operator<<, cerr +#include // Para make_unique, unique_ptr +#include // Para runtime_error +#include // Para allocator, basic_string, char_traits, operator+, string, operator== #include "asset.hpp" // Para Asset #include "audio.hpp" // Para Audio @@ -38,10 +36,9 @@ #include "system_utils.hpp" // Para createApplicationFolder, resultToString, Result #include "ui/notifier.hpp" // Para Notifier #include "ui/service_menu.hpp" // Para ServiceMenu -#include "utils.hpp" // Para Overrides, overrides // Constructor -Director::Director(int argc, std::span argv) { +Director::Director() { Section::attract_mode = Section::AttractMode::TITLE_TO_DEMO; // Establece el nivel de prioridad de la categoría de registro @@ -53,8 +50,9 @@ Director::Director(int argc, std::span argv) { std::cout << "Game start\n"; - // Comprueba los parametros del programa - checkProgramArguments(argc, argv); + // Obtener la ruta del ejecutable desde SDL + const char* base_path = SDL_GetBasePath(); + executable_path_ = (base_path != nullptr) ? base_path : ""; // Crea la carpeta del sistema donde guardar los datos persistentes createSystemFolder("jailgames"); @@ -173,11 +171,7 @@ void Director::loadScoreFile() { #ifdef _DEBUG manager->clear(); #else - if (overrides.clear_hi_score_table) { - manager->clear(); - } else { - manager->loadFromFile(Asset::get()->getPath("score.bin")); - } + manager->loadFromFile(Asset::get()->getPath("score.bin")); #endif } @@ -199,29 +193,6 @@ void Director::loadAssets() { } } -// Comprueba los parametros del programa -void Director::checkProgramArguments(int argc, std::span argv) { - // Obtener la ruta absoluta del ejecutable - std::filesystem::path exe_path = std::filesystem::absolute(argv[0]); - executable_path_ = exe_path.parent_path().string(); - - // Asegurar que termine con separador de directorio - if (!executable_path_.empty() && executable_path_.back() != '/' && executable_path_.back() != '\\') { - executable_path_ += "/"; - } - - // Comprueba el resto de parámetros - for (int i = 1; i < argc; ++i) { - std::string arg = argv[i]; - - if (arg == "--320x240") { - overrides.param_file = arg; - } else if (arg == "--clear_score") { - overrides.clear_hi_score_table = true; - } - } -} - // Carga debug.yaml desde la carpeta del sistema (solo en _DEBUG) void Director::loadDebugConfig() { const std::string DEBUG_FILE = system_folder_ + "/debug.yaml"; diff --git a/source/director.hpp b/source/director.hpp index be0789c..5ac99a4 100644 --- a/source/director.hpp +++ b/source/director.hpp @@ -3,7 +3,6 @@ #include // Para SDL_AppResult, SDL_Event #include // Para unique_ptr -#include // Para Span #include // Para string #include "section.hpp" // Para Section::Name @@ -25,11 +24,11 @@ class Credits; class Director { public: // --- Constructor y destructor --- - Director(int argc, std::span argv); + Director(); ~Director(); // --- Callbacks para SDL_MAIN_USE_CALLBACKS --- - auto iterate() -> SDL_AppResult; // Avanza un frame de la sección activa + auto iterate() -> SDL_AppResult; // Avanza un frame de la sección activa auto handleEvent(SDL_Event& event) -> SDL_AppResult; // Procesa un evento SDL // --- Debug config (accesible desde otras clases) --- @@ -73,8 +72,7 @@ class Director { void loadDebugConfig(); // Carga debug.yaml (solo en _DEBUG) // --- Gestión de entrada y archivos --- - void loadAssets(); // Crea el índice de archivos disponibles - void checkProgramArguments(int argc, std::span argv); // Verifica los parámetros del programa // NOLINT(modernize-avoid-c-arrays) + void loadAssets(); // Crea el índice de archivos disponibles // --- Gestión de secciones --- void handleSectionTransition(); // Destruye la sección anterior y construye la nueva si Section::name ha cambiado diff --git a/source/global_events.cpp b/source/global_events.cpp index 7c13b82..19e0ecb 100644 --- a/source/global_events.cpp +++ b/source/global_events.cpp @@ -2,10 +2,10 @@ #include // Para SDL_EventType, SDL_Event, SDL_LogInfo, SDL_LogCategory -#include // Para size_t +#include // Para size_t #include // Para std::cout -#include // Para allocator, operator+, string -#include // Para vector +#include // Para allocator, operator+, string +#include // Para vector #include "input.hpp" // Para Input #include "lang.hpp" // Para getText diff --git a/source/input.cpp b/source/input.cpp index c849f1b..c116704 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -8,7 +8,6 @@ #include // Para unordered_map, _Node_iterator, operator==, _Node_iterator_base, _Node_const_iterator #include // Para pair, move - // Singleton Input* Input::instance = nullptr; diff --git a/source/main.cpp b/source/main.cpp index 0d07f11..f9d7fa1 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -10,12 +10,10 @@ Actualizando a la versión "Arcade Edition" en 08/05/2024 #define SDL_MAIN_USE_CALLBACKS 1 #include -#include // Para span - #include "director.hpp" // Para Director -SDL_AppResult SDL_AppInit(void** appstate, int argc, char* argv[]) { - *appstate = new Director(argc, std::span(argv, argc)); +SDL_AppResult SDL_AppInit(void** appstate, int /*argc*/, char** /*argv*/) { + *appstate = new Director(); return SDL_APP_CONTINUE; } diff --git a/source/manage_hiscore_table.cpp b/source/manage_hiscore_table.cpp index 25055f4..54de1ba 100644 --- a/source/manage_hiscore_table.cpp +++ b/source/manage_hiscore_table.cpp @@ -11,7 +11,7 @@ #include // Para __find_if_fn, find_if #include // Para move -#include "utils.hpp" // Para getFileName +#include "utils.hpp" // Para getFileName // Resetea la tabla a los valores por defecto void ManageHiScoreTable::clear() { diff --git a/source/resource.cpp b/source/resource.cpp index ae372f3..47bef2e 100644 --- a/source/resource.cpp +++ b/source/resource.cpp @@ -12,16 +12,16 @@ #include // Para runtime_error #include // Para move -#include "asset.hpp" // Para Asset -#include "color.hpp" // Para Color, NO_COLOR_MOD +#include "asset.hpp" // Para Asset +#include "color.hpp" // Para Color, NO_COLOR_MOD #include "external/jail_audio.hpp" // Para JA_LoadMusic, JA_LoadSound, JA_DeleteMusic, JA_DeleteSound -#include "lang.hpp" // Para getText -#include "param.hpp" // Para Param, param, ParamPlayer, ParamResource, ParamGame -#include "resource_helper.hpp" // Para loadFile -#include "screen.hpp" // Para Screen -#include "text.hpp" // Para Text -#include "utils.hpp" // Para getFileName -#include "version.h" // Para APP_NAME, GIT_HASH +#include "lang.hpp" // Para getText +#include "param.hpp" // Para Param, param, ParamPlayer, ParamResource, ParamGame +#include "resource_helper.hpp" // Para loadFile +#include "screen.hpp" // Para Screen +#include "text.hpp" // Para Text +#include "utils.hpp" // Para getFileName +#include "version.h" // Para APP_NAME, GIT_HASH struct JA_Music_t; // lines 11-11 struct JA_Sound_t; // lines 12-12 diff --git a/source/sections/hiscore_table.hpp b/source/sections/hiscore_table.hpp index 90ad0f9..d95a90b 100644 --- a/source/sections/hiscore_table.hpp +++ b/source/sections/hiscore_table.hpp @@ -28,8 +28,8 @@ class HiScoreTable { ~HiScoreTable(); // --- Callbacks para el bucle SDL_MAIN_USE_CALLBACKS --- - void iterate(); // Ejecuta un frame - void handleEvent(const SDL_Event& event); // Procesa un evento + void iterate(); // Ejecuta un frame + void handleEvent(const SDL_Event& event); // Procesa un evento // --- Bucle principal legacy (fallback) --- void run(); diff --git a/source/sections/instructions.hpp b/source/sections/instructions.hpp index 5c489a4..9081666 100644 --- a/source/sections/instructions.hpp +++ b/source/sections/instructions.hpp @@ -49,8 +49,8 @@ class Instructions { ~Instructions(); // --- Callbacks para el bucle SDL_MAIN_USE_CALLBACKS --- - void iterate(); // Ejecuta un frame - void handleEvent(const SDL_Event& event); // Procesa un evento + void iterate(); // Ejecuta un frame + void handleEvent(const SDL_Event& event); // Procesa un evento // --- Bucle principal legacy (fallback) --- void run(); diff --git a/source/sections/intro.hpp b/source/sections/intro.hpp index 27ab0e3..c5a3e0d 100644 --- a/source/sections/intro.hpp +++ b/source/sections/intro.hpp @@ -31,8 +31,8 @@ class Intro { ~Intro() = default; // --- Callbacks para el bucle SDL_MAIN_USE_CALLBACKS --- - void iterate(); // Ejecuta un frame - void handleEvent(const SDL_Event& event); // Procesa un evento + void iterate(); // Ejecuta un frame + void handleEvent(const SDL_Event& event); // Procesa un evento // --- Bucle principal legacy (fallback) --- void run(); diff --git a/source/sections/logo.hpp b/source/sections/logo.hpp index dc6898c..f921dc8 100644 --- a/source/sections/logo.hpp +++ b/source/sections/logo.hpp @@ -32,8 +32,8 @@ class Logo { ~Logo(); // --- Callbacks para el bucle SDL_MAIN_USE_CALLBACKS --- - void iterate(); // Ejecuta un frame - void handleEvent(const SDL_Event& event); // Procesa un evento + void iterate(); // Ejecuta un frame + void handleEvent(const SDL_Event& event); // Procesa un evento // --- Bucle principal legacy (fallback) --- void run(); diff --git a/source/sections/title.hpp b/source/sections/title.hpp index 88ca72b..03844bb 100644 --- a/source/sections/title.hpp +++ b/source/sections/title.hpp @@ -41,8 +41,8 @@ class Title { ~Title(); // --- Callbacks para el bucle SDL_MAIN_USE_CALLBACKS --- - void iterate(); // Ejecuta un frame - void handleEvent(const SDL_Event& event); // Procesa un evento + void iterate(); // Ejecuta un frame + void handleEvent(const SDL_Event& event); // Procesa un evento // --- Bucle principal legacy (fallback) --- void run(); diff --git a/source/texture.hpp b/source/texture.hpp index 905af43..75b8305 100644 --- a/source/texture.hpp +++ b/source/texture.hpp @@ -49,10 +49,10 @@ class Texture { void setAlpha(Uint8 alpha); // Establece el alpha para la modulación // --- Paletas --- - void addPaletteFromGifFile(const std::string& path); // Añade una paleta a la lista - void addPaletteFromPalFile(const std::string& path); // Añade una paleta a la lista - void setPaletteColor(int palette, int index, Uint32 color); // Establece un color de la paleta - void setPalette(size_t palette); // Cambia la paleta de la textura + void addPaletteFromGifFile(const std::string& path); // Añade una paleta a la lista + void addPaletteFromPalFile(const std::string& path); // Añade una paleta a la lista + void setPaletteColor(int palette, int index, Uint32 color); // Establece un color de la paleta + void setPalette(size_t palette); // Cambia la paleta de la textura // --- Getters --- [[nodiscard]] auto getWidth() const -> int; // Obtiene el ancho de la imagen @@ -74,10 +74,10 @@ class Texture { int current_palette_ = 0; // Índice de la paleta en uso // --- Métodos internos --- - auto loadSurface(const std::string& file_path) -> std::shared_ptr; // Crea una surface desde un fichero .gif - void flipSurface(); // Vuelca la surface en la textura - static auto loadPaletteFromFile(const std::string& file_path) -> Palette; // Carga una paleta desde un fichero - void unloadTexture(); // Libera la memoria de la textura - void unloadSurface(); // Libera la surface actual - static auto readPalFile(const std::string& file_path) -> Palette; // Carga una paleta desde un archivo .pal + auto loadSurface(const std::string& file_path) -> std::shared_ptr; // Crea una surface desde un fichero .gif + void flipSurface(); // Vuelca la surface en la textura + static auto loadPaletteFromFile(const std::string& file_path) -> Palette; // Carga una paleta desde un fichero + void unloadTexture(); // Libera la memoria de la textura + void unloadSurface(); // Libera la surface actual + static auto readPalFile(const std::string& file_path) -> Palette; // Carga una paleta desde un archivo .pal }; \ No newline at end of file diff --git a/source/utils.cpp b/source/utils.cpp index 033a79b..d63b574 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -14,9 +14,6 @@ #include "lang.hpp" // Para getText -// Variables -Overrides overrides = Overrides(); - // Calcula el cuadrado de la distancia entre dos puntos auto distanceSquared(int x1, int y1, int x2, int y2) -> double { const int DELTA_X = x2 - x1; diff --git a/source/utils.hpp b/source/utils.hpp index bb91f80..b0ac8a3 100644 --- a/source/utils.hpp +++ b/source/utils.hpp @@ -12,13 +12,6 @@ constexpr int BLOCK = 8; // --- Estructuras --- -struct Overrides { - std::string param_file; // Fichero de parametros a utilizar - bool clear_hi_score_table{false}; // Reinicia la tabla de records - - Overrides() = default; -}; - struct Circle { int x, y, r; // Coordenadas y radio Circle() @@ -41,9 +34,6 @@ struct Zone { float third_quarter_y; // Anclaje al 75% del eje Y }; -// --- Variables --- -extern Overrides overrides; // Configuración global de overrides - // --- Funciones --- // Colisiones y geometría