Options: creat namespace
This commit is contained in:
@@ -29,7 +29,7 @@ Audio::Audio()
|
|||||||
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "\n** SDL_AUDIO: INITIALIZING\n");
|
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "\n** SDL_AUDIO: INITIALIZING\n");
|
||||||
|
|
||||||
JA_Init(48000, SDL_AUDIO_S16LE, 2);
|
JA_Init(48000, SDL_AUDIO_S16LE, 2);
|
||||||
enable(options.audio.enabled);
|
enable(Options::audio.enabled);
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "** SDL_AUDIO: INITIALIZATION COMPLETE\n");
|
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "** SDL_AUDIO: INITIALIZATION COMPLETE\n");
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ void Audio::setSoundVolume(int sound_volume)
|
|||||||
if (sound_enabled_)
|
if (sound_enabled_)
|
||||||
{
|
{
|
||||||
sound_volume = std::clamp(sound_volume, 0, 100);
|
sound_volume = std::clamp(sound_volume, 0, 100);
|
||||||
const float CONVERTED_VOLUME = (sound_volume / 100.0f) * (options.audio.volume / 100.0f);
|
const float CONVERTED_VOLUME = (sound_volume / 100.0f) * (Options::audio.volume / 100.0f);
|
||||||
JA_SetSoundVolume(CONVERTED_VOLUME);
|
JA_SetSoundVolume(CONVERTED_VOLUME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ void Audio::setMusicVolume(int music_volume)
|
|||||||
if (music_enabled_)
|
if (music_enabled_)
|
||||||
{
|
{
|
||||||
music_volume = std::clamp(music_volume, 0, 100);
|
music_volume = std::clamp(music_volume, 0, 100);
|
||||||
const float CONVERTED_VOLUME = (music_volume / 100.0f) * (options.audio.volume / 100.0f);
|
const float CONVERTED_VOLUME = (music_volume / 100.0f) * (Options::audio.volume / 100.0f);
|
||||||
JA_SetMusicVolume(CONVERTED_VOLUME);
|
JA_SetMusicVolume(CONVERTED_VOLUME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ void Audio::setMusicVolume(int music_volume)
|
|||||||
// Aplica la configuración
|
// Aplica la configuración
|
||||||
void Audio::applySettings()
|
void Audio::applySettings()
|
||||||
{
|
{
|
||||||
enable(options.audio.enabled);
|
enable(Options::audio.enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establecer estado general
|
// Establecer estado general
|
||||||
@@ -131,15 +131,6 @@ void Audio::enable(bool value)
|
|||||||
{
|
{
|
||||||
enabled_ = value;
|
enabled_ = value;
|
||||||
|
|
||||||
switch (enabled_)
|
setSoundVolume(enabled_ ? Options::audio.sound.volume : 0);
|
||||||
{
|
setMusicVolume(enabled_ ? Options::audio.music.volume : 0);
|
||||||
case true:
|
|
||||||
setSoundVolume(options.audio.sound.volume);
|
|
||||||
setMusicVolume(options.audio.music.volume);
|
|
||||||
break;
|
|
||||||
case false:
|
|
||||||
setSoundVolume(0);
|
|
||||||
setMusicVolume(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -488,15 +488,15 @@ void Credits::updateAllFades()
|
|||||||
// Establece el nivel de volumen
|
// Establece el nivel de volumen
|
||||||
void Credits::setVolume(int amount)
|
void Credits::setVolume(int amount)
|
||||||
{
|
{
|
||||||
options.audio.music.volume = std::clamp(amount, 0, 100);
|
Options::audio.music.volume = std::clamp(amount, 0, 100);
|
||||||
Audio::get()->setMusicVolume(options.audio.music.volume);
|
Audio::get()->setMusicVolume(Options::audio.music.volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reestablece el nivel de volumen
|
// Reestablece el nivel de volumen
|
||||||
void Credits::resetVolume()
|
void Credits::resetVolume()
|
||||||
{
|
{
|
||||||
options.audio.music.volume = initial_volume_;
|
Options::audio.music.volume = initial_volume_;
|
||||||
Audio::get()->setMusicVolume(options.audio.music.volume);
|
Audio::get()->setMusicVolume(Options::audio.music.volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el color del fondo
|
// Cambia el color del fondo
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ private:
|
|||||||
int mini_logo_final_pos_ = 0; // Posición final del minilogo
|
int mini_logo_final_pos_ = 0; // Posición final del minilogo
|
||||||
|
|
||||||
// --- Control de audio ---
|
// --- Control de audio ---
|
||||||
int initial_volume_ = options.audio.music.volume; // Volumen inicial
|
int initial_volume_ = Options::audio.music.volume; // Volumen inicial
|
||||||
int steps_ = 0; // Pasos para reducir audio
|
int steps_ = 0; // Pasos para reducir audio
|
||||||
|
|
||||||
// --- Rectángulos de renderizado ---
|
// --- Rectángulos de renderizado ---
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ void DefineButtons::render()
|
|||||||
{
|
{
|
||||||
if (enabled_)
|
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_, controller_names_.at(index_controller_));
|
||||||
text_->writeCentered(x_, y_ + 10, buttons_.at(index_button_).label);
|
text_->writeCentered(x_, y_ + 10, buttons_.at(index_button_).label);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ void DefineButtons::incIndexButton()
|
|||||||
void DefineButtons::saveBindingsToOptions()
|
void DefineButtons::saveBindingsToOptions()
|
||||||
{
|
{
|
||||||
// Modifica las opciones para colocar los valores asignados
|
// Modifica las opciones para colocar los valores asignados
|
||||||
auto &controller = options.controllers.at(index_controller_);
|
auto &controller = Options::controllers.at(index_controller_);
|
||||||
controller.name = input_->getControllerName(index_controller_);
|
controller.name = input_->getControllerName(index_controller_);
|
||||||
for (size_t j = 0; j < controller.inputs.size(); ++j)
|
for (size_t j = 0; j < controller.inputs.size(); ++j)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,14 +46,14 @@
|
|||||||
Director::Director(int argc, const char *argv[])
|
Director::Director(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
section::name = section::Name::GAME;
|
Section::name = Section::Name::GAME;
|
||||||
section::options = section::Options::GAME_PLAY_1P;
|
Section::options = Section::Options::GAME_PLAY_1P;
|
||||||
#elif DEBUG
|
#elif DEBUG
|
||||||
Section::name = Section::Name::LOGO;
|
Section::name = Section::Name::LOGO;
|
||||||
Section::options = Section::Options::GAME_PLAY_1P;
|
Section::options = Section::Options::GAME_PLAY_1P;
|
||||||
#else // NORMAL GAME
|
#else // NORMAL GAME
|
||||||
section::name = section::Name::LOGO;
|
Section::name = Section::Name::LOGO;
|
||||||
section::options = section::Options::NONE;
|
Section::options = Section::Options::NONE;
|
||||||
#endif
|
#endif
|
||||||
Section::attract_mode = Section::AttractMode::TITLE_TO_DEMO;
|
Section::attract_mode = Section::AttractMode::TITLE_TO_DEMO;
|
||||||
|
|
||||||
@@ -88,12 +88,12 @@ void Director::init()
|
|||||||
// Configuración inicial de recursos
|
// Configuración inicial de recursos
|
||||||
Asset::init(executable_path_); // Inicializa el sistema de gestión de archivos
|
Asset::init(executable_path_); // Inicializa el sistema de gestión de archivos
|
||||||
setFileList(); // Crea el índice de archivos
|
setFileList(); // Crea el índice de archivos
|
||||||
loadOptionsFile(Asset::get()->get("config.txt")); // Carga el archivo de configuración
|
Options::loadOptionsFile(Asset::get()->get("config.txt")); // Carga el archivo de configuración
|
||||||
loadParams(); // Carga los parámetros del programa
|
loadParams(); // Carga los parámetros del programa
|
||||||
loadScoreFile(); // Carga el archivo de puntuaciones
|
loadScoreFile(); // Carga el archivo de puntuaciones
|
||||||
|
|
||||||
// Inicialización de subsistemas principales
|
// 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
|
Screen::init(); // Inicializa la pantalla y el sistema de renderizado
|
||||||
Audio::init(); // Activa el sistema de audio
|
Audio::init(); // Activa el sistema de audio
|
||||||
Resource::init(); // Inicializa el sistema de gestión de recursos
|
Resource::init(); // Inicializa el sistema de gestión de recursos
|
||||||
@@ -108,7 +108,7 @@ void Director::init()
|
|||||||
void Director::close()
|
void Director::close()
|
||||||
{
|
{
|
||||||
// Guarda las opciones actuales en el archivo de configuración
|
// Guarda las opciones actuales en el archivo de configuración
|
||||||
saveOptionsFile(Asset::get()->get("config.txt"));
|
Options::saveOptionsFile(Asset::get()->get("config.txt"));
|
||||||
|
|
||||||
// Libera los singletons y recursos en orden inverso al de inicialización
|
// Libera los singletons y recursos en orden inverso al de inicialización
|
||||||
Notifier::destroy(); // Libera el sistema de notificaciones
|
Notifier::destroy(); // Libera el sistema de notificaciones
|
||||||
@@ -141,7 +141,7 @@ void Director::loadParams()
|
|||||||
// Carga el fichero de puntuaciones
|
// Carga el fichero de puntuaciones
|
||||||
void Director::loadScoreFile()
|
void Director::loadScoreFile()
|
||||||
{
|
{
|
||||||
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
|
auto manager = std::make_unique<ManageHiScoreTable>(Options::game.hi_score_table);
|
||||||
if (overrides.clear_hi_score_table)
|
if (overrides.clear_hi_score_table)
|
||||||
{
|
{
|
||||||
manager->clear();
|
manager->clear();
|
||||||
@@ -218,7 +218,7 @@ void Director::bindInputs()
|
|||||||
const size_t max_controllers = std::min(2, NUM_GAMEPADS);
|
const size_t max_controllers = std::min(2, NUM_GAMEPADS);
|
||||||
for (size_t i = 0; i < max_controllers; ++i)
|
for (size_t i = 0; i < max_controllers; ++i)
|
||||||
{
|
{
|
||||||
for (auto &controller : options.controllers)
|
for (auto &controller : Options::controllers)
|
||||||
{
|
{
|
||||||
if (Input::get()->getControllerName(i) == controller.name)
|
if (Input::get()->getControllerName(i) == controller.name)
|
||||||
{
|
{
|
||||||
@@ -247,20 +247,20 @@ void Director::bindInputs()
|
|||||||
for (size_t i = 0; i < max_controllers; ++i)
|
for (size_t i = 0; i < max_controllers; ++i)
|
||||||
{
|
{
|
||||||
// Variables asociadas al mando
|
// Variables asociadas al mando
|
||||||
options.controllers.at(i).index = i;
|
Options::controllers.at(i).index = i;
|
||||||
options.controllers.at(i).name = Input::get()->getControllerName(i);
|
Options::controllers.at(i).name = Input::get()->getControllerName(i);
|
||||||
options.controllers.at(i).plugged = true;
|
Options::controllers.at(i).plugged = true;
|
||||||
// Asignaciones de botones
|
// Asignaciones de botones
|
||||||
for (size_t j = 0; j < options.controllers.at(i).inputs.size(); ++j)
|
for (size_t j = 0; j < Options::controllers.at(i).inputs.size(); ++j)
|
||||||
{
|
{
|
||||||
options.controllers.at(i).buttons.at(j) = Input::get()->getControllerBinding(i, options.controllers.at(i).inputs.at(j));
|
Options::controllers.at(i).buttons.at(j) = Input::get()->getControllerBinding(i, Options::controllers.at(i).inputs.at(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asegura que algún jugador tenga el teclado asignado
|
// Asegura que algún jugador tenga el teclado asignado
|
||||||
if (getPlayerWhoUsesKeyboard() == 0)
|
if (Options::getPlayerWhoUsesKeyboard() == 0)
|
||||||
{
|
{
|
||||||
setKeyboardToPlayer(1);
|
Options::setKeyboardToPlayer(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,9 +617,9 @@ void Director::runDemoGame()
|
|||||||
// Reinicia objetos y vuelve a la sección inicial
|
// Reinicia objetos y vuelve a la sección inicial
|
||||||
void Director::reset()
|
void Director::reset()
|
||||||
{
|
{
|
||||||
saveOptionsFile(Asset::get()->get("config.txt"));
|
Options::saveOptionsFile(Asset::get()->get("config.txt"));
|
||||||
loadOptionsFile(Asset::get()->get("config.txt"));
|
Options::loadOptionsFile(Asset::get()->get("config.txt"));
|
||||||
Lang::setLanguage(options.game.language);
|
Lang::setLanguage(Options::game.language);
|
||||||
Audio::get()->stopMusic();
|
Audio::get()->stopMusic();
|
||||||
Audio::get()->stopAllSounds();
|
Audio::get()->stopAllSounds();
|
||||||
if (Section::options == Section::Options::RELOAD || true)
|
if (Section::options == Section::Options::RELOAD || true)
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ Game::~Game()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// [Modo JUEGO] Guarda puntuaciones y transita a modo título
|
// [Modo JUEGO] Guarda puntuaciones y transita a modo título
|
||||||
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
|
auto manager = std::make_unique<ManageHiScoreTable>(Options::game.hi_score_table);
|
||||||
manager->saveToFile(Asset::get()->get("score.bin"));
|
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();
|
Audio::get()->stopMusic();
|
||||||
@@ -326,7 +326,7 @@ void Game::updateGameStateGameOver()
|
|||||||
|
|
||||||
if (fade_out_->isEnabled())
|
if (fade_out_->isEnabled())
|
||||||
{
|
{
|
||||||
if (options.audio.enabled)
|
if (Options::audio.enabled)
|
||||||
{
|
{
|
||||||
const float VOL = static_cast<float>(64 * (100 - fade_out_->getValue())) / 100.0f;
|
const float VOL = static_cast<float>(64 * (100 - fade_out_->getValue())) / 100.0f;
|
||||||
Audio::get()->setSoundVolume(static_cast<int>(VOL));
|
Audio::get()->setSoundVolume(static_cast<int>(VOL));
|
||||||
@@ -346,10 +346,10 @@ void Game::updateGameStateGameOver()
|
|||||||
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)
|
if (Options::audio.enabled)
|
||||||
{
|
{
|
||||||
Audio::get()->stopAllSounds();
|
Audio::get()->stopAllSounds();
|
||||||
Audio::get()->setSoundVolume(options.audio.sound.volume);
|
Audio::get()->setSoundVolume(Options::audio.sound.volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1267,10 +1267,10 @@ void Game::pause(bool value)
|
|||||||
void Game::addScoreToScoreBoard(const std::shared_ptr<Player> &player)
|
void Game::addScoreToScoreBoard(const std::shared_ptr<Player> &player)
|
||||||
{
|
{
|
||||||
const auto entry = HiScoreEntry(trim(player->getRecordName()), player->getScore(), player->get1CC());
|
const auto entry = HiScoreEntry(trim(player->getRecordName()), player->getScore(), player->get1CC());
|
||||||
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
|
auto manager = std::make_unique<ManageHiScoreTable>(Options::game.hi_score_table);
|
||||||
options.game.last_hi_score_entry.at(player->getId() - 1) = manager->add(entry);
|
Options::game.last_hi_score_entry.at(player->getId() - 1) = manager->add(entry);
|
||||||
manager->saveToFile(Asset::get()->get("score.bin"));
|
manager->saveToFile(Asset::get()->get("score.bin"));
|
||||||
hi_score_.name = options.game.hi_score_table.front().name;
|
hi_score_.name = Options::game.hi_score_table.front().name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Saca del estado de GAME OVER al jugador si el otro está activo
|
// Saca del estado de GAME OVER al jugador si el otro está activo
|
||||||
@@ -1321,12 +1321,12 @@ std::shared_ptr<Player> Game::getPlayer(int id)
|
|||||||
// Obtiene un controlador a partir del "id" del jugador
|
// Obtiene un controlador a partir del "id" del jugador
|
||||||
int Game::getController(int player_id)
|
int Game::getController(int player_id)
|
||||||
{
|
{
|
||||||
auto it = std::find_if(options.controllers.begin(), options.controllers.end(), [player_id](const auto &controller)
|
auto it = std::find_if(Options::controllers.begin(), Options::controllers.end(), [player_id](const auto &controller)
|
||||||
{ return controller.player_id == player_id; });
|
{ return controller.player_id == player_id; });
|
||||||
|
|
||||||
if (it != options.controllers.end())
|
if (it != Options::controllers.end())
|
||||||
{
|
{
|
||||||
return std::distance(options.controllers.begin(), it);
|
return std::distance(Options::controllers.begin(), it);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1443,7 +1443,7 @@ void Game::handleFireInput(const std::shared_ptr<Player> &player, BulletType bul
|
|||||||
Audio::get()->playSound("bullet.wav");
|
Audio::get()->playSound("bullet.wav");
|
||||||
|
|
||||||
// Establece un tiempo de espera para el próximo disparo.
|
// Establece un tiempo de espera para el próximo disparo.
|
||||||
const int cooldown = player->isPowerUp() ? 5 : options.game.autofire ? 10
|
const int cooldown = player->isPowerUp() ? 5 : Options::game.autofire ? 10
|
||||||
: 7;
|
: 7;
|
||||||
player->setFireCooldown(cooldown);
|
player->setFireCooldown(cooldown);
|
||||||
}
|
}
|
||||||
@@ -1475,8 +1475,8 @@ void Game::handlePlayersInput()
|
|||||||
// Maneja las entradas de movimiento y disparo para un jugador en modo normal.
|
// Maneja las entradas de movimiento y disparo para un jugador en modo normal.
|
||||||
void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player)
|
void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player)
|
||||||
{
|
{
|
||||||
const auto &controller = options.controllers.at(player->getController());
|
const auto &controller = Options::controllers.at(player->getController());
|
||||||
const bool autofire = player->isPowerUp() || options.game.autofire;
|
const bool autofire = player->isPowerUp() || Options::game.autofire;
|
||||||
|
|
||||||
if (input_->checkInput(InputAction::LEFT, INPUT_ALLOW_REPEAT, controller.type, controller.index))
|
if (input_->checkInput(InputAction::LEFT, INPUT_ALLOW_REPEAT, controller.type, controller.index))
|
||||||
{
|
{
|
||||||
@@ -1506,21 +1506,21 @@ void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player)
|
|||||||
// Procesa las entradas de disparo del jugador, permitiendo disparos automáticos si está habilitado.
|
// Procesa las entradas de disparo del jugador, permitiendo disparos automáticos si está habilitado.
|
||||||
void Game::handleFireInputs(const std::shared_ptr<Player> &player, bool autofire, int controllerIndex)
|
void Game::handleFireInputs(const std::shared_ptr<Player> &player, bool autofire, int controllerIndex)
|
||||||
{
|
{
|
||||||
if (input_->checkInput(InputAction::FIRE_CENTER, autofire, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
if (input_->checkInput(InputAction::FIRE_CENTER, autofire, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index))
|
||||||
{
|
{
|
||||||
handleFireInput(player, BulletType::UP);
|
handleFireInput(player, BulletType::UP);
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
demo_.keys.fire = 1;
|
demo_.keys.fire = 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (input_->checkInput(InputAction::FIRE_LEFT, autofire, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
else if (input_->checkInput(InputAction::FIRE_LEFT, autofire, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index))
|
||||||
{
|
{
|
||||||
handleFireInput(player, BulletType::LEFT);
|
handleFireInput(player, BulletType::LEFT);
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
demo_.keys.fire_left = 1;
|
demo_.keys.fire_left = 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (input_->checkInput(InputAction::FIRE_RIGHT, autofire, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
else if (input_->checkInput(InputAction::FIRE_RIGHT, autofire, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index))
|
||||||
{
|
{
|
||||||
handleFireInput(player, BulletType::RIGHT);
|
handleFireInput(player, BulletType::RIGHT);
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
@@ -1533,16 +1533,16 @@ void Game::handleFireInputs(const std::shared_ptr<Player> &player, bool autofire
|
|||||||
void Game::handlePlayerContinue(const std::shared_ptr<Player> &player)
|
void Game::handlePlayerContinue(const std::shared_ptr<Player> &player)
|
||||||
{
|
{
|
||||||
const auto controllerIndex = player->getController();
|
const auto controllerIndex = player->getController();
|
||||||
if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index))
|
||||||
{
|
{
|
||||||
player->setPlayingState(PlayerState::PLAYING);
|
player->setPlayingState(PlayerState::PLAYING);
|
||||||
player->addCredit();
|
player->addCredit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disminuye el contador de continuación si se presiona cualquier botón de disparo.
|
// Disminuye el contador de continuación si se presiona cualquier botón de disparo.
|
||||||
if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) ||
|
if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index) ||
|
||||||
input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) ||
|
input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index) ||
|
||||||
input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index))
|
||||||
{
|
{
|
||||||
if (player->getContinueCounter() < 7)
|
if (player->getContinueCounter() < 7)
|
||||||
{
|
{
|
||||||
@@ -1555,9 +1555,9 @@ void Game::handlePlayerContinue(const std::shared_ptr<Player> &player)
|
|||||||
void Game::handleNameInput(const std::shared_ptr<Player> &player)
|
void Game::handleNameInput(const std::shared_ptr<Player> &player)
|
||||||
{
|
{
|
||||||
const auto controllerIndex = player->getController();
|
const auto controllerIndex = player->getController();
|
||||||
if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) ||
|
if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index) ||
|
||||||
input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) ||
|
input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index) ||
|
||||||
input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index))
|
||||||
{
|
{
|
||||||
if (player->isShowingName())
|
if (player->isShowingName())
|
||||||
{
|
{
|
||||||
@@ -1574,19 +1574,19 @@ void Game::handleNameInput(const std::shared_ptr<Player> &player)
|
|||||||
player->setInput(InputAction::RIGHT);
|
player->setInput(InputAction::RIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (input_->checkInput(InputAction::UP, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
else if (input_->checkInput(InputAction::UP, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index))
|
||||||
{
|
{
|
||||||
player->setInput(InputAction::UP);
|
player->setInput(InputAction::UP);
|
||||||
}
|
}
|
||||||
else if (input_->checkInput(InputAction::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
else if (input_->checkInput(InputAction::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index))
|
||||||
{
|
{
|
||||||
player->setInput(InputAction::DOWN);
|
player->setInput(InputAction::DOWN);
|
||||||
}
|
}
|
||||||
else if (input_->checkInput(InputAction::LEFT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
else if (input_->checkInput(InputAction::LEFT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index))
|
||||||
{
|
{
|
||||||
player->setInput(InputAction::LEFT);
|
player->setInput(InputAction::LEFT);
|
||||||
}
|
}
|
||||||
else if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
else if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index))
|
||||||
{
|
{
|
||||||
player->setInput(InputAction::START);
|
player->setInput(InputAction::START);
|
||||||
addScoreToScoreBoard(player);
|
addScoreToScoreBoard(player);
|
||||||
@@ -1689,7 +1689,7 @@ void Game::initDifficultyVars()
|
|||||||
// Variables relacionadas con la dificultad
|
// Variables relacionadas con la dificultad
|
||||||
switch (difficulty_)
|
switch (difficulty_)
|
||||||
{
|
{
|
||||||
case DifficultyCode::EASY:
|
case Options::DifficultyCode::EASY:
|
||||||
{
|
{
|
||||||
balloon_manager_->setDefaultBalloonSpeed(BALLOON_SPEED[0]);
|
balloon_manager_->setDefaultBalloonSpeed(BALLOON_SPEED[0]);
|
||||||
difficulty_score_multiplier_ = 0.5f;
|
difficulty_score_multiplier_ = 0.5f;
|
||||||
@@ -1697,7 +1697,7 @@ void Game::initDifficultyVars()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DifficultyCode::NORMAL:
|
case Options::DifficultyCode::NORMAL:
|
||||||
{
|
{
|
||||||
balloon_manager_->setDefaultBalloonSpeed(BALLOON_SPEED[0]);
|
balloon_manager_->setDefaultBalloonSpeed(BALLOON_SPEED[0]);
|
||||||
difficulty_score_multiplier_ = 1.0f;
|
difficulty_score_multiplier_ = 1.0f;
|
||||||
@@ -1705,7 +1705,7 @@ void Game::initDifficultyVars()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DifficultyCode::HARD:
|
case Options::DifficultyCode::HARD:
|
||||||
{
|
{
|
||||||
balloon_manager_->setDefaultBalloonSpeed(BALLOON_SPEED[4]);
|
balloon_manager_->setDefaultBalloonSpeed(BALLOON_SPEED[4]);
|
||||||
difficulty_score_multiplier_ = 1.5f;
|
difficulty_score_multiplier_ = 1.5f;
|
||||||
@@ -1935,7 +1935,7 @@ void Game::evaluateAndSetMenace()
|
|||||||
// Actualiza la velocidad de los globos en funcion del poder acumulado de la fase
|
// Actualiza la velocidad de los globos en funcion del poder acumulado de la fase
|
||||||
void Game::checkAndUpdateBalloonSpeed()
|
void Game::checkAndUpdateBalloonSpeed()
|
||||||
{
|
{
|
||||||
if (difficulty_ != DifficultyCode::NORMAL)
|
if (difficulty_ != Options::DifficultyCode::NORMAL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const float percent = static_cast<float>(Stage::power) / Stage::get(Stage::number).power_to_complete;
|
const float percent = static_cast<float>(Stage::power) / Stage::get(Stage::number).power_to_complete;
|
||||||
|
|||||||
@@ -135,11 +135,11 @@ private:
|
|||||||
|
|
||||||
// --- Variables de estado ---
|
// --- Variables de estado ---
|
||||||
HiScoreEntry hi_score_ = HiScoreEntry(
|
HiScoreEntry hi_score_ = HiScoreEntry(
|
||||||
options.game.hi_score_table[0].name,
|
Options::game.hi_score_table[0].name,
|
||||||
options.game.hi_score_table[0].score); // Máxima puntuación y nombre de quien la ostenta
|
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
|
Demo demo_; // Variable con todas las variables relacionadas con el modo demo
|
||||||
DifficultyCode difficulty_ = options.game.difficulty; // Dificultad del juego
|
Options::DifficultyCode difficulty_ = Options::game.difficulty; // Dificultad del juego
|
||||||
Helper helper_; // Variable para gestionar las ayudas
|
Helper helper_; // Variable para gestionar las ayudas
|
||||||
Uint64 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
|
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
|
bool coffee_machine_enabled_ = false; // Indica si hay una máquina de café en el terreno de juego
|
||||||
|
|||||||
@@ -51,30 +51,30 @@ namespace GlobalInputs
|
|||||||
// Activa o desactiva el audio
|
// Activa o desactiva el audio
|
||||||
void toggleAudio()
|
void toggleAudio()
|
||||||
{
|
{
|
||||||
options.audio.enabled = !options.audio.enabled;
|
Options::audio.enabled = !Options::audio.enabled;
|
||||||
Audio::get()->enable(options.audio.enabled);
|
Audio::get()->enable(Options::audio.enabled);
|
||||||
Notifier::get()->show({"Audio " + boolToOnOff(options.audio.enabled)});
|
Notifier::get()->show({"Audio " + boolToOnOff(Options::audio.enabled)});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el modo de escalado entero
|
// Cambia el modo de escalado entero
|
||||||
void toggleIntegerScale()
|
void toggleIntegerScale()
|
||||||
{
|
{
|
||||||
Screen::get()->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
|
// Activa / desactiva el vsync
|
||||||
void toggleVSync()
|
void toggleVSync()
|
||||||
{
|
{
|
||||||
Screen::get()->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
|
// Activa o desactiva los shaders
|
||||||
void toggleShaders()
|
void toggleShaders()
|
||||||
{
|
{
|
||||||
Screen::get()->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
|
// Obtiene una fichero a partir de un lang::Code
|
||||||
@@ -117,15 +117,15 @@ namespace GlobalInputs
|
|||||||
const std::string CODE = "LANG";
|
const std::string CODE = "LANG";
|
||||||
if (Notifier::get()->checkCode(CODE))
|
if (Notifier::get()->checkCode(CODE))
|
||||||
{
|
{
|
||||||
options.game.language = Lang::getNextLangCode(options.game.language);
|
Options::game.language = Lang::getNextLangCode(Options::game.language);
|
||||||
Lang::loadFromFile(getLangFile(static_cast<Lang::Code>(options.game.language)));
|
Lang::loadFromFile(getLangFile(static_cast<Lang::Code>(Options::game.language)));
|
||||||
Section::name = Section::Name::RESET;
|
Section::name = Section::Name::RESET;
|
||||||
Section::options = Section::Options::RELOAD;
|
Section::options = Section::Options::RELOAD;
|
||||||
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 05") + getLangName(options.game.language)});
|
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 05") + getLangName(Options::game.language)});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto NEXT = Lang::getNextLangCode(options.game.language);
|
const auto NEXT = Lang::getNextLangCode(Options::game.language);
|
||||||
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 04") + getLangName(NEXT), std::string()}, -1, CODE);
|
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 04") + getLangName(NEXT), std::string()}, -1, CODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,8 +133,8 @@ namespace GlobalInputs
|
|||||||
// Cambia el modo de disparo
|
// Cambia el modo de disparo
|
||||||
void toggleFireMode()
|
void toggleFireMode()
|
||||||
{
|
{
|
||||||
options.game.autofire = !options.game.autofire;
|
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
|
// Salta una sección del juego
|
||||||
@@ -169,7 +169,7 @@ namespace GlobalInputs
|
|||||||
void toggleFullscreen()
|
void toggleFullscreen()
|
||||||
{
|
{
|
||||||
Screen::get()->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});
|
Notifier::get()->show({MODE});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ namespace GlobalInputs
|
|||||||
{
|
{
|
||||||
if (Screen::get()->decWindowSize())
|
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())
|
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))
|
if (Input::get()->checkInput(InputAction::WINDOW_FULLSCREEN, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||||
{
|
{
|
||||||
Screen::get()->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});
|
Notifier::get()->show({MODE});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -333,7 +333,7 @@ namespace GlobalInputs
|
|||||||
{
|
{
|
||||||
if (Screen::get()->decWindowSize())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
@@ -343,7 +343,7 @@ namespace GlobalInputs
|
|||||||
{
|
{
|
||||||
if (Screen::get()->incWindowSize())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ HiScoreTable::HiScoreTable()
|
|||||||
HiScoreTable::~HiScoreTable()
|
HiScoreTable::~HiScoreTable()
|
||||||
{
|
{
|
||||||
SDL_DestroyTexture(backbuffer_);
|
SDL_DestroyTexture(backbuffer_);
|
||||||
options.game.clearLastHiScoreEntries();
|
Options::game.clearLastHiScoreEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
@@ -232,15 +232,15 @@ void HiScoreTable::createSprites()
|
|||||||
for (int i = 0; i < MAX_NAMES; ++i)
|
for (int i = 0; i < MAX_NAMES; ++i)
|
||||||
{
|
{
|
||||||
const auto table_position = format(i + 1) + ". ";
|
const auto table_position = format(i + 1) + ". ";
|
||||||
const auto score = format(options.game.hi_score_table.at(i).score);
|
const auto score = format(Options::game.hi_score_table.at(i).score);
|
||||||
const auto num_dots = ENTRY_LENGHT - options.game.hi_score_table.at(i).name.size() - score.size();
|
const auto num_dots = ENTRY_LENGHT - Options::game.hi_score_table.at(i).name.size() - score.size();
|
||||||
const auto one_cc = options.game.hi_score_table.at(i).one_credit_complete ? " }" : "";
|
const auto one_cc = Options::game.hi_score_table.at(i).one_credit_complete ? " }" : "";
|
||||||
std::string dots;
|
std::string dots;
|
||||||
for (int j = 0; j < (int)num_dots; ++j)
|
for (int j = 0; j < (int)num_dots; ++j)
|
||||||
{
|
{
|
||||||
dots = dots + ".";
|
dots = dots + ".";
|
||||||
}
|
}
|
||||||
const auto line = table_position + options.game.hi_score_table.at(i).name + dots + score + one_cc;
|
const auto line = table_position + Options::game.hi_score_table.at(i).name + dots + score + one_cc;
|
||||||
|
|
||||||
entry_names_.emplace_back(std::make_shared<PathSprite>(entry_text->writeDXToTexture(TEXT_SHADOW, line, 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR)));
|
entry_names_.emplace_back(std::make_shared<PathSprite>(entry_text->writeDXToTexture(TEXT_SHADOW, line, 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR)));
|
||||||
const int default_pos_x = (backbuffer_width - entry_width) / 2;
|
const int default_pos_x = (backbuffer_width - entry_width) / 2;
|
||||||
@@ -402,7 +402,7 @@ void HiScoreTable::iniEntryColors()
|
|||||||
void HiScoreTable::glowEntryNames()
|
void HiScoreTable::glowEntryNames()
|
||||||
{
|
{
|
||||||
const Color entry_color = getEntryColor(counter_ / 5);
|
const Color entry_color = getEntryColor(counter_ / 5);
|
||||||
for (const auto &entry_index : options.game.last_hi_score_entry)
|
for (const auto &entry_index : Options::game.last_hi_score_entry)
|
||||||
{
|
{
|
||||||
if (entry_index != -1)
|
if (entry_index != -1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ namespace Lang
|
|||||||
// Establece el idioma
|
// Establece el idioma
|
||||||
void setLanguage(Code lang)
|
void setLanguage(Code lang)
|
||||||
{
|
{
|
||||||
options.game.language = lang;
|
Options::game.language = lang;
|
||||||
loadFromFile(Asset::get()->get(getLanguage(lang).file_name));
|
loadFromFile(Asset::get()->get(getLanguage(lang).file_name));
|
||||||
updateLanguageNames();
|
updateLanguageNames();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,14 @@
|
|||||||
|
|
||||||
namespace Options
|
namespace 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
|
||||||
|
|
||||||
// Vector con las dificultades
|
// Vector con las dificultades
|
||||||
std::vector<Difficulty> difficulties = {
|
std::vector<Difficulty> difficulties = {
|
||||||
{DifficultyCode::EASY, "Easy"},
|
{DifficultyCode::EASY, "Easy"},
|
||||||
|
|||||||
@@ -119,12 +119,12 @@ namespace Options
|
|||||||
};
|
};
|
||||||
|
|
||||||
// --- Variables globales ---
|
// --- Variables globales ---
|
||||||
WindowOptions window; // Opciones de la ventana
|
extern WindowOptions window; // Opciones de la ventana
|
||||||
GameOptions game; // Opciones del juego
|
extern GameOptions game; // Opciones del juego
|
||||||
VideoOptions video; // Opciones de vídeo
|
extern VideoOptions video; // Opciones de vídeo
|
||||||
AudioOptions audio; // Opciones de audio
|
extern AudioOptions audio; // Opciones de audio
|
||||||
std::vector<GamepadOptions> controllers; // Opciones de mando para cada jugador
|
extern std::vector<GamepadOptions> controllers; // Opciones de mando para cada jugador
|
||||||
PendingChanges pending_changes; // Opciones que se aplican al cerrar
|
extern PendingChanges pending_changes; // Opciones que se aplican al cerrar
|
||||||
|
|
||||||
// --- Funciones de configuración ---
|
// --- Funciones de configuración ---
|
||||||
void initOptions(); // Inicializa las opciones del programa
|
void initOptions(); // Inicializa las opciones del programa
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public:
|
|||||||
bool canFire() const { return cool_down_ <= 0; }
|
bool canFire() const { return cool_down_ <= 0; }
|
||||||
bool hasExtraHit() const { return extra_hit_; }
|
bool hasExtraHit() const { return extra_hit_; }
|
||||||
bool isCooling() const { return firing_state_ == PlayerState::COOLING_LEFT || firing_state_ == PlayerState::COOLING_UP || firing_state_ == PlayerState::COOLING_RIGHT; }
|
bool isCooling() const { return firing_state_ == PlayerState::COOLING_LEFT || firing_state_ == PlayerState::COOLING_UP || firing_state_ == PlayerState::COOLING_RIGHT; }
|
||||||
bool IsEligibleForHighScore() const { return score_ > options.game.hi_score_table.back().score; }
|
bool IsEligibleForHighScore() const { return score_ > Options::game.hi_score_table.back().score; }
|
||||||
bool isInvulnerable() const { return invulnerable_; }
|
bool isInvulnerable() const { return invulnerable_; }
|
||||||
bool isPowerUp() const { return power_up_; }
|
bool isPowerUp() const { return power_up_; }
|
||||||
Circle &getCollider() { return collider_; }
|
Circle &getCollider() { return collider_; }
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ void Screen::renderScreen()
|
|||||||
SDL_SetRenderTarget(renderer_, nullptr);
|
SDL_SetRenderTarget(renderer_, nullptr);
|
||||||
clean();
|
clean();
|
||||||
|
|
||||||
if (options.video.shaders)
|
if (Options::video.shaders)
|
||||||
{
|
{
|
||||||
shader::render();
|
shader::render();
|
||||||
}
|
}
|
||||||
@@ -126,10 +126,10 @@ void Screen::renderScreen()
|
|||||||
void Screen::setFullscreenMode(bool mode)
|
void Screen::setFullscreenMode(bool mode)
|
||||||
{
|
{
|
||||||
// Actualiza las opciones
|
// Actualiza las opciones
|
||||||
options.video.fullscreen = mode;
|
Options::video.fullscreen = mode;
|
||||||
|
|
||||||
// Configura el modo de pantalla
|
// Configura el modo de pantalla
|
||||||
SDL_SetWindowFullscreen(window_, options.video.fullscreen);
|
SDL_SetWindowFullscreen(window_, Options::video.fullscreen);
|
||||||
|
|
||||||
initShaders();
|
initShaders();
|
||||||
}
|
}
|
||||||
@@ -137,27 +137,27 @@ void Screen::setFullscreenMode(bool mode)
|
|||||||
// Camibia entre pantalla completa y ventana
|
// Camibia entre pantalla completa y ventana
|
||||||
void Screen::toggleFullscreen()
|
void Screen::toggleFullscreen()
|
||||||
{
|
{
|
||||||
options.video.fullscreen = !options.video.fullscreen;
|
Options::video.fullscreen = !Options::video.fullscreen;
|
||||||
setFullscreenMode();
|
setFullscreenMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el tamaño de la ventana
|
// Cambia el tamaño de la ventana
|
||||||
void Screen::setWindowZoom(int zoom)
|
void Screen::setWindowZoom(int zoom)
|
||||||
{
|
{
|
||||||
options.window.size = zoom;
|
Options::window.size = zoom;
|
||||||
adjustWindowSize();
|
adjustWindowSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce el tamaño de la ventana
|
// Reduce el tamaño de la ventana
|
||||||
bool Screen::decWindowSize()
|
bool Screen::decWindowSize()
|
||||||
{
|
{
|
||||||
if (!options.video.fullscreen)
|
if (!Options::video.fullscreen)
|
||||||
{
|
{
|
||||||
const int PREVIOUS_ZOOM = options.window.size;
|
const int PREVIOUS_ZOOM = Options::window.size;
|
||||||
--options.window.size;
|
--Options::window.size;
|
||||||
options.window.size = std::max(options.window.size, 1);
|
Options::window.size = std::max(Options::window.size, 1);
|
||||||
|
|
||||||
if (options.window.size != PREVIOUS_ZOOM)
|
if (Options::window.size != PREVIOUS_ZOOM)
|
||||||
{
|
{
|
||||||
adjustWindowSize();
|
adjustWindowSize();
|
||||||
return true;
|
return true;
|
||||||
@@ -170,13 +170,13 @@ bool Screen::decWindowSize()
|
|||||||
// Aumenta el tamaño de la ventana
|
// Aumenta el tamaño de la ventana
|
||||||
bool Screen::incWindowSize()
|
bool Screen::incWindowSize()
|
||||||
{
|
{
|
||||||
if (!options.video.fullscreen)
|
if (!Options::video.fullscreen)
|
||||||
{
|
{
|
||||||
const int PREVIOUS_ZOOM = options.window.size;
|
const int PREVIOUS_ZOOM = Options::window.size;
|
||||||
++options.window.size;
|
++Options::window.size;
|
||||||
options.window.size = std::min(options.window.size, options.window.max_size);
|
Options::window.size = std::min(Options::window.size, Options::window.max_size);
|
||||||
|
|
||||||
if (options.window.size != PREVIOUS_ZOOM)
|
if (Options::window.size != PREVIOUS_ZOOM)
|
||||||
{
|
{
|
||||||
adjustWindowSize();
|
adjustWindowSize();
|
||||||
return true;
|
return true;
|
||||||
@@ -249,7 +249,7 @@ void Screen::renderInfo()
|
|||||||
if (debug_info_.show)
|
if (debug_info_.show)
|
||||||
{
|
{
|
||||||
// Resolution
|
// Resolution
|
||||||
debug_info_.text->writeDX(TEXT_COLOR | TEXT_SHADOW, param.game.width - debug_info_.text->lenght(options.video.info) - 2, 1, options.video.info, 1, DEBUG_COLOR, 1, DEBUG_COLOR.darken(150));
|
debug_info_.text->writeDX(TEXT_COLOR | TEXT_SHADOW, param.game.width - debug_info_.text->lenght(Options::video.info) - 2, 1, Options::video.info, 1, DEBUG_COLOR, 1, DEBUG_COLOR.darken(150));
|
||||||
|
|
||||||
// FPS
|
// FPS
|
||||||
const std::string FPS_TEXT = std::to_string(fps_.lastValue) + " FPS";
|
const std::string FPS_TEXT = std::to_string(fps_.lastValue) + " FPS";
|
||||||
@@ -280,10 +280,10 @@ void Screen::initShaders()
|
|||||||
void Screen::adjustWindowSize()
|
void Screen::adjustWindowSize()
|
||||||
{
|
{
|
||||||
// Establece el nuevo tamaño
|
// Establece el nuevo tamaño
|
||||||
if (!options.video.fullscreen)
|
if (!Options::video.fullscreen)
|
||||||
{
|
{
|
||||||
const int WIDTH = param.game.width * options.window.size;
|
const int WIDTH = param.game.width * Options::window.size;
|
||||||
const int HEIGHT = param.game.height * options.window.size;
|
const int HEIGHT = param.game.height * Options::window.size;
|
||||||
|
|
||||||
int old_width, old_height;
|
int old_width, old_height;
|
||||||
SDL_GetWindowSize(window_, &old_width, &old_height);
|
SDL_GetWindowSize(window_, &old_width, &old_height);
|
||||||
@@ -349,7 +349,7 @@ bool Screen::initSDL()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea la ventana
|
// Crea la ventana
|
||||||
window_ = SDL_CreateWindow(options.window.caption.c_str(), param.game.width * options.window.size, param.game.height * options.window.size, SDL_WINDOW_OPENGL);
|
window_ = SDL_CreateWindow(Options::window.caption.c_str(), param.game.width * Options::window.size, param.game.height * Options::window.size, SDL_WINDOW_OPENGL);
|
||||||
if (!window_)
|
if (!window_)
|
||||||
{
|
{
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window could not be created! SDL Error: %s", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window could not be created! SDL Error: %s", SDL_GetError());
|
||||||
@@ -368,9 +368,9 @@ bool Screen::initSDL()
|
|||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
|
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
|
||||||
SDL_SetRenderLogicalPresentation(renderer_, param.game.width, param.game.height, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
|
SDL_SetRenderLogicalPresentation(renderer_, param.game.width, param.game.height, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
|
||||||
SDL_SetWindowFullscreen(window_, options.video.fullscreen);
|
SDL_SetWindowFullscreen(window_, Options::video.fullscreen);
|
||||||
SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND);
|
SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND);
|
||||||
SDL_SetRenderVSync(renderer_, options.video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
SDL_SetRenderVSync(renderer_, Options::video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -397,17 +397,17 @@ void Screen::getDisplayInfo()
|
|||||||
auto DM = SDL_GetCurrentDisplayMode(displays[0]);
|
auto DM = SDL_GetCurrentDisplayMode(displays[0]);
|
||||||
|
|
||||||
// Calcula el máximo factor de zoom que se puede aplicar a la pantalla
|
// Calcula el máximo factor de zoom que se puede aplicar a la pantalla
|
||||||
options.window.max_size = std::min(DM->w / param.game.width, DM->h / param.game.height);
|
Options::window.max_size = std::min(DM->w / param.game.width, DM->h / param.game.height);
|
||||||
options.window.size = std::min(options.window.size, options.window.max_size);
|
Options::window.size = std::min(Options::window.size, Options::window.max_size);
|
||||||
|
|
||||||
// Muestra información sobre el tamaño de la pantalla y de la ventana de juego
|
// Muestra información sobre el tamaño de la pantalla y de la ventana de juego
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Current display mode: %dx%d @ %dHz",
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Current display mode: %dx%d @ %dHz",
|
||||||
static_cast<int>(DM->w), static_cast<int>(DM->h), static_cast<int>(DM->refresh_rate));
|
static_cast<int>(DM->w), static_cast<int>(DM->h), static_cast<int>(DM->refresh_rate));
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Window resolution: %dx%d x%d",
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Window resolution: %dx%d x%d",
|
||||||
static_cast<int>(param.game.width), static_cast<int>(param.game.height), options.window.size);
|
static_cast<int>(param.game.width), static_cast<int>(param.game.height), Options::window.size);
|
||||||
|
|
||||||
options.video.info = std::to_string(static_cast<int>(DM->w)) + "x" +
|
Options::video.info = std::to_string(static_cast<int>(DM->w)) + "x" +
|
||||||
std::to_string(static_cast<int>(DM->h)) + " @ " +
|
std::to_string(static_cast<int>(DM->h)) + " @ " +
|
||||||
std::to_string(static_cast<int>(DM->refresh_rate)) + " Hz";
|
std::to_string(static_cast<int>(DM->refresh_rate)) + " Hz";
|
||||||
|
|
||||||
@@ -415,7 +415,7 @@ void Screen::getDisplayInfo()
|
|||||||
const int MAX_ZOOM = std::min(DM->w / param.game.width, (DM->h - WINDOWS_DECORATIONS_) / param.game.height);
|
const int MAX_ZOOM = std::min(DM->w / param.game.width, (DM->h - WINDOWS_DECORATIONS_) / param.game.height);
|
||||||
|
|
||||||
// Normaliza los valores de zoom
|
// Normaliza los valores de zoom
|
||||||
options.window.size = std::min(options.window.size, MAX_ZOOM);
|
Options::window.size = std::min(Options::window.size, MAX_ZOOM);
|
||||||
|
|
||||||
SDL_free(displays);
|
SDL_free(displays);
|
||||||
}
|
}
|
||||||
@@ -424,21 +424,21 @@ void Screen::getDisplayInfo()
|
|||||||
// Alterna entre activar y desactivar el escalado entero
|
// Alterna entre activar y desactivar el escalado entero
|
||||||
void Screen::toggleIntegerScale()
|
void Screen::toggleIntegerScale()
|
||||||
{
|
{
|
||||||
options.video.integer_scale = !options.video.integer_scale;
|
Options::video.integer_scale = !Options::video.integer_scale;
|
||||||
SDL_SetRenderLogicalPresentation(Screen::get()->getRenderer(), param.game.width, param.game.height, options.video.integer_scale ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE : SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
SDL_SetRenderLogicalPresentation(Screen::get()->getRenderer(), param.game.width, param.game.height, Options::video.integer_scale ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE : SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alterna entre activar y desactivar el V-Sync
|
// Alterna entre activar y desactivar el V-Sync
|
||||||
void Screen::toggleVSync()
|
void Screen::toggleVSync()
|
||||||
{
|
{
|
||||||
options.video.v_sync = !options.video.v_sync;
|
Options::video.v_sync = !Options::video.v_sync;
|
||||||
SDL_SetRenderVSync(renderer_, options.video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
SDL_SetRenderVSync(renderer_, Options::video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el estado del V-Sync
|
// Establece el estado del V-Sync
|
||||||
void Screen::setVSync(bool enabled)
|
void Screen::setVSync(bool enabled)
|
||||||
{
|
{
|
||||||
options.video.v_sync = enabled;
|
Options::video.v_sync = enabled;
|
||||||
SDL_SetRenderVSync(renderer_, enabled ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
SDL_SetRenderVSync(renderer_, enabled ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,8 +452,8 @@ void Screen::getSingletons()
|
|||||||
// Aplica los valores de las opciones
|
// Aplica los valores de las opciones
|
||||||
void Screen::applySettings()
|
void Screen::applySettings()
|
||||||
{
|
{
|
||||||
SDL_SetRenderVSync(renderer_, options.video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
SDL_SetRenderVSync(renderer_, Options::video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||||
SDL_SetRenderLogicalPresentation(Screen::get()->getRenderer(), param.game.width, param.game.height, options.video.integer_scale ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE : SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
SDL_SetRenderLogicalPresentation(Screen::get()->getRenderer(), param.game.width, param.game.height, Options::video.integer_scale ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE : SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
||||||
adjustWindowSize();
|
adjustWindowSize();
|
||||||
setFullscreenMode();
|
setFullscreenMode();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public:
|
|||||||
void coreRender(); // Vuelca el contenido del renderizador en pantalla exceptuando ciertas partes
|
void coreRender(); // Vuelca el contenido del renderizador en pantalla exceptuando ciertas partes
|
||||||
|
|
||||||
// --- Configuración de ventana y render ---
|
// --- Configuración de ventana y render ---
|
||||||
void setFullscreenMode(bool mode = options.video.fullscreen); // Establece el modo de video
|
void setFullscreenMode(bool mode = Options::video.fullscreen); // Establece el modo de video
|
||||||
void toggleFullscreen(); // Cambia entre pantalla completa y ventana
|
void toggleFullscreen(); // Cambia entre pantalla completa y ventana
|
||||||
void setWindowZoom(int size); // Cambia el tamaño de la ventana
|
void setWindowZoom(int size); // Cambia el tamaño de la ventana
|
||||||
bool decWindowSize(); // Reduce el tamaño de la ventana
|
bool decWindowSize(); // Reduce el tamaño de la ventana
|
||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
// --- Efectos visuales ---
|
// --- Efectos visuales ---
|
||||||
void shake() { shake_effect_.enable(src_rect_, dst_rect_); } // Agita la pantalla
|
void shake() { shake_effect_.enable(src_rect_, dst_rect_); } // Agita la pantalla
|
||||||
void flash(Color color, int lenght = 10, int delay = 0) { flash_effect_ = FlashEffect(true, lenght, delay, color); } // Pone la pantalla de color
|
void flash(Color color, int lenght = 10, int delay = 0) { flash_effect_ = FlashEffect(true, lenght, delay, color); } // Pone la pantalla de color
|
||||||
void toggleShaders() { options.video.shaders = !options.video.shaders; } // Alterna entre activar y desactivar los shaders
|
void toggleShaders() { Options::video.shaders = !Options::video.shaders; } // Alterna entre activar y desactivar los shaders
|
||||||
void toggleIntegerScale(); // Alterna entre activar y desactivar el escalado entero
|
void toggleIntegerScale(); // Alterna entre activar y desactivar el escalado entero
|
||||||
void toggleVSync(); // Alterna entre activar y desactivar el V-Sync
|
void toggleVSync(); // Alterna entre activar y desactivar el V-Sync
|
||||||
void setVSync(bool enabled); // Establece el estado del V-Sync
|
void setVSync(bool enabled); // Establece el estado del V-Sync
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
void show() { SDL_ShowWindow(window_); } // Muestra la ventana
|
void show() { SDL_ShowWindow(window_); } // Muestra la ventana
|
||||||
void hide() { SDL_HideWindow(window_); } // Oculta la ventana
|
void hide() { SDL_HideWindow(window_); } // Oculta la ventana
|
||||||
void getSingletons(); // Obtiene los punteros a los singletones
|
void getSingletons(); // Obtiene los punteros a los singletones
|
||||||
bool getVSync() const { return options.video.v_sync; } // Obtiene el valor de V-Sync
|
bool getVSync() const { return Options::video.v_sync; } // Obtiene el valor de V-Sync
|
||||||
std::shared_ptr<Text> getText() const { return text_; } // Obtiene el puntero al texto de Screen
|
std::shared_ptr<Text> getText() const { return text_; } // Obtiene el puntero al texto de Screen
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ void ServiceMenu::render()
|
|||||||
|
|
||||||
// LINEA
|
// LINEA
|
||||||
y = rect_.y + upper_height_;
|
y = rect_.y + upper_height_;
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), options.pending_changes.has_pending_changes ? 0 : 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);
|
SDL_RenderLine(Screen::get()->getRenderer(), rect_.x + OPTIONS_HORIZONTAL_PADDING_, y, rect_.x + rect_.w - OPTIONS_HORIZONTAL_PADDING_, y);
|
||||||
|
|
||||||
// OPCIONES
|
// OPCIONES
|
||||||
@@ -352,25 +352,25 @@ void ServiceMenu::initializeOptions()
|
|||||||
options_.clear();
|
options_.clear();
|
||||||
|
|
||||||
// Video
|
// 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] 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] 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] 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] 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] INTEGER_SCALE"), SettingsGroup::VIDEO, OptionBehavior::ADJUST, &Options::video.integer_scale, ValueType::BOOL);
|
||||||
|
|
||||||
// Audio
|
// 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] 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] 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] 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] SFX_VOLUME"), SettingsGroup::AUDIO, OptionBehavior::ADJUST, &Options::audio.sound.volume, ValueType::INT, 0, 100, 5);
|
||||||
|
|
||||||
// Settings
|
// 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(
|
options_.emplace_back(
|
||||||
Lang::getText("[SERVICE_MENU] LANGUAGE"),
|
Lang::getText("[SERVICE_MENU] LANGUAGE"),
|
||||||
SettingsGroup::SETTINGS,
|
SettingsGroup::SETTINGS,
|
||||||
OptionBehavior::ADJUST,
|
OptionBehavior::ADJUST,
|
||||||
&options.pending_changes.new_language,
|
&Options::pending_changes.new_language,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Lang::getText("[SERVICE_MENU] LANG_ES"),
|
Lang::getText("[SERVICE_MENU] LANG_ES"),
|
||||||
Lang::getText("[SERVICE_MENU] LANG_BA"),
|
Lang::getText("[SERVICE_MENU] LANG_BA"),
|
||||||
@@ -379,17 +379,17 @@ void ServiceMenu::initializeOptions()
|
|||||||
Lang::getText("[SERVICE_MENU] DIFFICULTY"),
|
Lang::getText("[SERVICE_MENU] DIFFICULTY"),
|
||||||
SettingsGroup::SETTINGS,
|
SettingsGroup::SETTINGS,
|
||||||
OptionBehavior::ADJUST,
|
OptionBehavior::ADJUST,
|
||||||
&options.pending_changes.new_difficulty,
|
&Options::pending_changes.new_difficulty,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Lang::getText("[SERVICE_MENU] EASY"),
|
Lang::getText("[SERVICE_MENU] EASY"),
|
||||||
Lang::getText("[SERVICE_MENU] NORMAL"),
|
Lang::getText("[SERVICE_MENU] NORMAL"),
|
||||||
Lang::getText("[SERVICE_MENU] HARD")});
|
Lang::getText("[SERVICE_MENU] HARD")});
|
||||||
options_.emplace_back(Lang::getText("[SERVICE_MENU] ENABLE_SHUTDOWN"), SettingsGroup::SETTINGS, OptionBehavior::ADJUST, &options.game.shutdown_enabled, ValueType::BOOL);
|
options_.emplace_back(Lang::getText("[SERVICE_MENU] ENABLE_SHUTDOWN"), SettingsGroup::SETTINGS, OptionBehavior::ADJUST, &Options::game.shutdown_enabled, ValueType::BOOL);
|
||||||
|
|
||||||
// System
|
// System
|
||||||
options_.emplace_back(Lang::getText("[SERVICE_MENU] RESET"), 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);
|
options_.emplace_back(Lang::getText("[SERVICE_MENU] QUIT"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
|
||||||
if (options.game.shutdown_enabled)
|
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
|
// Menu principal
|
||||||
@@ -526,7 +526,7 @@ void ServiceMenu::AdjustListValues()
|
|||||||
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)
|
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;
|
option->list_index = i;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,17 +144,17 @@ private:
|
|||||||
: (list_index - 1 + value_list.size()) % value_list.size();
|
: (list_index - 1 + value_list.size()) % value_list.size();
|
||||||
|
|
||||||
// Idioma
|
// Idioma
|
||||||
if (linked_variable == &options.pending_changes.new_language)
|
if (linked_variable == &Options::pending_changes.new_language)
|
||||||
{
|
{
|
||||||
options.pending_changes.new_language = Lang::getCodeFromName(value_list[list_index]);
|
Options::pending_changes.new_language = Lang::getCodeFromName(value_list[list_index]);
|
||||||
checkPendingChanges();
|
Options::checkPendingChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dificultad
|
// Dificultad
|
||||||
if (linked_variable == &options.pending_changes.new_difficulty)
|
if (linked_variable == &Options::pending_changes.new_difficulty)
|
||||||
{
|
{
|
||||||
// options.pending_changes.new_difficulty =
|
// Options::pending_changes.new_difficulty =
|
||||||
checkPendingChanges();
|
Options::checkPendingChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,7 +207,6 @@ private:
|
|||||||
size_t upper_height_; // Altura de la parte de arriba del menu: la del titulo
|
size_t upper_height_; // Altura de la parte de arriba del menu: la del titulo
|
||||||
size_t lower_height_; // Altira de la parte baja del menu: la que tiene las opciones
|
size_t lower_height_; // Altira de la parte baja del menu: la que tiene las opciones
|
||||||
size_t lower_padding_; // Espaciado vertical mínimo entre los bordes y el contenido de la zona inferior
|
size_t lower_padding_; // Espaciado vertical mínimo entre los bordes y el contenido de la zona inferior
|
||||||
size_t options_width_; // Anchura de la opcion + valor más larga
|
|
||||||
|
|
||||||
// --- Variables para animación de resize ---
|
// --- Variables para animación de resize ---
|
||||||
SDL_FRect rect_anim_from_{}; // Estado inicial de la animación
|
SDL_FRect rect_anim_from_{}; // Estado inicial de la animación
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ void Title::checkInput()
|
|||||||
if (!define_buttons_->isEnabled())
|
if (!define_buttons_->isEnabled())
|
||||||
{
|
{
|
||||||
// Comprueba todos los métodos de control
|
// Comprueba todos los métodos de control
|
||||||
for (const auto &CONTROLLER : options.controllers)
|
for (const auto &CONTROLLER : Options::controllers)
|
||||||
{
|
{
|
||||||
// START
|
// START
|
||||||
if (Input::get()->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index) &&
|
if (Input::get()->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index) &&
|
||||||
@@ -269,15 +269,15 @@ void Title::swapControllers()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
swapOptionsControllers();
|
Options::swapOptionsControllers();
|
||||||
showControllers();
|
showControllers();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Intercambia el teclado de jugador
|
// Intercambia el teclado de jugador
|
||||||
void Title::swapKeyboard()
|
void Title::swapKeyboard()
|
||||||
{
|
{
|
||||||
swapOptionsKeyboard();
|
Options::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(Options::getPlayerWhoUsesKeyboard()) + ": " + Lang::getText("[DEFINE_BUTTONS] KEYBOARD");
|
||||||
Notifier::get()->show({text});
|
Notifier::get()->show({text});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,16 +293,16 @@ void Title::showControllers()
|
|||||||
for (size_t i = 0; i < NUM_CONTROLLERS; ++i)
|
for (size_t i = 0; i < NUM_CONTROLLERS; ++i)
|
||||||
{
|
{
|
||||||
// Ejemplo: el jugador 1 tiene el mando 2
|
// Ejemplo: el jugador 1 tiene el mando 2
|
||||||
player_controller_index.at(options.controllers.at(i).player_id - 1) = i;
|
player_controller_index.at(Options::controllers.at(i).player_id - 1) = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Genera el texto correspondiente
|
// Genera el texto correspondiente
|
||||||
for (size_t i = 0; i < NUM_CONTROLLERS; ++i)
|
for (size_t i = 0; i < NUM_CONTROLLERS; ++i)
|
||||||
{
|
{
|
||||||
const size_t index = player_controller_index.at(i);
|
const size_t index = player_controller_index.at(i);
|
||||||
if (options.controllers.at(index).plugged)
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user