eliminat soport per a arguments
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <stdexcept> // 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 {
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_SetLogPriority, SDL_LogCategory, SDL_LogPriority, SDL_Quit
|
||||
|
||||
#include <cstdlib> // Para srand, exit, rand, EXIT_FAILURE
|
||||
#include <ctime> // Para time
|
||||
#include <filesystem> // Para path, absolute
|
||||
#include <fstream> // Para ifstream, ofstream
|
||||
#include <iostream> // Para basic_ostream, operator<<, cerr
|
||||
#include <memory> // Para make_unique, unique_ptr
|
||||
#include <span> // Para span
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <string> // Para allocator, basic_string, char_traits, operator+, string, operator==
|
||||
#include <cstdlib> // Para srand, exit, rand, EXIT_FAILURE
|
||||
#include <ctime> // Para time
|
||||
#include <fstream> // Para ifstream, ofstream
|
||||
#include <iostream> // Para basic_ostream, operator<<, cerr
|
||||
#include <memory> // Para make_unique, unique_ptr
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <string> // 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<char*> 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<char*> 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<char*> 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";
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <SDL3/SDL.h> // Para SDL_AppResult, SDL_Event
|
||||
|
||||
#include <memory> // Para unique_ptr
|
||||
#include <span> // Para Span
|
||||
#include <string> // 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<char*> 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<char*> 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
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_EventType, SDL_Event, SDL_LogInfo, SDL_LogCategory
|
||||
|
||||
#include <cstddef> // Para size_t
|
||||
#include <cstddef> // Para size_t
|
||||
#include <iostream> // Para std::cout
|
||||
#include <string> // Para allocator, operator+, string
|
||||
#include <vector> // Para vector
|
||||
#include <string> // Para allocator, operator+, string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "input.hpp" // Para Input
|
||||
#include "lang.hpp" // Para getText
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <unordered_map> // Para unordered_map, _Node_iterator, operator==, _Node_iterator_base, _Node_const_iterator
|
||||
#include <utility> // Para pair, move
|
||||
|
||||
|
||||
// Singleton
|
||||
Input* Input::instance = nullptr;
|
||||
|
||||
|
||||
@@ -10,12 +10,10 @@ Actualizando a la versión "Arcade Edition" en 08/05/2024
|
||||
#define SDL_MAIN_USE_CALLBACKS 1
|
||||
#include <SDL3/SDL_main.h>
|
||||
|
||||
#include <span> // Para span
|
||||
|
||||
#include "director.hpp" // Para Director
|
||||
|
||||
SDL_AppResult SDL_AppInit(void** appstate, int argc, char* argv[]) {
|
||||
*appstate = new Director(argc, std::span<char*>(argv, argc));
|
||||
SDL_AppResult SDL_AppInit(void** appstate, int /*argc*/, char** /*argv*/) {
|
||||
*appstate = new Director();
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <ranges> // Para __find_if_fn, find_if
|
||||
#include <utility> // Para move
|
||||
|
||||
#include "utils.hpp" // Para getFileName
|
||||
#include "utils.hpp" // Para getFileName
|
||||
|
||||
// Resetea la tabla a los valores por defecto
|
||||
void ManageHiScoreTable::clear() {
|
||||
|
||||
@@ -12,16 +12,16 @@
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <utility> // 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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<Surface>; // 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<Surface>; // 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
|
||||
};
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user