canvi de pc (toquejant Options)

This commit is contained in:
2025-06-14 16:28:36 +02:00
parent 4b8cc67b5c
commit 23e8f90274
27 changed files with 505 additions and 454 deletions

View File

@@ -44,7 +44,7 @@ Credits::Credits()
{
throw std::runtime_error("Failed to create SDL texture for text.");
}
section::name = section::Name::CREDITS;
Section::name = Section::Name::CREDITS;
balloon_manager_->setPlayArea(play_area_);
fade_in_->setColor(FADE_COLOR.r, FADE_COLOR.g, FADE_COLOR.b);
@@ -78,7 +78,7 @@ Credits::~Credits()
// Bucle principal
void Credits::run()
{
while (section::name == section::Name::CREDITS)
while (Section::name == Section::Name::CREDITS)
{
checkInput();
update();
@@ -134,7 +134,7 @@ void Credits::checkEvents()
SDL_Event event;
while (SDL_PollEvent(&event))
{
globalEvents::check(event);
GlobalEvents::check(event);
}
}
@@ -156,7 +156,7 @@ void Credits::checkInput()
}
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
globalInputs::check();
GlobalInputs::check();
}
// Crea la textura con el texto
@@ -169,10 +169,10 @@ void Credits::fillTextTexture()
SDL_RenderClear(Screen::get()->getRenderer());
const std::array<std::string, 10> TEXTS = {
lang::getText("[CREDITS] PROGRAMMED_AND_DESIGNED_BY"),
lang::getText("[CREDITS] PIXELART_DRAWN_BY"),
lang::getText("[CREDITS] MUSIC_COMPOSED_BY"),
lang::getText("[CREDITS] SOUND_EFFECTS"),
Lang::getText("[CREDITS] PROGRAMMED_AND_DESIGNED_BY"),
Lang::getText("[CREDITS] PIXELART_DRAWN_BY"),
Lang::getText("[CREDITS] MUSIC_COMPOSED_BY"),
Lang::getText("[CREDITS] SOUND_EFFECTS"),
"JAILDESIGNER",
"JAILDOCTOR (INTRO)",
"ERIC MATYAS (SOUNDIMAGE.ORG)",
@@ -481,7 +481,7 @@ void Credits::updateAllFades()
fade_out_->update();
if (fade_out_->hasEnded())
{
section::name = section::Name::HI_SCORE_TABLE;
Section::name = Section::Name::HI_SCORE_TABLE;
}
}

View File

@@ -28,7 +28,7 @@ void DefineButtons::render()
{
if (enabled_)
{
text_->writeCentered(x_, y_ - 10, lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(options.controllers.at(index_controller_).player_id));
text_->writeCentered(x_, y_ - 10, Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(options.controllers.at(index_controller_).player_id));
text_->writeCentered(x_, y_, controller_names_.at(index_controller_));
text_->writeCentered(x_, y_ + 10, buttons_.at(index_button_).label);
}
@@ -135,9 +135,9 @@ bool DefineButtons::checkButtonNotInUse(SDL_GamepadButton button)
void DefineButtons::clearButtons()
{
buttons_.clear();
buttons_.emplace_back(lang::getText("[DEFINE_BUTTONS] FIRE_LEFT"), InputAction::FIRE_LEFT, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(lang::getText("[DEFINE_BUTTONS] FIRE_UP"), InputAction::FIRE_CENTER, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(lang::getText("[DEFINE_BUTTONS] FIRE_RIGHT"), InputAction::FIRE_RIGHT, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(lang::getText("[DEFINE_BUTTONS] START"), InputAction::START, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(lang::getText("[DEFINE_BUTTONS] SERVICE_MENU"), InputAction::SERVICE, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] FIRE_LEFT"), InputAction::FIRE_LEFT, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] FIRE_UP"), InputAction::FIRE_CENTER, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] FIRE_RIGHT"), InputAction::FIRE_RIGHT, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] START"), InputAction::START, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] SERVICE_MENU"), InputAction::SERVICE, SDL_GAMEPAD_BUTTON_INVALID);
}

View File

@@ -49,13 +49,13 @@ Director::Director(int argc, const char *argv[])
section::name = section::Name::GAME;
section::options = section::Options::GAME_PLAY_1P;
#elif DEBUG
section::name = section::Name::LOGO;
section::options = section::Options::GAME_PLAY_1P;
Section::name = Section::Name::LOGO;
Section::options = Section::Options::GAME_PLAY_1P;
#else // NORMAL GAME
section::name = section::Name::LOGO;
section::options = section::Options::NONE;
#endif
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
Section::attract_mode = Section::AttractMode::TITLE_TO_DEMO;
// Establece el nivel de prioridad de la categoría de registro
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
@@ -93,7 +93,7 @@ void Director::init()
loadScoreFile(); // Carga el archivo de puntuaciones
// Inicialización de subsistemas principales
lang::setLanguage(options.game.language); // Carga el archivo de idioma
Lang::setLanguage(options.game.language); // Carga el archivo de idioma
Screen::init(); // Inicializa la pantalla y el sistema de renderizado
Audio::init(); // Activa el sistema de audio
Resource::init(); // Inicializa el sistema de gestión de recursos
@@ -123,7 +123,7 @@ void Director::close()
SDL_Quit();
// Apaga el sistema
shutdownSystem(section::options == section::Options::SHUTDOWN);
shutdownSystem(Section::options == Section::Options::SHUTDOWN);
}
// Carga los parametros
@@ -574,7 +574,7 @@ void Director::runTitle()
// Ejecuta la sección donde se juega al juego
void Director::runGame()
{
const auto player_id = section::options == section::Options::GAME_PLAY_1P ? 1 : 2;
const auto player_id = Section::options == Section::Options::GAME_PLAY_1P ? 1 : 2;
#ifdef DEBUG
constexpr auto current_stage = 0;
#else
@@ -619,49 +619,49 @@ void Director::reset()
{
saveOptionsFile(Asset::get()->get("config.txt"));
loadOptionsFile(Asset::get()->get("config.txt"));
lang::setLanguage(options.game.language);
Lang::setLanguage(options.game.language);
Audio::get()->stopMusic();
Audio::get()->stopAllSounds();
if (section::options == section::Options::RELOAD || true)
if (Section::options == Section::Options::RELOAD || true)
{
Resource::get()->reload();
}
ServiceMenu::get()->reset();
section::name = section::Name::LOGO;
Section::name = Section::Name::LOGO;
}
int Director::run()
{
// Bucle principal
while (section::name != section::Name::QUIT)
while (Section::name != Section::Name::QUIT)
{
switch (section::name)
switch (Section::name)
{
case section::Name::RESET:
case Section::Name::RESET:
reset();
break;
case section::Name::LOGO:
case Section::Name::LOGO:
runLogo();
break;
case section::Name::INTRO:
case Section::Name::INTRO:
runIntro();
break;
case section::Name::TITLE:
case Section::Name::TITLE:
runTitle();
break;
case section::Name::GAME:
case Section::Name::GAME:
runGame();
break;
case section::Name::HI_SCORE_TABLE:
case Section::Name::HI_SCORE_TABLE:
runHiScoreTable();
break;
case section::Name::GAME_DEMO:
case Section::Name::GAME_DEMO:
runDemoGame();
break;
case section::Name::INSTRUCTIONS:
case Section::Name::INSTRUCTIONS:
runInstructions();
break;
case section::Name::CREDITS:
case Section::Name::CREDITS:
runCredits();
break;
default:

View File

@@ -1,7 +1,7 @@
#pragma once
#include <string> // Para manejar cadenas de texto
namespace lang
namespace Lang
{
enum class Code : int;
}
@@ -47,7 +47,7 @@ private:
void reset(); // Reinicia objetos y vuelve a la sección inicial
// --- Gestión de archivos de idioma ---
std::string getLangFile(lang::Code code); // Obtiene un fichero de idioma según el código
std::string getLangFile(Lang::Code code); // Obtiene un fichero de idioma según el código
// --- Apagado del sistema ---
void shutdownSystem(bool should_shutdown); // Apaga el sistema

View File

@@ -52,8 +52,8 @@ Game::Game(int player_id, int current_stage, bool demo)
demo_.enabled = demo;
// Otras variables
section::name = section::Name::GAME;
section::options = section::Options::NONE;
Section::name = Section::Name::GAME;
Section::options = Section::Options::NONE;
Stage::init();
Stage::number = current_stage;
@@ -109,7 +109,7 @@ Game::~Game()
// [Modo JUEGO] Guarda puntuaciones y transita a modo título
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
manager->saveToFile(Asset::get()->get("score.bin"));
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
Section::attract_mode = Section::AttractMode::TITLE_TO_DEMO;
Audio::get()->stopMusic();
}
@@ -276,7 +276,7 @@ void Game::updateStage()
else
{
auto text = Resource::get()->getText("04b_25_2x");
const std::string caption = std::to_string(10 - Stage::number) + lang::getText("[GAME_TEXT] 2");
const std::string caption = std::to_string(10 - Stage::number) + Lang::getText("[GAME_TEXT] 2");
createMessage(paths, text->writeToTexture(caption, 1, -4));
}
}
@@ -338,14 +338,14 @@ void Game::updateGameStateGameOver()
if (game_completed_counter_ > 0)
{
// Los jugadores han completado el juego
section::name = section::Name::CREDITS;
Section::name = Section::Name::CREDITS;
}
else
{
// La partida ha terminado con la derrota de los jugadores
section::name = section::Name::HI_SCORE_TABLE;
Section::name = Section::Name::HI_SCORE_TABLE;
}
section::options = section::Options::HI_SCORE_AFTER_PLAYING;
Section::options = Section::Options::HI_SCORE_AFTER_PLAYING;
if (options.audio.enabled)
{
Audio::get()->stopAllSounds();
@@ -1090,7 +1090,7 @@ void Game::disableTimeStopItem()
// Bucle para el juego
void Game::run()
{
while (section::name == section::Name::GAME)
while (Section::name == Section::Name::GAME)
{
#ifndef RECORDING
checkInput();
@@ -1233,7 +1233,7 @@ void Game::checkEvents()
#ifdef DEBUG
checkDebugEvents(event);
#endif
globalEvents::check(event);
GlobalEvents::check(event);
}
}
@@ -1349,7 +1349,7 @@ void Game::checkInput()
}
// Verifica los inputs globales.
globalInputs::check();
GlobalInputs::check();
}
// Verifica si alguno de los controladores ha solicitado una pausa y actualiza el estado de pausa del juego.
@@ -1379,8 +1379,8 @@ void Game::DEMO_handlePassInput()
{
if (input_->checkAnyButtonPressed())
{
section::name = section::Name::TITLE; // Salir del modo demo y regresar al menú principal.
section::attract_mode = section::AttractMode::TITLE_TO_DEMO; // El juego volverá a mostrar la demo
Section::name = Section::Name::TITLE; // Salir del modo demo y regresar al menú principal.
Section::attract_mode = Section::AttractMode::TITLE_TO_DEMO; // El juego volverá a mostrar la demo
return;
}
}
@@ -1689,7 +1689,7 @@ void Game::initDifficultyVars()
// Variables relacionadas con la dificultad
switch (difficulty_)
{
case GameDifficulty::EASY:
case DifficultyCode::EASY:
{
balloon_manager_->setDefaultBalloonSpeed(BALLOON_SPEED[0]);
difficulty_score_multiplier_ = 0.5f;
@@ -1697,7 +1697,7 @@ void Game::initDifficultyVars()
break;
}
case GameDifficulty::NORMAL:
case DifficultyCode::NORMAL:
{
balloon_manager_->setDefaultBalloonSpeed(BALLOON_SPEED[0]);
difficulty_score_multiplier_ = 1.0f;
@@ -1705,7 +1705,7 @@ void Game::initDifficultyVars()
break;
}
case GameDifficulty::HARD:
case DifficultyCode::HARD:
{
balloon_manager_->setDefaultBalloonSpeed(BALLOON_SPEED[4]);
difficulty_score_multiplier_ = 1.5f;
@@ -1727,12 +1727,12 @@ void Game::initPlayers(int player_id)
const int Y = param.game.play_area.rect.h - 30;
players_.emplace_back(std::make_unique<Player>(1, param.game.play_area.first_quarter_x - 15, Y, demo_.enabled, param.game.play_area.rect, player_textures_[0], player_animations_));
players_.back()->setScoreBoardPanel(SCOREBOARD_LEFT_PANEL);
players_.back()->setName(lang::getText("[SCOREBOARD] 1"));
players_.back()->setName(Lang::getText("[SCOREBOARD] 1"));
players_.back()->setController(getController(players_.back()->getId()));
players_.emplace_back(std::make_unique<Player>(2, param.game.play_area.third_quarter_x - 15, Y, demo_.enabled, param.game.play_area.rect, player_textures_[1], player_animations_));
players_.back()->setScoreBoardPanel(SCOREBOARD_RIGHT_PANEL);
players_.back()->setName(lang::getText("[SCOREBOARD] 2"));
players_.back()->setName(Lang::getText("[SCOREBOARD] 2"));
players_.back()->setController(getController(players_.back()->getId()));
// Activa el jugador que coincide con el "player_id"
@@ -1783,7 +1783,7 @@ void Game::updateDemo()
// Si ha terminado el fundido, cambia de sección
if (fade_out_->hasEnded())
{
section::name = section::Name::HI_SCORE_TABLE;
Section::name = Section::Name::HI_SCORE_TABLE;
return;
}
}
@@ -1935,7 +1935,7 @@ void Game::evaluateAndSetMenace()
// Actualiza la velocidad de los globos en funcion del poder acumulado de la fase
void Game::checkAndUpdateBalloonSpeed()
{
if (difficulty_ != GameDifficulty::NORMAL)
if (difficulty_ != DifficultyCode::NORMAL)
return;
const float percent = static_cast<float>(Stage::power) / Stage::get(Stage::number).power_to_complete;

View File

@@ -139,7 +139,7 @@ private:
options.game.hi_score_table[0].score); // Máxima puntuación y nombre de quien la ostenta
Demo demo_; // Variable con todas las variables relacionadas con el modo demo
GameDifficulty difficulty_ = options.game.difficulty; // Dificultad del juego
DifficultyCode difficulty_ = options.game.difficulty; // Dificultad del juego
Helper helper_; // Variable para gestionar las ayudas
Uint64 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
bool coffee_machine_enabled_ = false; // Indica si hay una máquina de café en el terreno de juego

View File

@@ -3,7 +3,7 @@
#include "mouse.h" // Para handleEvent
#include "section.h" // Para Name, Options, name, options
namespace globalEvents
namespace GlobalEvents
{
// Comprueba los eventos que se pueden producir en cualquier sección del juego
void check(const SDL_Event &event)
@@ -11,8 +11,8 @@ namespace globalEvents
switch (event.type)
{
case SDL_EVENT_QUIT: // Evento de salida de la aplicación
section::name = section::Name::QUIT;
section::options = section::Options::NONE;
Section::name = Section::Name::QUIT;
Section::options = Section::Options::NONE;
return;
case SDL_EVENT_RENDER_DEVICE_RESET:

View File

@@ -2,7 +2,7 @@
#include <SDL3/SDL_events.h>
namespace globalEvents
namespace GlobalEvents
{
// Comprueba los eventos que se pueden producir en cualquier sección del juego
void check(const SDL_Event &event);

View File

@@ -14,7 +14,7 @@
#include "service_menu.h" // Para ServiceMenu
#include "utils.h" // Para boolToOnOff
namespace globalInputs
namespace GlobalInputs
{
// Termina
void quit()
@@ -23,13 +23,13 @@ namespace globalInputs
if (Notifier::get()->checkCode(CODE))
{
// Si la notificación de salir está activa, cambia de sección
section::name = section::Name::QUIT;
section::options = section::Options::NONE;
Section::name = Section::Name::QUIT;
Section::options = Section::Options::NONE;
}
else
{
// Si la notificación de salir no está activa, muestra la notificación
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 01"), std::string()}, -1, CODE);
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 01"), std::string()}, -1, CODE);
}
}
@@ -39,12 +39,12 @@ namespace globalInputs
const std::string CODE = "RESET";
if (Notifier::get()->checkCode(CODE))
{
section::name = section::Name::RESET;
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 15")});
Section::name = Section::Name::RESET;
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 15")});
}
else
{
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 03"), std::string()}, -1, CODE);
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 03"), std::string()}, -1, CODE);
}
}
@@ -60,32 +60,32 @@ namespace globalInputs
void toggleIntegerScale()
{
Screen::get()->toggleIntegerScale();
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 12") + " " + boolToOnOff(options.video.integer_scale)});
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 12") + " " + boolToOnOff(options.video.integer_scale)});
}
// Activa / desactiva el vsync
void toggleVSync()
{
Screen::get()->toggleVSync();
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 14") + " " + boolToOnOff(options.video.v_sync)});
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 14") + " " + boolToOnOff(options.video.v_sync)});
}
// Activa o desactiva los shaders
void toggleShaders()
{
Screen::get()->toggleShaders();
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 13") + " " + boolToOnOff(options.video.shaders)});
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 13") + " " + boolToOnOff(options.video.shaders)});
}
// Obtiene una fichero a partir de un lang::Code
std::string getLangFile(lang::Code code)
std::string getLangFile(Lang::Code code)
{
switch (code)
{
case lang::Code::VALENCIAN:
case Lang::Code::VALENCIAN:
return Asset::get()->get("ba_BA.json");
break;
case lang::Code::SPANISH:
case Lang::Code::SPANISH:
return Asset::get()->get("es_ES.json");
break;
default:
@@ -95,14 +95,14 @@ namespace globalInputs
}
// Obtiene una cadena a partir de un lang::Code
std::string getLangName(lang::Code code)
std::string getLangName(Lang::Code code)
{
switch (code)
{
case lang::Code::VALENCIAN:
case Lang::Code::VALENCIAN:
return " \"ba_BA\"";
break;
case lang::Code::SPANISH:
case Lang::Code::SPANISH:
return " \"es_ES\"";
break;
default:
@@ -117,16 +117,16 @@ namespace globalInputs
const std::string CODE = "LANG";
if (Notifier::get()->checkCode(CODE))
{
options.game.language = lang::getNextLangCode(options.game.language);
lang::loadFromFile(getLangFile(static_cast<lang::Code>(options.game.language)));
section::name = section::Name::RESET;
section::options = section::Options::RELOAD;
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 05") + getLangName(options.game.language)});
options.game.language = Lang::getNextLangCode(options.game.language);
Lang::loadFromFile(getLangFile(static_cast<Lang::Code>(options.game.language)));
Section::name = Section::Name::RESET;
Section::options = Section::Options::RELOAD;
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 05") + getLangName(options.game.language)});
}
else
{
const auto NEXT = lang::getNextLangCode(options.game.language);
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 04") + getLangName(NEXT), std::string()}, -1, CODE);
const auto NEXT = Lang::getNextLangCode(options.game.language);
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 04") + getLangName(NEXT), std::string()}, -1, CODE);
}
}
@@ -134,24 +134,24 @@ namespace globalInputs
void toggleFireMode()
{
options.game.autofire = !options.game.autofire;
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 08") + " " + boolToOnOff(options.game.autofire)});
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 08") + " " + boolToOnOff(options.game.autofire)});
}
// Salta una sección del juego
void skipSection()
{
switch (section::name)
switch (Section::name)
{
case section::Name::INTRO:
case Section::Name::INTRO:
Audio::get()->stopMusic();
/* Continua en el case de abajo */
case section::Name::LOGO:
case section::Name::HI_SCORE_TABLE:
case section::Name::INSTRUCTIONS:
case Section::Name::LOGO:
case Section::Name::HI_SCORE_TABLE:
case Section::Name::INSTRUCTIONS:
{
section::name = section::Name::TITLE;
section::options = section::Options::TITLE_1;
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
Section::name = Section::Name::TITLE;
Section::options = Section::Options::TITLE_1;
Section::attract_mode = Section::AttractMode::TITLE_TO_DEMO;
break;
}
default:
@@ -169,7 +169,7 @@ namespace globalInputs
void toggleFullscreen()
{
Screen::get()->toggleFullscreen();
const std::string MODE = options.video.fullscreen ? lang::getText("[NOTIFICATIONS] 11") : lang::getText("[NOTIFICATIONS] 10");
const std::string MODE = options.video.fullscreen ? Lang::getText("[NOTIFICATIONS] 11") : Lang::getText("[NOTIFICATIONS] 10");
Notifier::get()->show({MODE});
}
@@ -178,7 +178,7 @@ namespace globalInputs
{
if (Screen::get()->decWindowSize())
{
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)});
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)});
}
}
@@ -187,7 +187,7 @@ namespace globalInputs
{
if (Screen::get()->incWindowSize())
{
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)});
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)});
}
}
@@ -323,7 +323,7 @@ namespace globalInputs
if (Input::get()->checkInput(InputAction::WINDOW_FULLSCREEN, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
{
Screen::get()->toggleFullscreen();
const std::string MODE = options.video.fullscreen ? lang::getText("[NOTIFICATIONS] 11") : lang::getText("[NOTIFICATIONS] 10");
const std::string MODE = options.video.fullscreen ? Lang::getText("[NOTIFICATIONS] 11") : Lang::getText("[NOTIFICATIONS] 10");
Notifier::get()->show({MODE});
return;
}
@@ -333,7 +333,7 @@ namespace globalInputs
{
if (Screen::get()->decWindowSize())
{
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)});
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)});
}
return;
}
@@ -343,7 +343,7 @@ namespace globalInputs
{
if (Screen::get()->incWindowSize())
{
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)});
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)});
}
return;
}

View File

@@ -1,6 +1,6 @@
#pragma once
namespace globalInputs
namespace GlobalInputs
{
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
void check();

View File

@@ -39,7 +39,7 @@ HiScoreTable::HiScoreTable()
background_fade_color_(Color(0, 0, 0))
{
// Inicializa el resto
section::name = section::Name::HI_SCORE_TABLE;
Section::name = Section::Name::HI_SCORE_TABLE;
SDL_SetTextureBlendMode(backbuffer_, SDL_BLENDMODE_BLEND);
initFade();
initBackground();
@@ -137,18 +137,18 @@ void HiScoreTable::checkEvents()
SDL_Event event;
while (SDL_PollEvent(&event))
{
globalEvents::check(event);
GlobalEvents::check(event);
}
}
// Comprueba las entradas
void HiScoreTable::checkInput() { globalInputs::check(); }
void HiScoreTable::checkInput() { GlobalInputs::check(); }
// Bucle para la pantalla de instrucciones
void HiScoreTable::run()
{
Audio::get()->playMusic("title.ogg");
while (section::name == section::Name::HI_SCORE_TABLE)
while (Section::name == Section::Name::HI_SCORE_TABLE)
{
checkInput();
update();
@@ -171,10 +171,10 @@ void HiScoreTable::updateFade()
if (fade_->hasEnded() && fade_mode_ == FadeMode::OUT)
{
section::name = (section::options == section::Options::HI_SCORE_AFTER_PLAYING)
? section::Name::TITLE
: section::Name::INSTRUCTIONS;
section::options = section::Options::NONE;
Section::name = (Section::options == Section::Options::HI_SCORE_AFTER_PLAYING)
? Section::Name::TITLE
: Section::Name::INSTRUCTIONS;
Section::options = Section::Options::NONE;
}
}
@@ -221,7 +221,7 @@ void HiScoreTable::createSprites()
const int first_line = (param.game.height - size) / 2;
// Crea el sprite para el texto de cabecera
header_ = std::make_unique<Sprite>(header_text->writeDXToTexture(TEXT_COLOR, lang::getText("[HIGHSCORE_TABLE] CAPTION"), -2, background_fade_color_.getInverse().lighten(25)));
header_ = std::make_unique<Sprite>(header_text->writeDXToTexture(TEXT_COLOR, Lang::getText("[HIGHSCORE_TABLE] CAPTION"), -2, background_fade_color_.getInverse().lighten(25)));
header_->setPosition(param.game.game_area.center_x - (header_->getWidth() / 2), first_line);
// Crea los sprites para las entradas en la tabla de puntuaciones

View File

@@ -35,7 +35,7 @@ Instructions::Instructions()
SDL_SetTextureBlendMode(texture_, SDL_BLENDMODE_BLEND);
// Inicializa variables
section::name = section::Name::INSTRUCTIONS;
Section::name = Section::Name::INSTRUCTIONS;
view_ = param.game.game_area.rect;
// Inicializa objetos
@@ -141,11 +141,11 @@ void Instructions::fillTexture()
// Calcula cual es el texto más largo de las descripciones de los items
int lenght = 0;
const std::array<std::string, 5> ITEM_DESCRIPTIONS = {
lang::getText("[INSTRUCTIONS] 07"),
lang::getText("[INSTRUCTIONS] 08"),
lang::getText("[INSTRUCTIONS] 09"),
lang::getText("[INSTRUCTIONS] 10"),
lang::getText("[INSTRUCTIONS] 11")};
Lang::getText("[INSTRUCTIONS] 07"),
Lang::getText("[INSTRUCTIONS] 08"),
Lang::getText("[INSTRUCTIONS] 09"),
Lang::getText("[INSTRUCTIONS] 10"),
Lang::getText("[INSTRUCTIONS] 11")};
for (const auto &desc : ITEM_DESCRIPTIONS)
{
const int l = text_->lenght(desc);
@@ -154,24 +154,24 @@ void Instructions::fillTexture()
const int ANCHOR_ITEM = (param.game.width - (lenght + desp_x)) / 2;
// Escribe el texto de las instrucciones
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, first_line, lang::getText("[INSTRUCTIONS] 01"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR);
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, first_line, Lang::getText("[INSTRUCTIONS] 01"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR);
const int anchor1 = first_line + space_post_header;
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_between_lines * 0, lang::getText("[INSTRUCTIONS] 02"), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_between_lines * 1, lang::getText("[INSTRUCTIONS] 03"), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_new_paragraph + space_between_lines * 2, lang::getText("[INSTRUCTIONS] 04"), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_new_paragraph + space_between_lines * 3, lang::getText("[INSTRUCTIONS] 05"), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_between_lines * 0, Lang::getText("[INSTRUCTIONS] 02"), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_between_lines * 1, Lang::getText("[INSTRUCTIONS] 03"), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_new_paragraph + space_between_lines * 2, Lang::getText("[INSTRUCTIONS] 04"), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_new_paragraph + space_between_lines * 3, Lang::getText("[INSTRUCTIONS] 05"), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
// Escribe el texto de los objetos y sus puntos
const int anchor2 = anchor1 + space_pre_header + space_new_paragraph + space_between_lines * 3;
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor2, lang::getText("[INSTRUCTIONS] 06"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR);
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor2, Lang::getText("[INSTRUCTIONS] 06"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR);
const int anchor3 = anchor2 + space_post_header;
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 0, lang::getText("[INSTRUCTIONS] 07"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 1, lang::getText("[INSTRUCTIONS] 08"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 2, lang::getText("[INSTRUCTIONS] 09"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 3, lang::getText("[INSTRUCTIONS] 10"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 4, lang::getText("[INSTRUCTIONS] 11"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 0, Lang::getText("[INSTRUCTIONS] 07"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 1, Lang::getText("[INSTRUCTIONS] 08"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 2, Lang::getText("[INSTRUCTIONS] 09"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 3, Lang::getText("[INSTRUCTIONS] 10"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 4, Lang::getText("[INSTRUCTIONS] 11"), SHADOW_TEXT_COLOR);
// Deja el renderizador como estaba
SDL_SetRenderTarget(renderer_, temp);
@@ -266,18 +266,18 @@ void Instructions::checkEvents()
SDL_Event event;
while (SDL_PollEvent(&event))
{
globalEvents::check(event);
GlobalEvents::check(event);
}
}
// Comprueba las entradas
void Instructions::checkInput() { globalInputs::check(); }
void Instructions::checkInput() { GlobalInputs::check(); }
// Bucle para la pantalla de instrucciones
void Instructions::run()
{
Audio::get()->playMusic("title.ogg");
while (section::name == section::Name::INSTRUCTIONS)
while (Section::name == Section::Name::INSTRUCTIONS)
{
checkInput();
update();
@@ -368,7 +368,7 @@ void Instructions::updateBackbuffer()
// Comprueba si el contador ha llegado al final
if (all_lines_off_screen_)
{
section::name = section::Name::TITLE;
section::options = section::Options::TITLE_1;
Section::name = Section::Name::TITLE;
Section::options = Section::Options::TITLE_1;
}
}

View File

@@ -28,8 +28,8 @@ Intro::Intro()
: tiled_bg_(std::make_unique<TiledBG>(param.game.game_area.rect, TiledBGMode::DIAGONAL))
{
// Inicializa variables
section::name = section::Name::INTRO;
section::options = section::Options::NONE;
Section::name = Section::Name::INTRO;
Section::options = Section::Options::NONE;
// Inicializa las imagens
initSprites();
@@ -48,12 +48,12 @@ void Intro::checkEvents()
SDL_Event event;
while (SDL_PollEvent(&event))
{
globalEvents::check(event);
GlobalEvents::check(event);
}
}
// Comprueba las entradas
void Intro::checkInput() { globalInputs::check(); }
void Intro::checkInput() { GlobalInputs::check(); }
// Actualiza las escenas de la intro
void Intro::updateScenes()
@@ -282,7 +282,7 @@ void Intro::render()
void Intro::run()
{
Audio::get()->playMusic("intro.ogg", 0);
while (section::name == section::Name::INTRO)
while (Section::name == Section::Name::INTRO)
{
checkInput();
update();
@@ -396,39 +396,39 @@ void Intro::initTexts()
}
// Un dia qualsevol de l'any 2000
texts_.at(0)->setCaption(lang::getText("[INTRO] 1"));
texts_.at(0)->setCaption(Lang::getText("[INTRO] 1"));
texts_.at(0)->setSpeed(8);
// Tot esta tranquil a la UPV
texts_.at(1)->setCaption(lang::getText("[INTRO] 2"));
texts_.at(1)->setCaption(Lang::getText("[INTRO] 2"));
texts_.at(1)->setSpeed(8);
// Fins que un desaprensiu...
texts_.at(2)->setCaption(lang::getText("[INTRO] 3"));
texts_.at(2)->setCaption(Lang::getText("[INTRO] 3"));
texts_.at(2)->setSpeed(12);
// HEY! ME ANE A FERME UN CORTAET...
texts_.at(3)->setCaption(lang::getText("[INTRO] 4"));
texts_.at(3)->setCaption(Lang::getText("[INTRO] 4"));
texts_.at(3)->setSpeed(8);
// UAAAAAAAAAAAAA!!!
texts_.at(4)->setCaption(lang::getText("[INTRO] 5"));
texts_.at(4)->setCaption(Lang::getText("[INTRO] 5"));
texts_.at(4)->setSpeed(1);
// Espera un moment...
texts_.at(5)->setCaption(lang::getText("[INTRO] 6"));
texts_.at(5)->setCaption(Lang::getText("[INTRO] 6"));
texts_.at(5)->setSpeed(16);
// Si resulta que no tinc solt!
texts_.at(6)->setCaption(lang::getText("[INTRO] 7"));
texts_.at(6)->setCaption(Lang::getText("[INTRO] 7"));
texts_.at(6)->setSpeed(2);
// MERDA DE MAQUINA!
texts_.at(7)->setCaption(lang::getText("[INTRO] 8"));
texts_.at(7)->setCaption(Lang::getText("[INTRO] 8"));
texts_.at(7)->setSpeed(3);
// Blop... blop... blop...
texts_.at(8)->setCaption(lang::getText("[INTRO] 9"));
texts_.at(8)->setCaption(Lang::getText("[INTRO] 9"));
texts_.at(8)->setSpeed(20);
for (auto &text : texts_)
@@ -514,8 +514,8 @@ void Intro::updatePostState()
if (ELAPSED_TIME >= 1000)
{
Audio::get()->stopMusic();
section::name = section::Name::TITLE;
section::options = section::Options::TITLE_1;
Section::name = Section::Name::TITLE;
Section::options = Section::Options::TITLE_1;
}
break;

View File

@@ -7,7 +7,7 @@
using json = nlohmann::json;
namespace lang
namespace Lang
{
std::unordered_map<std::string, std::string> texts;
@@ -101,13 +101,13 @@ namespace lang
switch (lang.code)
{
case Code::SPANISH:
lang.name = lang::getText("[SERVICE_MENU] LANG_ES");
lang.name = Lang::getText("[SERVICE_MENU] LANG_ES");
break;
case Code::VALENCIAN:
lang.name = lang::getText("[SERVICE_MENU] LANG_BA");
lang.name = Lang::getText("[SERVICE_MENU] LANG_BA");
break;
case Code::ENGLISH:
lang.name = lang::getText("[SERVICE_MENU] LANG_EN");
lang.name = Lang::getText("[SERVICE_MENU] LANG_EN");
break;
default:
lang.name = "Unknown";
@@ -117,7 +117,7 @@ namespace lang
}
// Obtiene una fichero a partir de un lang::Code
std::string getLanguageFileName(lang::Code code)
std::string getLanguageFileName(Lang::Code code)
{
for (const auto &lang : languages)
{

View File

@@ -3,7 +3,7 @@
#include <string>
#include <vector>
namespace lang
namespace Lang
{
// --- Códigos de idioma soportados ---
enum class Code : int

View File

@@ -21,7 +21,7 @@ Logo::Logo()
{
// Inicializa variables
section::name = section::Name::LOGO;
Section::name = Section::Name::LOGO;
dest_.x = param.game.game_area.center_x - jail_texture_->getWidth() / 2;
dest_.y = param.game.game_area.center_y - jail_texture_->getHeight() / 2;
since_sprite_->setPosition(SDL_FRect{
@@ -69,12 +69,12 @@ void Logo::checkEvents()
SDL_Event event;
while (SDL_PollEvent(&event))
{
globalEvents::check(event);
GlobalEvents::check(event);
}
}
// Comprueba las entradas
void Logo::checkInput() { globalInputs::check(); }
void Logo::checkInput() { GlobalInputs::check(); }
// Gestiona el logo de JAILGAMES
void Logo::updateJAILGAMES()
@@ -113,7 +113,7 @@ void Logo::updateJAILGAMES()
// Comprueba si ha terminado el logo
if (counter_ == END_LOGO_COUNTER_MARK + POST_LOGO_DURATION)
{
section::name = section::Name::INTRO;
Section::name = Section::Name::INTRO;
}
}
@@ -179,7 +179,7 @@ void Logo::render()
void Logo::run()
{
Audio::get()->fadeOutMusic(300);
while (section::name == section::Name::LOGO)
while (Section::name == Section::Name::LOGO)
{
checkInput();
update();

View File

@@ -8,8 +8,13 @@
#include "lang.h" // Para Code
#include "utils.h" // Para boolToString, stringToBool, getFileName
// Variables
Options options;
namespace Options
{
// Vector con las dificultades
std::vector<Difficulty> difficulties = {
{DifficultyCode::EASY, "Easy"},
{DifficultyCode::NORMAL, "Normal"},
{DifficultyCode::HARD, "Hard"}};
// Declaraciones
bool setOptions(const std::string &var, const std::string &value);
@@ -17,42 +22,42 @@ bool setOptions(const std::string &var, const std::string &value);
// Inicializa las opciones del programa
void initOptions()
{
options.window.caption = "Coffee Crisis Arcade Edition";
options.window.size = 2;
window.caption = "Coffee Crisis Arcade Edition";
window.size = 2;
// Opciones de video
options.video.fullscreen = false;
options.video.scale_mode = SDL_ScaleMode::SDL_SCALEMODE_NEAREST;
options.video.v_sync = true;
options.video.integer_scale = true;
options.video.shaders = false;
video.fullscreen = false;
video.scale_mode = SDL_ScaleMode::SDL_SCALEMODE_NEAREST;
video.v_sync = true;
video.integer_scale = true;
video.shaders = false;
// Opciones de audio
options.audio.enabled = true;
options.audio.volume = 100;
options.audio.music.enabled = true;
options.audio.music.volume = 100;
options.audio.sound.enabled = true;
options.audio.sound.volume = 50;
audio.enabled = true;
audio.volume = 100;
audio.music.enabled = true;
audio.music.volume = 100;
audio.sound.enabled = true;
audio.sound.volume = 50;
// Opciones de juego
options.game.difficulty = GameDifficulty::NORMAL;
options.game.language = lang::Code::VALENCIAN;
options.game.autofire = true;
options.game.shutdown_enabled = false;
options.game.clearLastHiScoreEntries();
game.difficulty = DifficultyCode::NORMAL;
game.language = Lang::Code::VALENCIAN;
game.autofire = true;
game.shutdown_enabled = false;
game.clearLastHiScoreEntries();
// Opciones de control
options.controllers.clear();
options.controllers.resize(2);
options.controllers.at(0).player_id = 1;
options.controllers.at(1).player_id = 2;
controllers.clear();
controllers.resize(2);
controllers.at(0).player_id = 1;
controllers.at(1).player_id = 2;
setKeyboardToPlayer(1);
// Opciones pendientes
options.pending_changes.new_language = options.game.language;
options.pending_changes.new_difficulty = options.game.difficulty;
options.pending_changes.has_pending_changes = false;
pending_changes.new_language = game.language;
pending_changes.new_difficulty = game.difficulty;
pending_changes.has_pending_changes = false;
}
// Carga el fichero de configuración
@@ -98,11 +103,11 @@ bool loadOptionsFile(std::string file_path)
}
// Normaliza los valores
if (options.game.language != lang::Code::ENGLISH &&
options.game.language != lang::Code::VALENCIAN &&
options.game.language != lang::Code::SPANISH)
if (game.language != Lang::Code::ENGLISH &&
game.language != Lang::Code::VALENCIAN &&
game.language != Lang::Code::SPANISH)
{
options.game.language = lang::Code::ENGLISH;
game.language = Lang::Code::ENGLISH;
}
return success;
@@ -128,41 +133,41 @@ bool saveOptionsFile(std::string file_path)
file << "## video.scale_mode [" << static_cast<int>(SDL_ScaleMode::SDL_SCALEMODE_NEAREST) << ": nearest, " << static_cast<int>(SDL_ScaleMode::SDL_SCALEMODE_LINEAR) << ": lineal]\n";
file << "\n";
file << "window.zoom=" << options.window.size << "\n";
file << "video.fullscreen=" << boolToString(options.video.fullscreen) << "\n";
file << "video.scale_mode=" << static_cast<int>(options.video.scale_mode) << "\n";
file << "video.v_sync=" << boolToString(options.video.v_sync) << "\n";
file << "video.integer_scale=" << boolToString(options.video.integer_scale) << "\n";
file << "video.shaders=" << boolToString(options.video.shaders) << "\n";
file << "window.zoom=" << window.size << "\n";
file << "video.fullscreen=" << boolToString(video.fullscreen) << "\n";
file << "video.scale_mode=" << static_cast<int>(video.scale_mode) << "\n";
file << "video.v_sync=" << boolToString(video.v_sync) << "\n";
file << "video.integer_scale=" << boolToString(video.integer_scale) << "\n";
file << "video.shaders=" << boolToString(video.shaders) << "\n";
// Opciones de audio
file << "\n\n## AUDIO\n";
file << "## volume [0 .. 100]\n";
file << "\n";
file << "audio.enabled=" << boolToString(options.audio.enabled) << "\n";
file << "audio.volume=" << options.audio.volume << "\n";
file << "audio.music.enabled=" << boolToString(options.audio.music.enabled) << "\n";
file << "audio.music.volume=" << options.audio.music.volume << "\n";
file << "audio.sound.enabled=" << boolToString(options.audio.sound.enabled) << "\n";
file << "audio.sound.volume=" << options.audio.sound.volume << "\n";
file << "audio.enabled=" << boolToString(audio.enabled) << "\n";
file << "audio.volume=" << audio.volume << "\n";
file << "audio.music.enabled=" << boolToString(audio.music.enabled) << "\n";
file << "audio.music.volume=" << audio.music.volume << "\n";
file << "audio.sound.enabled=" << boolToString(audio.sound.enabled) << "\n";
file << "audio.sound.volume=" << audio.sound.volume << "\n";
// Opciones del juego
file << "\n\n## GAME\n";
file << "## game.language [0: spanish, 1: valencian, 2: english]\n";
file << "## game.difficulty [" << static_cast<int>(GameDifficulty::EASY) << ": easy, " << static_cast<int>(GameDifficulty::NORMAL) << ": normal, " << static_cast<int>(GameDifficulty::HARD) << ": hard]\n";
file << "## game.difficulty [" << static_cast<int>(DifficultyCode::EASY) << ": easy, " << static_cast<int>(DifficultyCode::NORMAL) << ": normal, " << static_cast<int>(DifficultyCode::HARD) << ": hard]\n";
file << "\n";
file << "game.language=" << static_cast<int>(options.game.language) << "\n";
file << "game.difficulty=" << static_cast<int>(options.game.difficulty) << "\n";
file << "game.autofire=" << boolToString(options.game.autofire) << "\n";
file << "game.shutdown_enabled=" << boolToString(options.game.shutdown_enabled) << "\n";
file << "game.language=" << static_cast<int>(game.language) << "\n";
file << "game.difficulty=" << static_cast<int>(game.difficulty) << "\n";
file << "game.autofire=" << boolToString(game.autofire) << "\n";
file << "game.shutdown_enabled=" << boolToString(game.shutdown_enabled) << "\n";
// Opciones de mandos
file << "\n\n## CONTROLLERS\n";
int controller_index = 0;
for (const auto &controller : options.controllers)
for (const auto &controller : controllers)
{
file << "\n";
file << "controller." << controller_index << ".name=" << controller.name << "\n";
@@ -193,139 +198,139 @@ bool setOptions(const std::string &var, const std::string &value)
// Opciones de video
if (var == "video.fullscreen")
{
options.video.fullscreen = stringToBool(value);
video.fullscreen = stringToBool(value);
}
else if (var == "window.zoom")
{
options.window.size = std::stoi(value);
window.size = std::stoi(value);
}
else if (var == "video.scale_mode")
{
options.video.scale_mode = static_cast<SDL_ScaleMode>(std::stoi(value));
video.scale_mode = static_cast<SDL_ScaleMode>(std::stoi(value));
}
else if (var == "video.shaders")
{
options.video.shaders = stringToBool(value);
video.shaders = stringToBool(value);
}
else if (var == "video.integer_scale")
{
options.video.integer_scale = stringToBool(value);
video.integer_scale = stringToBool(value);
}
else if (var == "video.v_sync")
{
options.video.v_sync = stringToBool(value);
video.v_sync = stringToBool(value);
}
// Opciones de audio
else if (var == "audio.enabled")
{
options.audio.enabled = stringToBool(value);
audio.enabled = stringToBool(value);
}
else if (var == "audio.volume")
{
options.audio.volume = std::clamp(std::stoi(value), 0, 100);
audio.volume = std::clamp(std::stoi(value), 0, 100);
}
else if (var == "audio.music.enabled")
{
options.audio.music.enabled = stringToBool(value);
audio.music.enabled = stringToBool(value);
}
else if (var == "audio.music.volume")
{
options.audio.music.volume = std::clamp(std::stoi(value), 0, 100);
audio.music.volume = std::clamp(std::stoi(value), 0, 100);
}
else if (var == "audio.sound.enabled")
{
options.audio.sound.enabled = stringToBool(value);
audio.sound.enabled = stringToBool(value);
}
else if (var == "audio.sound.volume")
{
options.audio.sound.volume = std::clamp(std::stoi(value), 0, 100);
audio.sound.volume = std::clamp(std::stoi(value), 0, 100);
}
// Opciones de juego
else if (var == "game.language")
{
options.game.language = static_cast<lang::Code>(std::stoi(value));
options.pending_changes.new_language = options.game.language;
game.language = static_cast<Lang::Code>(std::stoi(value));
pending_changes.new_language = game.language;
}
else if (var == "game.difficulty")
{
options.game.difficulty = static_cast<GameDifficulty>(std::stoi(value));
options.pending_changes.new_difficulty = options.game.difficulty;
game.difficulty = static_cast<DifficultyCode>(std::stoi(value));
pending_changes.new_difficulty = game.difficulty;
}
else if (var == "game.autofire")
{
options.game.autofire = stringToBool(value);
game.autofire = stringToBool(value);
}
else if (var == "game.shutdown_enabled")
{
options.game.shutdown_enabled = stringToBool(value);
game.shutdown_enabled = stringToBool(value);
}
// Opciones de mandos
else if (var == "controller.0.name")
{
options.controllers.at(0).name = value;
controllers.at(0).name = value;
}
else if (var == "controller.0.player")
{
options.controllers.at(0).player_id = std::clamp(std::stoi(value), 1, 2);
controllers.at(0).player_id = std::clamp(std::stoi(value), 1, 2);
}
else if (var == "controller.0.type")
{
options.controllers.at(0).type = static_cast<InputDeviceToUse>(std::stoi(value));
controllers.at(0).type = static_cast<InputDeviceToUse>(std::stoi(value));
}
else if (var == "controller.0.button.fire_left")
{
options.controllers.at(0).buttons.at(0) = static_cast<SDL_GamepadButton>(std::stoi(value));
controllers.at(0).buttons.at(0) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.0.button.fire_center")
{
options.controllers.at(0).buttons.at(1) = static_cast<SDL_GamepadButton>(std::stoi(value));
controllers.at(0).buttons.at(1) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.0.button.fire_right")
{
options.controllers.at(0).buttons.at(2) = static_cast<SDL_GamepadButton>(std::stoi(value));
controllers.at(0).buttons.at(2) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.0.button.start")
{
options.controllers.at(0).buttons.at(3) = static_cast<SDL_GamepadButton>(std::stoi(value));
controllers.at(0).buttons.at(3) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.0.button.service")
{
options.controllers.at(0).buttons.at(4) = static_cast<SDL_GamepadButton>(std::stoi(value));
controllers.at(0).buttons.at(4) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.1.name")
{
options.controllers.at(1).name = value;
controllers.at(1).name = value;
}
else if (var == "controller.1.player")
{
options.controllers.at(1).player_id = std::clamp(std::stoi(value), 1, 2);
controllers.at(1).player_id = std::clamp(std::stoi(value), 1, 2);
}
else if (var == "controller.1.type")
{
options.controllers.at(1).type = static_cast<InputDeviceToUse>(std::stoi(value));
controllers.at(1).type = static_cast<InputDeviceToUse>(std::stoi(value));
}
else if (var == "controller.1.button.fire_left")
{
options.controllers.at(1).buttons.at(0) = static_cast<SDL_GamepadButton>(std::stoi(value));
controllers.at(1).buttons.at(0) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.1.button.fire_center")
{
options.controllers.at(1).buttons.at(1) = static_cast<SDL_GamepadButton>(std::stoi(value));
controllers.at(1).buttons.at(1) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.1.button.fire_right")
{
options.controllers.at(1).buttons.at(2) = static_cast<SDL_GamepadButton>(std::stoi(value));
controllers.at(1).buttons.at(2) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.1.button.start")
{
options.controllers.at(1).buttons.at(3) = static_cast<SDL_GamepadButton>(std::stoi(value));
controllers.at(1).buttons.at(3) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.1.button.service")
{
options.controllers.at(1).buttons.at(4) = static_cast<SDL_GamepadButton>(std::stoi(value));
controllers.at(1).buttons.at(4) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
// Lineas vacias o que empiezan por comentario
@@ -343,7 +348,7 @@ bool setOptions(const std::string &var, const std::string &value)
// Asigna el teclado al jugador
void setKeyboardToPlayer(int player_id)
{
for (auto &controller : options.controllers)
for (auto &controller : controllers)
{
if (controller.player_id == player_id)
{
@@ -359,20 +364,20 @@ void setKeyboardToPlayer(int player_id)
// Intercambia el teclado de jugador
void swapOptionsKeyboard()
{
std::swap(options.controllers.at(0).type, options.controllers.at(1).type);
std::swap(controllers.at(0).type, controllers.at(1).type);
}
// Intercambia los jugadores asignados a los dos primeros mandos
void swapOptionsControllers()
{
std::swap(options.controllers.at(0).player_id, options.controllers.at(1).player_id);
std::swap(options.controllers.at(0).type, options.controllers.at(1).type);
std::swap(controllers.at(0).player_id, controllers.at(1).player_id);
std::swap(controllers.at(0).type, controllers.at(1).type);
}
// Averigua quien está usando el teclado
int getPlayerWhoUsesKeyboard()
{
for (const auto &controller : options.controllers)
for (const auto &controller : controllers)
{
if (controller.type == InputDeviceToUse::ANY)
{
@@ -385,10 +390,24 @@ int getPlayerWhoUsesKeyboard()
// Aplica los cambios pendientes copiando los valores a sus variables
void applyPendingChanges()
{
if (options.pending_changes.has_pending_changes)
if (pending_changes.has_pending_changes)
{
options.game.language = options.pending_changes.new_language;
options.game.difficulty = options.pending_changes.new_difficulty;
options.pending_changes.has_pending_changes = false;
game.language = pending_changes.new_language;
game.difficulty = pending_changes.new_difficulty;
pending_changes.has_pending_changes = false;
}
}
void checkPendingChanges()
{
if (game.language != pending_changes.new_language ||
game.difficulty != pending_changes.new_difficulty)
{
pending_changes.has_pending_changes = true;
}
else
{
pending_changes.has_pending_changes = false;
}
}
} // namespace Options

View File

@@ -7,19 +7,31 @@
#include "input.h" // Para InputAction, InputDeviceToUse
#include "manage_hiscore_table.h" // Para HiScoreEntry
namespace lang
namespace Lang
{
enum class Code : int;
}
namespace Options
{
// --- Dificultad del juego ---
enum class GameDifficulty
enum class DifficultyCode
{
EASY = 0,
NORMAL = 1,
HARD = 2,
};
// --- Estructura que representa un nivel de dificultad
struct Difficulty
{
DifficultyCode code; // Código que identifica la dificultad
std::string name; // Nombre que identifica la dificultad
Difficulty(DifficultyCode c, const std::string &n)
: code(c), name(n) {}
};
// --- Opciones de la ventana ---
struct WindowOptions
{
@@ -65,8 +77,8 @@ struct AudioOptions
// --- Opciones del juego ---
struct GameOptions
{
GameDifficulty difficulty; // Dificultad del juego
lang::Code language; // Idioma usado en el juego
DifficultyCode difficulty; // Dificultad del juego
Lang::Code language; // Idioma usado en el juego
bool autofire; // Indicador de autofire
bool shutdown_enabled; // Especifica si se puede apagar el sistema
std::vector<HiScoreEntry> hi_score_table; // Tabla de mejores puntuaciones
@@ -101,24 +113,18 @@ struct GamepadOptions
// --- Opciones pendientes de aplicar ---
struct PendingChanges
{
lang::Code new_language; // Idioma en espera de aplicar
GameDifficulty new_difficulty; // Dificultad en espera de aplicar
Lang::Code new_language; // Idioma en espera de aplicar
DifficultyCode new_difficulty; // Dificultad en espera de aplicar
bool has_pending_changes = false; // Indica si hay cambios pendientes
};
// --- Opciones generales del programa ---
struct Options
{
// --- Variables globales ---
WindowOptions window; // Opciones de la ventana
GameOptions game; // Opciones del juego
VideoOptions video; // Opciones de vídeo
AudioOptions audio; // Opciones de audio
std::vector<GamepadOptions> controllers; // Opciones de mando para cada jugador
PendingChanges pending_changes; // Opciones que se aplican al cerrar
};
// --- Variables globales ---
extern Options options;
// --- Funciones de configuración ---
void initOptions(); // Inicializa las opciones del programa
@@ -129,3 +135,5 @@ void swapOptionsKeyboard(); // Intercambia el teclado de jugador
void swapOptionsControllers(); // Intercambia los jugadores asignados a los dos primeros mandos
int getPlayerWhoUsesKeyboard(); // Averigua quién está usando el teclado
void applyPendingChanges(); // Aplica los cambios pendientes copiando los valores a sus variables
void checkPendingChanges();
} // namespace Options

View File

@@ -309,10 +309,10 @@ void Resource::createTextures()
{"game_text_1000_points", "1.000"},
{"game_text_2500_points", "2.500"},
{"game_text_5000_points", "5.000"},
{"game_text_powerup", lang::getText("[GAME_TEXT] 4")},
{"game_text_one_hit", lang::getText("[GAME_TEXT] 5")},
{"game_text_stop", lang::getText("[GAME_TEXT] 6")},
{"game_text_1000000_points", lang::getText("[GAME_TEXT] 8")}};
{"game_text_powerup", Lang::getText("[GAME_TEXT] 4")},
{"game_text_one_hit", Lang::getText("[GAME_TEXT] 5")},
{"game_text_stop", Lang::getText("[GAME_TEXT] 6")},
{"game_text_1000000_points", Lang::getText("[GAME_TEXT] 8")}};
auto text = getText("04b_25");
for (const auto &s : strings)
@@ -324,9 +324,9 @@ void Resource::createTextures()
// Texturas de tamaño doble
std::vector<NameAndText> strings2X = {
{"game_text_100000_points", "100.000"},
{"game_text_get_ready", lang::getText("[GAME_TEXT] 7")},
{"game_text_last_stage", lang::getText("[GAME_TEXT] 3")},
{"game_text_congratulations", lang::getText("[GAME_TEXT] 1")},
{"game_text_get_ready", Lang::getText("[GAME_TEXT] 7")},
{"game_text_last_stage", Lang::getText("[GAME_TEXT] 3")},
{"game_text_congratulations", Lang::getText("[GAME_TEXT] 1")},
{"game_text_game_over", "Game Over"}};
auto text2 = getText("04b_25_2x");
@@ -450,7 +450,7 @@ void Resource::renderProgress()
loading_text_->write(
loading_wired_rect_.x,
loading_wired_rect_.y - 9,
lang::getText("[RESOURCE] LOADING") + " : " + loading_resource_name_
Lang::getText("[RESOURCE] LOADING") + " : " + loading_resource_name_
);
// Renderiza el frame en pantalla

View File

@@ -170,7 +170,7 @@ void Scoreboard::fillPanelTextures()
text_scoreboard_->writeCentered(slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]));
// MULT
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText("[SCOREBOARD] 3"));
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 3"));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, "x" + std::to_string(mult_[i]).substr(0, 3));
break;
}
@@ -178,13 +178,13 @@ void Scoreboard::fillPanelTextures()
case ScoreboardMode::DEMO:
{
// DEMO MODE
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText("[SCOREBOARD] 6"));
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, Lang::getText("[SCOREBOARD] 6"));
// PRESS START TO PLAY
if (time_counter_ % 10 < 8)
{
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText("[SCOREBOARD] 8"));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, lang::getText("[SCOREBOARD] 9"));
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, Lang::getText("[SCOREBOARD] 8"));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, Lang::getText("[SCOREBOARD] 9"));
}
break;
}
@@ -192,13 +192,13 @@ void Scoreboard::fillPanelTextures()
case ScoreboardMode::WAITING:
{
// GAME OVER
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText("[SCOREBOARD] 7"));
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, Lang::getText("[SCOREBOARD] 7"));
// PRESS START TO PLAY
if (time_counter_ % 10 < 8)
{
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText("[SCOREBOARD] 8"));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, lang::getText("[SCOREBOARD] 9"));
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, Lang::getText("[SCOREBOARD] 8"));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, Lang::getText("[SCOREBOARD] 9"));
}
break;
}
@@ -206,13 +206,13 @@ void Scoreboard::fillPanelTextures()
case ScoreboardMode::GAME_OVER:
{
// GAME OVER
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText("[SCOREBOARD] 7"));
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, Lang::getText("[SCOREBOARD] 7"));
// PLEASE WAIT
if (time_counter_ % 10 < 8)
{
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText("[SCOREBOARD] 12"));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, lang::getText("[SCOREBOARD] 13"));
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, Lang::getText("[SCOREBOARD] 12"));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, Lang::getText("[SCOREBOARD] 13"));
}
break;
}
@@ -220,7 +220,7 @@ void Scoreboard::fillPanelTextures()
case ScoreboardMode::STAGE_INFO:
{
// STAGE
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y, lang::getText("[SCOREBOARD] 5") + std::to_string(stage_));
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y, Lang::getText("[SCOREBOARD] 5") + std::to_string(stage_));
// POWERMETER
power_meter_sprite_->setSpriteClip(0, 0, 40, 7);
@@ -229,7 +229,7 @@ void Scoreboard::fillPanelTextures()
power_meter_sprite_->render();
// HI-SCORE
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText("[SCOREBOARD] 4"));
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 4"));
const std::string name = hi_score_name_ == "" ? "" : hi_score_name_ + " - ";
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, name + updateScoreText(hi_score_));
break;
@@ -242,7 +242,7 @@ void Scoreboard::fillPanelTextures()
text_scoreboard_->writeCentered(slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]));
// CONTINUE
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText("[SCOREBOARD] 10"));
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 10"));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, std::to_string(continue_counter_[i]));
break;
}
@@ -255,7 +255,7 @@ void Scoreboard::fillPanelTextures()
// ENTER NAME
{
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText("[SCOREBOARD] 11"));
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 11"));
SDL_FRect rect = {enter_name_pos_.x, enter_name_pos_.y, 5.0f, 7.0f};
// Recorre todos los slots de letras del nombre
@@ -291,7 +291,7 @@ void Scoreboard::fillPanelTextures()
text_scoreboard_->writeCentered(slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]));
// NAME
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText("[SCOREBOARD] 11"));
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 11"));
/* TEXTO CENTRADO */
// text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, record_name_[i], 1, getColorLikeKnightRider(name_colors_, loop_counter_ / 5));
@@ -302,12 +302,12 @@ void Scoreboard::fillPanelTextures()
case ScoreboardMode::GAME_COMPLETED:
{
// GAME OVER
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText("[SCOREBOARD] 7"));
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, Lang::getText("[SCOREBOARD] 7"));
// SCORE
if (time_counter_ % 10 < 8)
{
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText("[SCOREBOARD] 14"));
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, Lang::getText("[SCOREBOARD] 14"));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, updateScoreText(score_[i]));
}
}

View File

@@ -1,6 +1,6 @@
#include "section.h"
namespace section
namespace Section
{
Name name;
Options options;

View File

@@ -6,7 +6,7 @@
Proporciona variables globales para gestionar el flujo entre secciones.
*/
namespace section
namespace Section
{
// --- Enumeraciones de secciones del programa ---
enum class Name

View File

@@ -72,11 +72,11 @@ void ServiceMenu::render()
// TITULO
y += title_padding_;
title_text_->writeDX(TEXT_COLOR | TEXT_CENTER, param.game.game_area.center_x, y, lang::getText("[SERVICE_MENU] TITLE"), -4, title_color_);
title_text_->writeDX(TEXT_COLOR | TEXT_CENTER, param.game.game_area.center_x, y, title_, -4, title_color_);
// LINEA
y = rect_.y + upper_height_;
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), title_color_.r, title_color_.g, title_color_.b, 255);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), options.pending_changes.has_pending_changes ? 0 : title_color_.r, title_color_.g, title_color_.b, 255);
SDL_RenderLine(Screen::get()->getRenderer(), rect_.x + OPTIONS_HORIZONTAL_PADDING_, y, rect_.x + rect_.w - OPTIONS_HORIZONTAL_PADDING_, y);
// OPCIONES
@@ -295,6 +295,7 @@ void ServiceMenu::selectOption()
{
previous_settings_group_ = current_settings_group_;
current_settings_group_ = display_options_.at(selected_)->target_group;
title_ = settingsGroupToString(current_settings_group_);
updateMenu(current_settings_group_);
selected_ = 0;
setOptionsPosition();
@@ -305,22 +306,22 @@ void ServiceMenu::selectOption()
// Opción
if (display_options_.at(selected_)->behavior == OptionBehavior::SELECT)
{
if (display_options_.at(selected_)->caption == lang::getText("[SERVICE_MENU] RESET"))
if (display_options_.at(selected_)->caption == Lang::getText("[SERVICE_MENU] RESET"))
{
section::name = section::Name::RESET;
Section::name = Section::Name::RESET;
toggle();
return;
}
else if (display_options_.at(selected_)->caption == lang::getText("[SERVICE_MENU] QUIT"))
else if (display_options_.at(selected_)->caption == Lang::getText("[SERVICE_MENU] QUIT"))
{
section::name = section::Name::QUIT;
section::options = section::Options::NONE;
Section::name = Section::Name::QUIT;
Section::options = Section::Options::NONE;
return;
}
else if (display_options_.at(selected_)->caption == lang::getText("[SERVICE_MENU] SHUTDOWN"))
else if (display_options_.at(selected_)->caption == Lang::getText("[SERVICE_MENU] SHUTDOWN"))
{
section::name = section::Name::QUIT;
section::options = section::Options::SHUTDOWN;
Section::name = Section::Name::QUIT;
Section::options = Section::Options::SHUTDOWN;
return;
}
return;
@@ -351,51 +352,51 @@ void ServiceMenu::initializeOptions()
options_.clear();
// Video
options_.emplace_back(lang::getText("[SERVICE_MENU] FULLSCREEN"), SettingsGroup::VIDEO, OptionBehavior::ADJUST, &options.video.fullscreen, ValueType::BOOL);
options_.emplace_back(lang::getText("[SERVICE_MENU] WINDOW_SIZE"), SettingsGroup::VIDEO, OptionBehavior::ADJUST, &options.window.size, ValueType::INT, 1, options.window.max_size, 1);
options_.emplace_back(lang::getText("[SERVICE_MENU] SHADERS"), SettingsGroup::VIDEO, OptionBehavior::ADJUST, &options.video.shaders, ValueType::BOOL);
options_.emplace_back(lang::getText("[SERVICE_MENU] VSYNC"), SettingsGroup::VIDEO, OptionBehavior::ADJUST, &options.video.v_sync, ValueType::BOOL);
options_.emplace_back(lang::getText("[SERVICE_MENU] INTEGER_SCALE"), SettingsGroup::VIDEO, OptionBehavior::ADJUST, &options.video.integer_scale, ValueType::BOOL);
options_.emplace_back(Lang::getText("[SERVICE_MENU] FULLSCREEN"), SettingsGroup::VIDEO, OptionBehavior::ADJUST, &options.video.fullscreen, ValueType::BOOL);
options_.emplace_back(Lang::getText("[SERVICE_MENU] WINDOW_SIZE"), SettingsGroup::VIDEO, OptionBehavior::ADJUST, &options.window.size, ValueType::INT, 1, options.window.max_size, 1);
options_.emplace_back(Lang::getText("[SERVICE_MENU] SHADERS"), SettingsGroup::VIDEO, OptionBehavior::ADJUST, &options.video.shaders, ValueType::BOOL);
options_.emplace_back(Lang::getText("[SERVICE_MENU] VSYNC"), SettingsGroup::VIDEO, OptionBehavior::ADJUST, &options.video.v_sync, ValueType::BOOL);
options_.emplace_back(Lang::getText("[SERVICE_MENU] INTEGER_SCALE"), SettingsGroup::VIDEO, OptionBehavior::ADJUST, &options.video.integer_scale, ValueType::BOOL);
// Audio
options_.emplace_back(lang::getText("[SERVICE_MENU] AUDIO"), SettingsGroup::AUDIO, OptionBehavior::ADJUST, &options.audio.enabled, ValueType::BOOL);
options_.emplace_back(lang::getText("[SERVICE_MENU] MAIN_VOLUME"), SettingsGroup::AUDIO, OptionBehavior::ADJUST, &options.audio.volume, ValueType::INT, 0, 100, 5);
options_.emplace_back(lang::getText("[SERVICE_MENU] MUSIC_VOLUME"), SettingsGroup::AUDIO, OptionBehavior::ADJUST, &options.audio.music.volume, ValueType::INT, 0, 100, 5);
options_.emplace_back(lang::getText("[SERVICE_MENU] SFX_VOLUME"), SettingsGroup::AUDIO, OptionBehavior::ADJUST, &options.audio.sound.volume, ValueType::INT, 0, 100, 5);
options_.emplace_back(Lang::getText("[SERVICE_MENU] AUDIO"), SettingsGroup::AUDIO, OptionBehavior::ADJUST, &options.audio.enabled, ValueType::BOOL);
options_.emplace_back(Lang::getText("[SERVICE_MENU] MAIN_VOLUME"), SettingsGroup::AUDIO, OptionBehavior::ADJUST, &options.audio.volume, ValueType::INT, 0, 100, 5);
options_.emplace_back(Lang::getText("[SERVICE_MENU] MUSIC_VOLUME"), SettingsGroup::AUDIO, OptionBehavior::ADJUST, &options.audio.music.volume, ValueType::INT, 0, 100, 5);
options_.emplace_back(Lang::getText("[SERVICE_MENU] SFX_VOLUME"), SettingsGroup::AUDIO, OptionBehavior::ADJUST, &options.audio.sound.volume, ValueType::INT, 0, 100, 5);
// Settings
options_.emplace_back(lang::getText("[SERVICE_MENU] AUTOFIRE"), SettingsGroup::SETTINGS, OptionBehavior::ADJUST, &options.game.autofire, ValueType::BOOL);
options_.emplace_back(Lang::getText("[SERVICE_MENU] AUTOFIRE"), SettingsGroup::SETTINGS, OptionBehavior::ADJUST, &options.game.autofire, ValueType::BOOL);
options_.emplace_back(
lang::getText("[SERVICE_MENU] LANGUAGE"),
Lang::getText("[SERVICE_MENU] LANGUAGE"),
SettingsGroup::SETTINGS,
OptionBehavior::ADJUST,
&options.pending_changes.new_language,
std::vector<std::string>{
lang::getText("[SERVICE_MENU] LANG_ES"),
lang::getText("[SERVICE_MENU] LANG_BA"),
lang::getText("[SERVICE_MENU] LANG_EN")});
Lang::getText("[SERVICE_MENU] LANG_ES"),
Lang::getText("[SERVICE_MENU] LANG_BA"),
Lang::getText("[SERVICE_MENU] LANG_EN")});
options_.emplace_back(
lang::getText("[SERVICE_MENU] DIFFICULTY"),
Lang::getText("[SERVICE_MENU] DIFFICULTY"),
SettingsGroup::SETTINGS,
OptionBehavior::ADJUST,
&options.pending_changes.new_difficulty,
std::vector<std::string>{
lang::getText("[SERVICE_MENU] EASY"),
lang::getText("[SERVICE_MENU] NORMAL"),
lang::getText("[SERVICE_MENU] HARD")});
options_.emplace_back(lang::getText("[SERVICE_MENU] ENABLE_SHUTDOWN"), SettingsGroup::SETTINGS, OptionBehavior::ADJUST, &options.game.shutdown_enabled, ValueType::BOOL);
Lang::getText("[SERVICE_MENU] EASY"),
Lang::getText("[SERVICE_MENU] NORMAL"),
Lang::getText("[SERVICE_MENU] HARD")});
options_.emplace_back(Lang::getText("[SERVICE_MENU] ENABLE_SHUTDOWN"), SettingsGroup::SETTINGS, OptionBehavior::ADJUST, &options.game.shutdown_enabled, ValueType::BOOL);
// System
options_.emplace_back(lang::getText("[SERVICE_MENU] RESET"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
options_.emplace_back(lang::getText("[SERVICE_MENU] QUIT"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
options_.emplace_back(Lang::getText("[SERVICE_MENU] RESET"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
options_.emplace_back(Lang::getText("[SERVICE_MENU] QUIT"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
if (options.game.shutdown_enabled)
options_.emplace_back(lang::getText("[SERVICE_MENU] SHUTDOWN"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
options_.emplace_back(Lang::getText("[SERVICE_MENU] SHUTDOWN"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
// Menu principal
options_.emplace_back(lang::getText("[SERVICE_MENU] VIDEO"), SettingsGroup::MAIN, OptionBehavior::SELECT, SettingsGroup::VIDEO);
options_.emplace_back(lang::getText("[SERVICE_MENU] AUDIO"), SettingsGroup::MAIN, OptionBehavior::SELECT, SettingsGroup::AUDIO);
options_.emplace_back(lang::getText("[SERVICE_MENU] SETTINGS"), SettingsGroup::MAIN, OptionBehavior::SELECT, SettingsGroup::SETTINGS);
options_.emplace_back(lang::getText("[SERVICE_MENU] SYSTEM"), SettingsGroup::MAIN, OptionBehavior::SELECT, SettingsGroup::SYSTEM);
options_.emplace_back(Lang::getText("[SERVICE_MENU] VIDEO"), SettingsGroup::MAIN, OptionBehavior::SELECT, SettingsGroup::VIDEO);
options_.emplace_back(Lang::getText("[SERVICE_MENU] AUDIO"), SettingsGroup::MAIN, OptionBehavior::SELECT, SettingsGroup::AUDIO);
options_.emplace_back(Lang::getText("[SERVICE_MENU] SETTINGS"), SettingsGroup::MAIN, OptionBehavior::SELECT, SettingsGroup::SETTINGS);
options_.emplace_back(Lang::getText("[SERVICE_MENU] SYSTEM"), SettingsGroup::MAIN, OptionBehavior::SELECT, SettingsGroup::SYSTEM);
// Al terminar de inicializar las opciones, recalcula los anchos de menú
precalculateMenuWidths();
@@ -452,6 +453,7 @@ void ServiceMenu::applySettings(ServiceMenu::SettingsGroup group)
// Actualiza las opciones mostradas según el grupo seleccionado
void ServiceMenu::updateMenu(SettingsGroup group)
{
title_ = settingsGroupToString(group);
AdjustListValues();
option_pairs_ = getOptionPairs(group);
display_options_ = getOptionsByGroup(group);
@@ -464,6 +466,7 @@ void ServiceMenu::reset()
{
selected_ = 0;
previous_settings_group_ = current_settings_group_ = SettingsGroup::MAIN;
title_ = settingsGroupToString(current_settings_group_);
initializeOptions();
updateMenu(current_settings_group_);
setAnchors();
@@ -520,10 +523,10 @@ ServiceMenu::OptionEntry *ServiceMenu::getOptionEntryByCaption(const std::string
void ServiceMenu::AdjustListValues()
{
// Idioma
auto option = getOptionEntryByCaption(lang::getText("[SERVICE_MENU] LANGUAGE"));
auto option = getOptionEntryByCaption(Lang::getText("[SERVICE_MENU] LANGUAGE"));
for (size_t i = 0; i < option->value_list.size(); ++i)
{
if (lang::getCodeFromName(option->value_list[i]) == options.game.language)
if (Lang::getCodeFromName(option->value_list[i]) == options.game.language)
{
option->list_index = i;
}
@@ -553,8 +556,8 @@ void ServiceMenu::precalculateMenuWidths()
{
case ValueType::BOOL:
max_value_width = std::max({max_value_width,
element_text_->lenght(lang::getText("[SERVICE_MENU] ON"), -2),
element_text_->lenght(lang::getText("[SERVICE_MENU] OFF"), -2)});
element_text_->lenght(Lang::getText("[SERVICE_MENU] ON"), -2),
element_text_->lenght(Lang::getText("[SERVICE_MENU] OFF"), -2)});
break;
case ValueType::INT:
max_value_width = std::max({max_value_width,
@@ -578,3 +581,22 @@ int ServiceMenu::getMenuWidthForGroup(SettingsGroup group) const
{
return group_menu_widths_[static_cast<int>(group)];
}
std::string ServiceMenu::settingsGroupToString(SettingsGroup group) const
{
switch (group)
{
case SettingsGroup::MAIN:
return Lang::getText("[SERVICE_MENU] TITLE");
case SettingsGroup::VIDEO:
return Lang::getText("[SERVICE_MENU] VIDEO");
case SettingsGroup::AUDIO:
return Lang::getText("[SERVICE_MENU] AUDIO");
case SettingsGroup::SETTINGS:
return Lang::getText("[SERVICE_MENU] SETTINGS");
case SettingsGroup::SYSTEM:
return Lang::getText("[SERVICE_MENU] SYSTEM");
default:
return Lang::getText("[SERVICE_MENU] TITLE");
}
}

View File

@@ -146,15 +146,15 @@ private:
// Idioma
if (linked_variable == &options.pending_changes.new_language)
{
options.pending_changes.new_language = lang::getCodeFromName(value_list[list_index]);
options.pending_changes.has_pending_changes = true;
options.pending_changes.new_language = Lang::getCodeFromName(value_list[list_index]);
checkPendingChanges();
}
// Dificultad
if (linked_variable == &options.pending_changes.new_difficulty)
{
// options.pending_changes.new_difficulty =
options.pending_changes.has_pending_changes = true;
checkPendingChanges();
}
}
}
@@ -166,7 +166,7 @@ private:
switch (type)
{
case ValueType::BOOL:
return (*(static_cast<bool *>(linked_variable))) ? lang::getText("[SERVICE_MENU] ON") : lang::getText("[SERVICE_MENU] OFF");
return (*(static_cast<bool *>(linked_variable))) ? Lang::getText("[SERVICE_MENU] ON") : Lang::getText("[SERVICE_MENU] OFF");
case ValueType::INT:
return std::to_string(*(static_cast<int *>(linked_variable)));
case ValueType::LIST:
@@ -190,6 +190,7 @@ private:
SettingsGroup current_settings_group_; // Grupo de opciones actualmente activo
SettingsGroup previous_settings_group_; // Grupo de opciones anterior
Aspect aspect_ = Aspect::ASPECT1; // Estilo visual del menú
std::string title_; // Titulo a mostrar en el menu
// --- Variables de aspecto ---
Color bg_color_ = SERV_MENU_BG_COLOR; // Color de fondo
@@ -239,6 +240,7 @@ private:
int findLargestGroupSize() const; // Devuelve el tamaño del grupo más grande
GroupAlignment getGroupAlignment(SettingsGroup group) const; // Devuelve la alineación del grupo
OptionEntry *getOptionEntryByCaption(const std::string &caption); // Devuelve un puntero a OptionEntry a partir del caption
std::string settingsGroupToString(SettingsGroup group) const;
// --- Métodos internos: Animación de resize ---
void updateResizeAnimation();

View File

@@ -46,10 +46,10 @@ Title::Title()
Resource::get()->getTexture("smb2.gif")->setPalette(1);
// Asigna valores a otras variables
section::options = section::Options::TITLE_1;
const bool IS_TITLE_TO_DEMO = (section::attract_mode == section::AttractMode::TITLE_TO_DEMO);
next_section_ = IS_TITLE_TO_DEMO ? section::Name::GAME_DEMO : section::Name::LOGO;
section::attract_mode = IS_TITLE_TO_DEMO ? section::AttractMode::TITLE_TO_LOGO : section::AttractMode::TITLE_TO_DEMO;
Section::options = Section::Options::TITLE_1;
const bool IS_TITLE_TO_DEMO = (Section::attract_mode == Section::AttractMode::TITLE_TO_DEMO);
next_section_ = IS_TITLE_TO_DEMO ? Section::Name::GAME_DEMO : Section::Name::LOGO;
Section::attract_mode = IS_TITLE_TO_DEMO ? Section::AttractMode::TITLE_TO_LOGO : Section::AttractMode::TITLE_TO_DEMO;
}
// Destructor
@@ -112,7 +112,7 @@ void Title::render()
// 'PRESS TO PLAY'
if (counter_ % 50 > 14 && !define_buttons_->isEnabled())
{
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, lang::getText("[TITLE] PRESS_BUTTON_TO_PLAY"), 1, NO_COLOR, 1, shadow);
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, Lang::getText("[TITLE] PRESS_BUTTON_TO_PLAY"), 1, NO_COLOR, 1, shadow);
}
}
@@ -121,7 +121,7 @@ void Title::render()
// 'PRESS TO PLAY'
if (counter_ % 10 > 4 && !define_buttons_->isEnabled())
{
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, lang::getText("[TITLE] PRESS_BUTTON_TO_PLAY"), 1, NO_COLOR, 1, shadow);
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, Lang::getText("[TITLE] PRESS_BUTTON_TO_PLAY"), 1, NO_COLOR, 1, shadow);
}
}
@@ -181,7 +181,7 @@ void Title::checkEvents()
}
}
globalEvents::check(event);
GlobalEvents::check(event);
define_buttons_->checkEvents(event);
}
}
@@ -208,13 +208,13 @@ void Title::checkInput()
switch (CONTROLLER.player_id)
{
case 1:
selection_ = section::Options::GAME_PLAY_1P;
selection_ = Section::Options::GAME_PLAY_1P;
break;
case 2:
selection_ = section::Options::GAME_PLAY_2P;
selection_ = Section::Options::GAME_PLAY_2P;
break;
default:
selection_ = section::Options::TITLE_TIME_OUT;
selection_ = Section::Options::TITLE_TIME_OUT;
break;
}
state_ = TitleState::START_HAS_BEEN_PRESSED;
@@ -243,13 +243,13 @@ void Title::checkInput()
}
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
globalInputs::check();
GlobalInputs::check();
}
// Bucle para el titulo del juego
void Title::run()
{
while (section::name == section::Name::TITLE)
while (Section::name == Section::Name::TITLE)
{
checkInput();
update();
@@ -277,7 +277,7 @@ void Title::swapControllers()
void Title::swapKeyboard()
{
swapOptionsKeyboard();
std::string text = lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(getPlayerWhoUsesKeyboard()) + ": " + lang::getText("[DEFINE_BUTTONS] KEYBOARD");
std::string text = Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(getPlayerWhoUsesKeyboard()) + ": " + Lang::getText("[DEFINE_BUTTONS] KEYBOARD");
Notifier::get()->show({text});
}
@@ -302,7 +302,7 @@ void Title::showControllers()
const size_t index = player_controller_index.at(i);
if (options.controllers.at(index).plugged)
{
text.at(i) = lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(i + 1) + ": " + options.controllers.at(index).name;
text.at(i) = Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(i + 1) + ": " + options.controllers.at(index).name;
}
}
@@ -316,16 +316,16 @@ void Title::updateFade()
fade_->update();
if (fade_->hasEnded())
{
if (selection_ == section::Options::TITLE_TIME_OUT)
if (selection_ == Section::Options::TITLE_TIME_OUT)
{
// El menu ha hecho time out
section::name = next_section_;
Section::name = next_section_;
}
else
{
// Se ha pulsado para jugar
section::name = section::Name::GAME;
section::options = selection_;
Section::name = Section::Name::GAME;
Section::options = selection_;
Audio::get()->stopMusic();
}
}
@@ -363,7 +363,7 @@ void Title::updateState()
// El menu ha hecho time out
fade_->setPostDuration(0);
fade_->activate();
selection_ = section::Options::TITLE_TIME_OUT;
selection_ = Section::Options::TITLE_TIME_OUT;
}
break;

View File

@@ -54,8 +54,8 @@ private:
// --- Variables de estado ---
int counter_ = 0; // Temporizador para la pantalla de título
Uint64 ticks_ = 0; // Contador de ticks para ajustar la velocidad
section::Name next_section_; // Siguiente sección a cargar
section::Options selection_ = section::Options::TITLE_TIME_OUT; // Opción elegida en el título
Section::Name next_section_; // Siguiente sección a cargar
Section::Options selection_ = Section::Options::TITLE_TIME_OUT; // Opción elegida en el título
int num_controllers_; // Número de mandos conectados
TitleState state_; // Estado actual de la sección

View File

@@ -130,7 +130,7 @@ std::string boolToString(bool value)
// Convierte un valor booleano en una cadena "on" o "off"
std::string boolToOnOff(bool value)
{
return value ? lang::getText("[NOTIFICATIONS] 06") : lang::getText("[NOTIFICATIONS] 07");
return value ? Lang::getText("[NOTIFICATIONS] 06") : Lang::getText("[NOTIFICATIONS] 07");
}
// Convierte una cadena a minusculas