renombrades extensions .h a .hpp
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
#include "ui/service_menu.h"
|
||||
#include "ui/service_menu.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "audio.h" // Para Audio
|
||||
#include "define_buttons.h" // Para DefineButtons
|
||||
#include "difficulty.h" // Para getCodeFromName, getNameFromCode
|
||||
#include "input.h" // Para Input
|
||||
#include "input_types.h" // Para InputAction
|
||||
#include "lang.h" // Para getText, getCodeFromName, getNameFromCode
|
||||
#include "menu_option.h" // Para MenuOption, ActionOption, BoolOption, ListOption, FolderOption, IntOption, ActionListOption
|
||||
#include "menu_renderer.h" // Para MenuRenderer
|
||||
#include "options.h" // Para GamepadManager, gamepad_manager, PendingChanges, Video, pending_changes, video, Audio, Gamepad, Settings, audio, checkPendingChanges, settings, Window, getPlayerWhoUsesKeyboard, playerIdToString, stringToPlayerId, window, Keyboard, Music, Sound, keyboard
|
||||
#include "param.h" // Para Param, param, ParamGame, ParamServiceMenu
|
||||
#include "player.h" // Para Player
|
||||
#include "resource.h" // Para Resource
|
||||
#include "screen.h" // Para Screen
|
||||
#include "section.hpp" // Para Name, name, Options, options
|
||||
#include "ui/ui_message.h" // Para UIMessage
|
||||
#include "utils.h" // Para Zone
|
||||
#include "audio.hpp" // Para Audio
|
||||
#include "define_buttons.hpp" // Para DefineButtons
|
||||
#include "difficulty.hpp" // Para getCodeFromName, getNameFromCode
|
||||
#include "input.hpp" // Para Input
|
||||
#include "input_types.hpp" // Para InputAction
|
||||
#include "lang.hpp" // Para getText, getCodeFromName, getNameFromCode
|
||||
#include "menu_option.hpp" // Para MenuOption, ActionOption, BoolOption, ListOption, FolderOption, IntOption, ActionListOption
|
||||
#include "menu_renderer.hpp" // Para MenuRenderer
|
||||
#include "options.hpp" // Para GamepadManager, gamepad_manager, PendingChanges, Video, pending_changes, video, Audio, Gamepad, Settings, audio, checkPendingChanges, settings, Window, getPlayerWhoUsesKeyboard, playerIdToString, stringToPlayerId, window, Keyboard, Music, Sound, keyboard
|
||||
#include "param.hpp" // Para Param, param, ParamGame, ParamServiceMenu
|
||||
#include "player.hpp" // Para Player
|
||||
#include "resource.hpp" // Para Resource
|
||||
#include "screen.hpp" // Para Screen
|
||||
#include "section.hpp" // Para Name, name, Options, options
|
||||
#include "ui/ui_message.hpp" // Para UIMessage
|
||||
#include "utils.hpp" // Para Zone
|
||||
|
||||
// Singleton
|
||||
ServiceMenu *ServiceMenu::instance = nullptr;
|
||||
ServiceMenu* ServiceMenu::instance = nullptr;
|
||||
void ServiceMenu::init() { ServiceMenu::instance = new ServiceMenu(); }
|
||||
void ServiceMenu::destroy() { delete ServiceMenu::instance; }
|
||||
auto ServiceMenu::get() -> ServiceMenu * { return ServiceMenu::instance; }
|
||||
auto ServiceMenu::get() -> ServiceMenu* { return ServiceMenu::instance; }
|
||||
|
||||
// Constructor
|
||||
ServiceMenu::ServiceMenu()
|
||||
@@ -153,7 +153,7 @@ void ServiceMenu::adjustOption(bool adjust_up) {
|
||||
if (display_options_.empty()) {
|
||||
return;
|
||||
}
|
||||
auto &selected_option = display_options_.at(selected_);
|
||||
auto& selected_option = display_options_.at(selected_);
|
||||
if (selected_option->getBehavior() == MenuOption::Behavior::ADJUST) {
|
||||
selected_option->adjustValue(adjust_up);
|
||||
applySettings();
|
||||
@@ -169,13 +169,13 @@ void ServiceMenu::selectOption() {
|
||||
main_menu_selected_ = selected_;
|
||||
}
|
||||
|
||||
auto *selected_option = display_options_.at(selected_);
|
||||
auto* selected_option = display_options_.at(selected_);
|
||||
if (selected_option == nullptr) {
|
||||
// This shouldn't happen in normal operation, but protects against null pointer
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto *folder = dynamic_cast<FolderOption *>(selected_option)) {
|
||||
if (auto* folder = dynamic_cast<FolderOption*>(selected_option)) {
|
||||
previous_settings_group_ = current_settings_group_;
|
||||
current_settings_group_ = folder->getTargetGroup();
|
||||
selected_ = 0;
|
||||
@@ -190,7 +190,7 @@ void ServiceMenu::selectOption() {
|
||||
|
||||
void ServiceMenu::updateDisplayOptions() {
|
||||
display_options_.clear();
|
||||
for (auto &option : options_) {
|
||||
for (auto& option : options_) {
|
||||
if (option->getGroup() == current_settings_group_ && !option->isHidden()) {
|
||||
display_options_.push_back(option.get());
|
||||
}
|
||||
@@ -200,7 +200,7 @@ void ServiceMenu::updateDisplayOptions() {
|
||||
|
||||
void ServiceMenu::updateOptionPairs() {
|
||||
option_pairs_.clear();
|
||||
for (const auto &option : display_options_) {
|
||||
for (const auto& option : display_options_) {
|
||||
option_pairs_.emplace_back(option->getCaption(), option->getValueAsString());
|
||||
}
|
||||
}
|
||||
@@ -249,8 +249,8 @@ void ServiceMenu::applySettingsSettings() {
|
||||
setHiddenOptions();
|
||||
}
|
||||
|
||||
auto ServiceMenu::getOptionByCaption(const std::string &caption) const -> MenuOption * {
|
||||
for (const auto &option : options_) {
|
||||
auto ServiceMenu::getOptionByCaption(const std::string& caption) const -> MenuOption* {
|
||||
for (const auto& option : options_) {
|
||||
if (option->getCaption() == caption) {
|
||||
return option.get();
|
||||
}
|
||||
@@ -274,7 +274,7 @@ auto ServiceMenu::getCurrentGroupAlignment() const -> ServiceMenu::GroupAlignmen
|
||||
|
||||
auto ServiceMenu::countOptionsInGroup(SettingsGroup group) const -> size_t {
|
||||
size_t count = 0;
|
||||
for (const auto &option : options_) {
|
||||
for (const auto& option : options_) {
|
||||
if (option->getGroup() == group && !option->isHidden()) {
|
||||
count++;
|
||||
}
|
||||
@@ -294,12 +294,12 @@ void ServiceMenu::initializeOptions() {
|
||||
[]() {
|
||||
return Options::gamepad_manager.getGamepad(Player::Id::PLAYER1).name;
|
||||
},
|
||||
[](const std::string &val) {
|
||||
[](const std::string& val) {
|
||||
Options::gamepad_manager.assignGamepadToPlayer(Player::Id::PLAYER1, Input::get()->getGamepadByName(val), val);
|
||||
},
|
||||
[this]() {
|
||||
// Acción: configurar botones del mando del jugador 1
|
||||
auto *gamepad = &Options::gamepad_manager.getGamepad(Player::Id::PLAYER1);
|
||||
auto* gamepad = &Options::gamepad_manager.getGamepad(Player::Id::PLAYER1);
|
||||
if ((gamepad != nullptr) && gamepad->instance) {
|
||||
define_buttons_->enable(gamepad);
|
||||
}
|
||||
@@ -312,12 +312,12 @@ void ServiceMenu::initializeOptions() {
|
||||
[]() {
|
||||
return Options::gamepad_manager.getGamepad(Player::Id::PLAYER2).name;
|
||||
},
|
||||
[](const std::string &val) {
|
||||
[](const std::string& val) {
|
||||
Options::gamepad_manager.assignGamepadToPlayer(Player::Id::PLAYER2, Input::get()->getGamepadByName(val), val);
|
||||
},
|
||||
[this]() {
|
||||
// Acción: configurar botones del mando del jugador 2
|
||||
auto *gamepad = &Options::gamepad_manager.getGamepad(Player::Id::PLAYER2);
|
||||
auto* gamepad = &Options::gamepad_manager.getGamepad(Player::Id::PLAYER2);
|
||||
if ((gamepad != nullptr) && gamepad->instance) {
|
||||
define_buttons_->enable(gamepad);
|
||||
}
|
||||
@@ -334,7 +334,7 @@ void ServiceMenu::initializeOptions() {
|
||||
// Devolver el jugador actual asignado al teclado
|
||||
return Options::playerIdToString(Options::getPlayerWhoUsesKeyboard());
|
||||
},
|
||||
[](const std::string &val) {
|
||||
[](const std::string& val) {
|
||||
// Asignar el teclado al jugador seleccionado
|
||||
Options::keyboard.assignTo(Options::stringToPlayerId(val));
|
||||
}));
|
||||
@@ -424,7 +424,7 @@ void ServiceMenu::initializeOptions() {
|
||||
[]() {
|
||||
return Lang::getNameFromCode(Options::pending_changes.new_language);
|
||||
},
|
||||
[](const std::string &val) {
|
||||
[](const std::string& val) {
|
||||
Options::pending_changes.new_language = Lang::getCodeFromName(val);
|
||||
Options::checkPendingChanges();
|
||||
}));
|
||||
@@ -439,7 +439,7 @@ void ServiceMenu::initializeOptions() {
|
||||
[]() {
|
||||
return Difficulty::getNameFromCode(Options::pending_changes.new_difficulty);
|
||||
},
|
||||
[](const std::string &val) {
|
||||
[](const std::string& val) {
|
||||
Options::pending_changes.new_difficulty = Difficulty::getCodeFromName(val);
|
||||
Options::checkPendingChanges();
|
||||
}));
|
||||
@@ -507,8 +507,8 @@ void ServiceMenu::initializeOptions() {
|
||||
|
||||
// Sincroniza los valores de las opciones tipo lista
|
||||
void ServiceMenu::adjustListValues() {
|
||||
for (auto &option : options_) {
|
||||
if (auto *list_option = dynamic_cast<ListOption *>(option.get())) {
|
||||
for (auto& option : options_) {
|
||||
if (auto* list_option = dynamic_cast<ListOption*>(option.get())) {
|
||||
list_option->sync();
|
||||
}
|
||||
}
|
||||
@@ -543,14 +543,14 @@ auto ServiceMenu::settingsGroupToString(SettingsGroup group) -> std::string {
|
||||
// Establece el estado de oculto de ciertas opciones
|
||||
void ServiceMenu::setHiddenOptions() {
|
||||
{
|
||||
auto *option = getOptionByCaption(Lang::getText("[SERVICE_MENU] WINDOW_SIZE"));
|
||||
auto* option = getOptionByCaption(Lang::getText("[SERVICE_MENU] WINDOW_SIZE"));
|
||||
if (option != nullptr) {
|
||||
option->setHidden(Options::video.fullscreen);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto *option = getOptionByCaption(Lang::getText("[SERVICE_MENU] SHUTDOWN"));
|
||||
auto* option = getOptionByCaption(Lang::getText("[SERVICE_MENU] SHUTDOWN"));
|
||||
if (option != nullptr) {
|
||||
option->setHidden(!Options::settings.shutdown_enabled);
|
||||
}
|
||||
@@ -559,7 +559,7 @@ void ServiceMenu::setHiddenOptions() {
|
||||
updateMenu(); // El menú debe refrescarse si algo se oculta
|
||||
}
|
||||
|
||||
void ServiceMenu::handleEvent(const SDL_Event &event) {
|
||||
void ServiceMenu::handleEvent(const SDL_Event& event) {
|
||||
if (!enabled_) {
|
||||
return;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ auto ServiceMenu::checkInput() -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
static auto *input_ = Input::get();
|
||||
static auto* input_ = Input::get();
|
||||
using Action = Input::Action;
|
||||
|
||||
const std::vector<std::pair<Action, std::function<void()>>> ACTIONS = {
|
||||
@@ -590,7 +590,7 @@ auto ServiceMenu::checkInput() -> bool {
|
||||
};
|
||||
|
||||
// Teclado
|
||||
for (const auto &[action, func] : ACTIONS) {
|
||||
for (const auto& [action, func] : ACTIONS) {
|
||||
if (input_->checkAction(action, Input::DO_NOT_ALLOW_REPEAT, Input::CHECK_KEYBOARD)) {
|
||||
func();
|
||||
return true;
|
||||
@@ -598,8 +598,8 @@ auto ServiceMenu::checkInput() -> bool {
|
||||
}
|
||||
|
||||
// Mandos
|
||||
for (const auto &gamepad : input_->getGamepads()) {
|
||||
for (const auto &[action, func] : ACTIONS) {
|
||||
for (const auto& gamepad : input_->getGamepads()) {
|
||||
for (const auto& [action, func] : ACTIONS) {
|
||||
if (input_->checkAction(action, Input::DO_NOT_ALLOW_REPEAT, Input::DO_NOT_CHECK_KEYBOARD, gamepad)) {
|
||||
func();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user