neteja clang-tidy: enums uint8_t, includes, naming i altres
This commit is contained in:
+115
-110
@@ -8,7 +8,6 @@
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/define_buttons.hpp" // Para DefineButtons
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/input/input_types.hpp" // Para InputAction
|
||||
#include "core/locale/lang.hpp" // Para getText, getCodeFromName, getNameFromCode
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
@@ -252,9 +251,9 @@ void ServiceMenu::applySettingsSettings() {
|
||||
}
|
||||
|
||||
auto ServiceMenu::getOptionByCaption(const std::string& caption) const -> MenuOption* {
|
||||
const auto it = std::ranges::find_if(options_,
|
||||
const auto IT = std::ranges::find_if(options_,
|
||||
[&caption](const auto& option) { return option->getCaption() == caption; });
|
||||
return it != options_.end() ? it->get() : nullptr;
|
||||
return IT != options_.end() ? IT->get() : nullptr;
|
||||
}
|
||||
|
||||
// --- Getters y otros ---
|
||||
@@ -279,8 +278,16 @@ auto ServiceMenu::countOptionsInGroup(SettingsGroup group) const -> size_t {
|
||||
// Inicializa todas las opciones del menú
|
||||
void ServiceMenu::initializeOptions() {
|
||||
options_.clear();
|
||||
addControlsOptions();
|
||||
addVideoOptions();
|
||||
addAudioOptions();
|
||||
addSettingsOptions();
|
||||
addSystemOptions();
|
||||
addMainMenuOptions();
|
||||
setHiddenOptions();
|
||||
}
|
||||
|
||||
// CONTROLS - Usando ActionListOption para mandos
|
||||
void ServiceMenu::addControlsOptions() {
|
||||
options_.push_back(std::make_unique<ActionListOption>(
|
||||
Lang::getText("[SERVICE_MENU] CONTROLLER1"),
|
||||
SettingsGroup::CONTROLS,
|
||||
@@ -292,7 +299,6 @@ void ServiceMenu::initializeOptions() {
|
||||
Options::gamepad_manager.assignGamepadToPlayer(Player::Id::PLAYER1, Input::get()->getGamepadByName(val), val);
|
||||
},
|
||||
[this]() -> void {
|
||||
// Acción: configurar botones del mando del jugador 1
|
||||
auto* gamepad = &Options::gamepad_manager.getGamepad(Player::Id::PLAYER1);
|
||||
if (gamepad->instance != nullptr) {
|
||||
define_buttons_->enable(gamepad);
|
||||
@@ -310,14 +316,12 @@ void ServiceMenu::initializeOptions() {
|
||||
Options::gamepad_manager.assignGamepadToPlayer(Player::Id::PLAYER2, Input::get()->getGamepadByName(val), val);
|
||||
},
|
||||
[this]() -> void {
|
||||
// Acción: configurar botones del mando del jugador 2
|
||||
auto* gamepad = &Options::gamepad_manager.getGamepad(Player::Id::PLAYER2);
|
||||
if (gamepad->instance != nullptr) {
|
||||
define_buttons_->enable(gamepad);
|
||||
}
|
||||
}));
|
||||
|
||||
// CONTROLS - Opción para teclado (solo lista, sin acción)
|
||||
options_.push_back(std::make_unique<ListOption>(
|
||||
Lang::getText("[SERVICE_MENU] KEYBOARD"),
|
||||
SettingsGroup::CONTROLS,
|
||||
@@ -325,26 +329,22 @@ void ServiceMenu::initializeOptions() {
|
||||
Lang::getText("[SERVICE_MENU] PLAYER1"),
|
||||
Lang::getText("[SERVICE_MENU] PLAYER2")},
|
||||
[]() -> std::string {
|
||||
// Devolver el jugador actual asignado al teclado
|
||||
return Options::playerIdToString(Options::getPlayerWhoUsesKeyboard());
|
||||
},
|
||||
[](const std::string& val) -> void {
|
||||
// Asignar el teclado al jugador seleccionado
|
||||
Options::keyboard.assignTo(Options::stringToPlayerId(val));
|
||||
}));
|
||||
|
||||
// CONTROLS - Acción para intercambiar mandos
|
||||
options_.push_back(std::make_unique<ActionOption>(
|
||||
Lang::getText("[SERVICE_MENU] SWAP_CONTROLLERS"),
|
||||
SettingsGroup::CONTROLS,
|
||||
[this]() -> void {
|
||||
Options::gamepad_manager.swapPlayers();
|
||||
adjustListValues(); // Sincroniza el valor de las opciones de lista (como MANDO1) con los datos reales
|
||||
updateOptionPairs(); // Actualiza los pares de texto <opción, valor> que se van a dibujar
|
||||
adjustListValues();
|
||||
updateOptionPairs();
|
||||
|
||||
// Feedback visual: anima el intercambio de los valores entre
|
||||
// las filas de MANDO 1 y MANDO 2, imprescindible cuando los dos
|
||||
// mandos tienen el mismo nombre (el texto no cambia al swap).
|
||||
// Feedback visual: anima el intercambio de las filas de MANDO 1 y MANDO 2,
|
||||
// imprescindible cuando ambos mandos tienen el mismo nombre (el texto no cambia).
|
||||
const std::string CAPTION1 = Lang::getText("[SERVICE_MENU] CONTROLLER1");
|
||||
const std::string CAPTION2 = Lang::getText("[SERVICE_MENU] CONTROLLER2");
|
||||
size_t idx1 = display_options_.size();
|
||||
@@ -358,8 +358,9 @@ void ServiceMenu::initializeOptions() {
|
||||
renderer_->startSwapAnimation(idx1, idx2);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
// VIDEO
|
||||
void ServiceMenu::addVideoOptions() {
|
||||
options_.push_back(std::make_unique<BoolOption>(
|
||||
Lang::getText("[SERVICE_MENU] FULLSCREEN"),
|
||||
SettingsGroup::VIDEO,
|
||||
@@ -373,76 +374,8 @@ void ServiceMenu::initializeOptions() {
|
||||
Options::window.max_zoom,
|
||||
1));
|
||||
|
||||
// Shader: Desactivat / PostFX / CrtPi
|
||||
{
|
||||
std::string disabled_text = Lang::getText("[SERVICE_MENU] SHADER_DISABLED");
|
||||
std::vector<std::string> shader_values = {disabled_text, "PostFX", "CrtPi"};
|
||||
auto shader_getter = [disabled_text]() -> std::string {
|
||||
// NOLINTNEXTLINE(performance-no-automatic-move) -- captura por valor en lambda const, no se puede mover
|
||||
if (!Options::video.shader.enabled) { return disabled_text; }
|
||||
return (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) ? "CrtPi" : "PostFX";
|
||||
};
|
||||
auto shader_setter = [disabled_text](const std::string& val) {
|
||||
if (val == disabled_text) {
|
||||
Options::video.shader.enabled = false;
|
||||
} else {
|
||||
Options::video.shader.enabled = true;
|
||||
const auto TYPE = (val == "CrtPi") ? Rendering::ShaderType::CRTPI : Rendering::ShaderType::POSTFX;
|
||||
Options::video.shader.current_shader = TYPE;
|
||||
auto* screen = Screen::get();
|
||||
if (screen != nullptr) {
|
||||
screen->applySettings();
|
||||
}
|
||||
}
|
||||
Screen::initShaders();
|
||||
};
|
||||
options_.push_back(std::make_unique<ListOption>(
|
||||
Lang::getText("[SERVICE_MENU] SHADER"),
|
||||
SettingsGroup::VIDEO,
|
||||
shader_values,
|
||||
shader_getter,
|
||||
shader_setter));
|
||||
}
|
||||
|
||||
// Preset: muestra nombre, cicla circularmente entre presets del shader activo
|
||||
{
|
||||
auto preset_getter = []() -> std::string {
|
||||
if (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) {
|
||||
if (Options::crtpi_presets.empty()) { return ""; }
|
||||
return Options::crtpi_presets.at(static_cast<size_t>(Options::video.shader.current_crtpi_preset)).name;
|
||||
}
|
||||
if (Options::postfx_presets.empty()) { return ""; }
|
||||
return Options::postfx_presets.at(static_cast<size_t>(Options::video.shader.current_postfx_preset)).name;
|
||||
};
|
||||
auto preset_adjuster = [](bool up) {
|
||||
if (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) {
|
||||
if (Options::crtpi_presets.empty()) { return; }
|
||||
const int SIZE = static_cast<int>(Options::crtpi_presets.size());
|
||||
Options::video.shader.current_crtpi_preset = up
|
||||
? (Options::video.shader.current_crtpi_preset + 1) % SIZE
|
||||
: (Options::video.shader.current_crtpi_preset + SIZE - 1) % SIZE;
|
||||
} else {
|
||||
if (Options::postfx_presets.empty()) { return; }
|
||||
const int SIZE = static_cast<int>(Options::postfx_presets.size());
|
||||
Options::video.shader.current_postfx_preset = up
|
||||
? (Options::video.shader.current_postfx_preset + 1) % SIZE
|
||||
: (Options::video.shader.current_postfx_preset + SIZE - 1) % SIZE;
|
||||
}
|
||||
Screen::initShaders();
|
||||
};
|
||||
auto preset_max_width = [](const Text* text) -> int {
|
||||
const auto presets_length = [text](int max_w, const auto& p) { return std::max(max_w, text->length(p.name, -2)); };
|
||||
int max_w = std::accumulate(Options::postfx_presets.begin(), Options::postfx_presets.end(), 0, presets_length);
|
||||
return std::accumulate(Options::crtpi_presets.begin(), Options::crtpi_presets.end(), max_w, presets_length);
|
||||
};
|
||||
|
||||
options_.push_back(std::make_unique<CallbackOption>(
|
||||
Lang::getText("[SERVICE_MENU] SHADER_PRESET"),
|
||||
SettingsGroup::VIDEO,
|
||||
preset_getter,
|
||||
preset_adjuster,
|
||||
preset_max_width));
|
||||
}
|
||||
addVideoShaderOption();
|
||||
addVideoPresetOption();
|
||||
|
||||
options_.push_back(std::make_unique<BoolOption>(
|
||||
Lang::getText("[SERVICE_MENU] SUPERSAMPLING"),
|
||||
@@ -459,25 +392,97 @@ void ServiceMenu::initializeOptions() {
|
||||
SettingsGroup::VIDEO,
|
||||
&Options::video.integer_scale));
|
||||
|
||||
// FILTER: Nearest / Linear (solo visible en el fallback SDL, sin GPU acelerada)
|
||||
{
|
||||
std::vector<std::string> filter_values = {"Nearest", "Linear"};
|
||||
auto filter_getter = []() -> std::string {
|
||||
return (Options::video.scale_mode == SDL_SCALEMODE_LINEAR) ? "Linear" : "Nearest";
|
||||
};
|
||||
auto filter_setter = [](const std::string& val) {
|
||||
Options::video.scale_mode = (val == "Linear") ? SDL_SCALEMODE_LINEAR : SDL_SCALEMODE_NEAREST;
|
||||
if (Screen::get() != nullptr) { Screen::get()->applyFilter(); }
|
||||
};
|
||||
options_.push_back(std::make_unique<ListOption>(
|
||||
Lang::getText("[SERVICE_MENU] FILTER"),
|
||||
SettingsGroup::VIDEO,
|
||||
filter_values,
|
||||
filter_getter,
|
||||
filter_setter));
|
||||
}
|
||||
addVideoFilterOption();
|
||||
}
|
||||
|
||||
// AUDIO
|
||||
void ServiceMenu::addVideoShaderOption() {
|
||||
std::string disabled_text = Lang::getText("[SERVICE_MENU] SHADER_DISABLED");
|
||||
std::vector<std::string> shader_values = {disabled_text, "PostFX", "CrtPi"};
|
||||
auto shader_getter = [disabled_text]() -> std::string {
|
||||
// NOLINTNEXTLINE(performance-no-automatic-move) -- captura por valor en lambda const, no se puede mover
|
||||
if (!Options::video.shader.enabled) { return disabled_text; }
|
||||
return (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) ? "CrtPi" : "PostFX";
|
||||
};
|
||||
auto shader_setter = [disabled_text](const std::string& val) {
|
||||
if (val == disabled_text) {
|
||||
Options::video.shader.enabled = false;
|
||||
} else {
|
||||
Options::video.shader.enabled = true;
|
||||
const auto TYPE = (val == "CrtPi") ? Rendering::ShaderType::CRTPI : Rendering::ShaderType::POSTFX;
|
||||
Options::video.shader.current_shader = TYPE;
|
||||
auto* screen = Screen::get();
|
||||
if (screen != nullptr) {
|
||||
screen->applySettings();
|
||||
}
|
||||
}
|
||||
Screen::initShaders();
|
||||
};
|
||||
options_.push_back(std::make_unique<ListOption>(
|
||||
Lang::getText("[SERVICE_MENU] SHADER"),
|
||||
SettingsGroup::VIDEO,
|
||||
shader_values,
|
||||
shader_getter,
|
||||
shader_setter));
|
||||
}
|
||||
|
||||
void ServiceMenu::addVideoPresetOption() {
|
||||
auto preset_getter = []() -> std::string {
|
||||
if (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) {
|
||||
if (Options::crtpi_presets.empty()) { return ""; }
|
||||
return Options::crtpi_presets.at(static_cast<size_t>(Options::video.shader.current_crtpi_preset)).name;
|
||||
}
|
||||
if (Options::postfx_presets.empty()) { return ""; }
|
||||
return Options::postfx_presets.at(static_cast<size_t>(Options::video.shader.current_postfx_preset)).name;
|
||||
};
|
||||
auto preset_adjuster = [](bool up) {
|
||||
if (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) {
|
||||
if (Options::crtpi_presets.empty()) { return; }
|
||||
const int SIZE = static_cast<int>(Options::crtpi_presets.size());
|
||||
Options::video.shader.current_crtpi_preset = up
|
||||
? (Options::video.shader.current_crtpi_preset + 1) % SIZE
|
||||
: (Options::video.shader.current_crtpi_preset + SIZE - 1) % SIZE;
|
||||
} else {
|
||||
if (Options::postfx_presets.empty()) { return; }
|
||||
const int SIZE = static_cast<int>(Options::postfx_presets.size());
|
||||
Options::video.shader.current_postfx_preset = up
|
||||
? (Options::video.shader.current_postfx_preset + 1) % SIZE
|
||||
: (Options::video.shader.current_postfx_preset + SIZE - 1) % SIZE;
|
||||
}
|
||||
Screen::initShaders();
|
||||
};
|
||||
auto preset_max_width = [](const Text* text) -> int {
|
||||
const auto PRESETS_LENGTH = [text](int max_w, const auto& p) { return std::max(max_w, text->length(p.name, -2)); };
|
||||
int max_w = std::accumulate(Options::postfx_presets.begin(), Options::postfx_presets.end(), 0, PRESETS_LENGTH);
|
||||
return std::accumulate(Options::crtpi_presets.begin(), Options::crtpi_presets.end(), max_w, PRESETS_LENGTH);
|
||||
};
|
||||
|
||||
options_.push_back(std::make_unique<CallbackOption>(
|
||||
Lang::getText("[SERVICE_MENU] SHADER_PRESET"),
|
||||
SettingsGroup::VIDEO,
|
||||
preset_getter,
|
||||
preset_adjuster,
|
||||
preset_max_width));
|
||||
}
|
||||
|
||||
void ServiceMenu::addVideoFilterOption() {
|
||||
// FILTER: Nearest / Linear (solo visible en el fallback SDL, sin GPU acelerada)
|
||||
std::vector<std::string> filter_values = {"Nearest", "Linear"};
|
||||
auto filter_getter = []() -> std::string {
|
||||
return (Options::video.scale_mode == SDL_SCALEMODE_LINEAR) ? "Linear" : "Nearest";
|
||||
};
|
||||
auto filter_setter = [](const std::string& val) {
|
||||
Options::video.scale_mode = (val == "Linear") ? SDL_SCALEMODE_LINEAR : SDL_SCALEMODE_NEAREST;
|
||||
if (Screen::get() != nullptr) { Screen::get()->applyFilter(); }
|
||||
};
|
||||
options_.push_back(std::make_unique<ListOption>(
|
||||
Lang::getText("[SERVICE_MENU] FILTER"),
|
||||
SettingsGroup::VIDEO,
|
||||
filter_values,
|
||||
filter_getter,
|
||||
filter_setter));
|
||||
}
|
||||
|
||||
void ServiceMenu::addAudioOptions() {
|
||||
options_.push_back(std::make_unique<BoolOption>(
|
||||
Lang::getText("[SERVICE_MENU] AUDIO"),
|
||||
SettingsGroup::AUDIO,
|
||||
@@ -500,8 +505,9 @@ void ServiceMenu::initializeOptions() {
|
||||
SettingsGroup::AUDIO,
|
||||
&Options::audio.sound.volume,
|
||||
5));
|
||||
}
|
||||
|
||||
// SETTINGS
|
||||
void ServiceMenu::addSettingsOptions() {
|
||||
options_.push_back(std::make_unique<BoolOption>(
|
||||
Lang::getText("[SERVICE_MENU] AUTOFIRE"),
|
||||
SettingsGroup::SETTINGS,
|
||||
@@ -541,8 +547,9 @@ void ServiceMenu::initializeOptions() {
|
||||
Lang::getText("[SERVICE_MENU] ENABLE_SHUTDOWN"),
|
||||
SettingsGroup::SETTINGS,
|
||||
&Options::settings.shutdown_enabled));
|
||||
}
|
||||
|
||||
// SYSTEM
|
||||
void ServiceMenu::addSystemOptions() {
|
||||
options_.push_back(std::make_unique<ActionOption>(
|
||||
Lang::getText("[SERVICE_MENU] RESET"),
|
||||
SettingsGroup::SYSTEM,
|
||||
@@ -567,8 +574,9 @@ void ServiceMenu::initializeOptions() {
|
||||
Section::options = Section::Options::SHUTDOWN;
|
||||
},
|
||||
!Options::settings.shutdown_enabled));
|
||||
}
|
||||
|
||||
// MAIN MENU
|
||||
void ServiceMenu::addMainMenuOptions() {
|
||||
options_.push_back(std::make_unique<FolderOption>(
|
||||
Lang::getText("[SERVICE_MENU] CONTROLS"),
|
||||
SettingsGroup::MAIN,
|
||||
@@ -593,9 +601,6 @@ void ServiceMenu::initializeOptions() {
|
||||
Lang::getText("[SERVICE_MENU] SYSTEM"),
|
||||
SettingsGroup::MAIN,
|
||||
SettingsGroup::SYSTEM));
|
||||
|
||||
// Oculta opciones según configuración
|
||||
setHiddenOptions();
|
||||
}
|
||||
|
||||
// Sincroniza los valores de las opciones tipo lista
|
||||
|
||||
Reference in New Issue
Block a user