canviat Options de struct a namespace

This commit is contained in:
2025-10-26 14:01:08 +01:00
parent 8f49e442de
commit df4965a84b
59 changed files with 1470 additions and 1533 deletions

View File

@@ -3,9 +3,9 @@
#include <algorithm> // Para max
#include <memory> // Para __shared_ptr_access, shared_ptr
#include "core/resources/resource.hpp" // Para Resource
#include "core/rendering/text.hpp" // Para Text
#include "utils/utils.hpp" // Para Color
#include "core/resources/resource.hpp" // Para Resource
#include "utils/utils.hpp" // Para Color
// [SINGLETON]
Debug* Debug::debug_ = nullptr;

View File

@@ -11,15 +11,14 @@
#include <memory> // Para make_unique, unique_ptr
#include <string> // Para operator+, allocator, char_traits
#include "core/resources/asset.hpp" // Para Asset, AssetType
#include "game/gameplay/cheevos.hpp" // Para Cheevos
#include "core/system/debug.hpp" // Para Debug
#include "utils/defines.hpp" // Para WINDOW_CAPTION
#include "external/jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundV...
#include "core/input/input.hpp" // Para Input, InputAction
#include "game/gameplay/options.hpp" // Para Options, options, OptionsVideo
#include "core/resources/resource.hpp" // Para Resource
#include "core/rendering/screen.hpp" // Para Screen
#include "core/input/input.hpp" // Para Input, InputAction
#include "core/rendering/screen.hpp" // Para Screen
#include "core/resources/asset.hpp" // Para Asset, AssetType
#include "core/resources/resource.hpp" // Para Resource
#include "core/system/debug.hpp" // Para Debug
#include "external/jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundV...
#include "game/gameplay/cheevos.hpp" // Para Cheevos
#include "game/gameplay/options.hpp" // Para Options, options, OptionsVideo
#include "game/scenes/credits.hpp" // Para Credits
#include "game/scenes/ending.hpp" // Para Ending
#include "game/scenes/ending2.hpp" // Para Ending2
@@ -28,7 +27,8 @@
#include "game/scenes/loading_screen.hpp" // Para LoadingScreen
#include "game/scenes/logo.hpp" // Para Logo
#include "game/scenes/title.hpp" // Para Title
#include "game/ui/notifier.hpp" // Para Notifier
#include "game/ui/notifier.hpp" // Para Notifier
#include "utils/defines.hpp" // Para WINDOW_CAPTION
#ifndef _WIN32
#include <pwd.h>
@@ -39,7 +39,7 @@ Director::Director(int argc, const char* argv[]) {
std::cout << "Game start" << std::endl;
// Crea e inicializa las opciones del programa
initOptions();
Options::init();
// Comprueba los parametros del programa
executable_path_ = checkProgramArguments(argc, argv);
@@ -57,7 +57,7 @@ Director::Director(int argc, const char* argv[]) {
}
// Carga las opciones desde un fichero
loadOptionsFromFile(Asset::get()->get("config.txt"));
Options::loadFromFile(Asset::get()->get("config.txt"));
// Inicializa JailAudio
initJailAudio();
@@ -76,7 +76,7 @@ Director::Director(int argc, const char* argv[]) {
Director::~Director() {
// Guarda las opciones a un fichero
saveOptionsToFile(Asset::get()->get("config.txt"));
Options::saveToFile(Asset::get()->get("config.txt"));
// Destruye los singletones
Cheevos::destroy();
@@ -99,15 +99,15 @@ std::string Director::checkProgramArguments(int argc, const char* argv[]) {
std::string argument(argv[i]);
if (argument == "--console") {
options.console = true;
Options::console = true;
} else if (argument == "--infiniteLives") {
options.cheats.infinite_lives = Cheat::CheatState::ENABLED;
Options::cheats.infinite_lives = Options::Cheat::State::ENABLED;
} else if (argument == "--invincible") {
options.cheats.invincible = Cheat::CheatState::ENABLED;
Options::cheats.invincible = Options::Cheat::State::ENABLED;
} else if (argument == "--jailEnabled") {
options.cheats.jail_is_open = Cheat::CheatState::ENABLED;
Options::cheats.jail_is_open = Options::Cheat::State::ENABLED;
} else if (argument == "--altSkin") {
options.cheats.alternate_skin = Cheat::CheatState::ENABLED;
Options::cheats.alternate_skin = Options::Cheat::State::ENABLED;
}
}
@@ -175,19 +175,19 @@ void Director::initInput() {
Input::get()->discoverGameControllers();
// Teclado - Movimiento
if (options.keys == ControlScheme::CURSOR) {
if (Options::keys == Options::ControlScheme::CURSOR) {
Input::get()->bindKey(InputAction::JUMP, SDL_SCANCODE_UP);
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_LEFT);
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_RIGHT);
Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_UP);
Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_DOWN);
} else if (options.keys == ControlScheme::OPQA) {
} else if (Options::keys == Options::ControlScheme::OPQA) {
Input::get()->bindKey(InputAction::JUMP, SDL_SCANCODE_Q);
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_O);
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_P);
Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_Q);
Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_A);
} else if (options.keys == ControlScheme::WASD) {
} else if (Options::keys == Options::ControlScheme::WASD) {
Input::get()->bindKey(InputAction::JUMP, SDL_SCANCODE_W);
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_A);
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_D);
@@ -241,9 +241,9 @@ void Director::initJailAudio() {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_AUDIO could not initialize! SDL Error: %s", SDL_GetError());
} else {
JA_Init(48000, SDL_AUDIO_S16LE, 2);
if (options.audio.enabled) {
JA_SetMusicVolume(options.audio.music.volume);
JA_SetSoundVolume(options.audio.sound.volume);
if (Options::audio.enabled) {
JA_SetMusicVolume(Options::audio.music.volume);
JA_SetSoundVolume(Options::audio.sound.volume);
} else {
JA_SetMusicVolume(0);
JA_SetSoundVolume(0);
@@ -542,41 +542,41 @@ void Director::runGame() {
int Director::run() {
// Bucle principal
while (options.section.section != Section::QUIT) {
switch (options.section.section) {
case Section::LOGO:
while (Options::section.section != Options::Scene::QUIT) {
switch (Options::section.section) {
case Options::Scene::LOGO:
runLogo();
break;
case Section::LOADING_SCREEN:
case Options::Scene::LOADING_SCREEN:
runLoadingScreen();
break;
case Section::TITLE:
case Options::Scene::TITLE:
runTitle();
break;
case Section::CREDITS:
case Options::Scene::CREDITS:
runCredits();
break;
case Section::DEMO:
case Options::Scene::DEMO:
runDemo();
break;
case Section::GAME:
case Options::Scene::GAME:
runGame();
break;
case Section::GAME_OVER:
case Options::Scene::GAME_OVER:
runGameOver();
break;
case Section::ENDING:
case Options::Scene::ENDING:
runEnding();
break;
case Section::ENDING2:
case Options::Scene::ENDING2:
runEnding2();
break;

View File

@@ -1,6 +1,6 @@
#pragma once
#include <SDL3/SDL.h>
#include <SDL3/SDL.h>
#include <string> // Para string
@@ -19,7 +19,7 @@ class Director {
// Inicializa jail_audio
void initJailAudio();
// Inicializa el objeto Input
// Inicializa el objeto Input
void initInput();
// Crea el indice de ficheros