neteja cppcheck (105 → 0)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#include "game/ui/service_menu.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <numeric>
|
||||
#include <utility>
|
||||
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
@@ -175,7 +178,7 @@ void ServiceMenu::selectOption() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto* folder = dynamic_cast<FolderOption*>(selected_option)) {
|
||||
if (const auto* folder = dynamic_cast<const FolderOption*>(selected_option)) {
|
||||
previous_settings_group_ = current_settings_group_;
|
||||
current_settings_group_ = folder->getTargetGroup();
|
||||
selected_ = 0;
|
||||
@@ -200,9 +203,8 @@ void ServiceMenu::updateDisplayOptions() {
|
||||
|
||||
void ServiceMenu::updateOptionPairs() {
|
||||
option_pairs_.clear();
|
||||
for (const auto& option : display_options_) {
|
||||
option_pairs_.emplace_back(option->getCaption(), option->getValueAsString());
|
||||
}
|
||||
option_pairs_.reserve(display_options_.size());
|
||||
std::ranges::transform(display_options_, std::back_inserter(option_pairs_), [](const auto* option) { return std::pair{option->getCaption(), option->getValueAsString()}; });
|
||||
}
|
||||
|
||||
void ServiceMenu::updateMenu() {
|
||||
@@ -250,12 +252,9 @@ void ServiceMenu::applySettingsSettings() {
|
||||
}
|
||||
|
||||
auto ServiceMenu::getOptionByCaption(const std::string& caption) const -> MenuOption* {
|
||||
for (const auto& option : options_) {
|
||||
if (option->getCaption() == caption) {
|
||||
return option.get();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
const auto it = std::ranges::find_if(options_,
|
||||
[&caption](const auto& option) { return option->getCaption() == caption; });
|
||||
return it != options_.end() ? it->get() : nullptr;
|
||||
}
|
||||
|
||||
// --- Getters y otros ---
|
||||
@@ -273,13 +272,8 @@ auto ServiceMenu::getCurrentGroupAlignment() const -> ServiceMenu::GroupAlignmen
|
||||
}
|
||||
|
||||
auto ServiceMenu::countOptionsInGroup(SettingsGroup group) const -> size_t {
|
||||
size_t count = 0;
|
||||
for (const auto& option : options_) {
|
||||
if (option->getGroup() == group && !option->isHidden()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
return std::ranges::count_if(options_,
|
||||
[group](const auto& option) { return option->getGroup() == group && !option->isHidden(); });
|
||||
}
|
||||
|
||||
// Inicializa todas las opciones del menú
|
||||
@@ -300,7 +294,7 @@ void ServiceMenu::initializeOptions() {
|
||||
[this]() -> void {
|
||||
// Acción: configurar botones del mando del jugador 1
|
||||
auto* gamepad = &Options::gamepad_manager.getGamepad(Player::Id::PLAYER1);
|
||||
if ((gamepad != nullptr) && gamepad->instance) {
|
||||
if (gamepad->instance != nullptr) {
|
||||
define_buttons_->enable(gamepad);
|
||||
}
|
||||
}));
|
||||
@@ -318,7 +312,7 @@ void ServiceMenu::initializeOptions() {
|
||||
[this]() -> void {
|
||||
// Acción: configurar botones del mando del jugador 2
|
||||
auto* gamepad = &Options::gamepad_manager.getGamepad(Player::Id::PLAYER2);
|
||||
if ((gamepad != nullptr) && gamepad->instance) {
|
||||
if (gamepad->instance != nullptr) {
|
||||
define_buttons_->enable(gamepad);
|
||||
}
|
||||
}));
|
||||
@@ -436,11 +430,10 @@ void ServiceMenu::initializeOptions() {
|
||||
}
|
||||
Screen::initShaders();
|
||||
};
|
||||
auto preset_max_width = [](Text* text) -> int {
|
||||
int max_w = 0;
|
||||
for (const auto& p : Options::postfx_presets) { max_w = std::max(max_w, text->length(p.name, -2)); }
|
||||
for (const auto& p : Options::crtpi_presets) { max_w = std::max(max_w, text->length(p.name, -2)); }
|
||||
return max_w;
|
||||
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>(
|
||||
|
||||
Reference in New Issue
Block a user