clang-tidy (amb el fuck de que no feien bona parella el clang de macos i el tidy de llvm)
This commit is contained in:
@@ -135,8 +135,8 @@ class ListOption : public MenuOption {
|
||||
return;
|
||||
}
|
||||
size_t size = value_list_.size();
|
||||
list_index_ = (adjust_up) ? (list_index_ + 1) % size
|
||||
: (list_index_ + size - 1) % size;
|
||||
list_index_ = adjust_up ? (list_index_ + 1) % size
|
||||
: (list_index_ + size - 1) % size;
|
||||
setter_(value_list_[list_index_]);
|
||||
}
|
||||
auto getMaxValueWidth(Text* text_renderer) const -> int override {
|
||||
|
||||
@@ -57,7 +57,7 @@ void MenuRenderer::render(const ServiceMenu* menu_state) {
|
||||
|
||||
// Dibuja la sombra
|
||||
if (param.service_menu.drop_shadow) {
|
||||
SDL_FRect shadow_rect = {rect_.x + 5, rect_.y + 5, rect_.w, rect_.h};
|
||||
SDL_FRect shadow_rect = {.x = rect_.x + 5, .y = rect_.y + 5, .w = rect_.w, .h = rect_.h};
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 64);
|
||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &shadow_rect);
|
||||
}
|
||||
@@ -203,7 +203,7 @@ auto MenuRenderer::calculateNewRect(const ServiceMenu* menu_state) -> SDL_FRect
|
||||
lower_height_ = ((!display_options.empty() ? display_options.size() - 1 : 0) * (options_height_ + options_padding_)) + options_height_ + (lower_padding_ * 2);
|
||||
height_ = std::min(upper_height_ + lower_height_, max_menu_height_);
|
||||
|
||||
SDL_FRect new_rect = {0, 0, (float)width_, (float)height_};
|
||||
SDL_FRect new_rect = {.x = 0, .y = 0, .w = static_cast<float>(width_), .h = static_cast<float>(height_)};
|
||||
|
||||
// La posición x, y se establecerá en `updatePosition`
|
||||
return new_rect;
|
||||
@@ -286,8 +286,8 @@ void MenuRenderer::updateResizeAnimation(float delta_time) {
|
||||
updatePosition();
|
||||
} else {
|
||||
float progress = easeOut(resize_animation_.elapsed / duration);
|
||||
rect_.w = resize_animation_.start_width + (resize_animation_.target_width - resize_animation_.start_width) * progress;
|
||||
rect_.h = resize_animation_.start_height + (resize_animation_.target_height - resize_animation_.start_height) * progress;
|
||||
rect_.w = resize_animation_.start_width + ((resize_animation_.target_width - resize_animation_.start_width) * progress);
|
||||
rect_.h = resize_animation_.start_height + ((resize_animation_.target_height - resize_animation_.start_height) * progress);
|
||||
updatePosition();
|
||||
}
|
||||
options_y_ = rect_.y + upper_height_ + lower_padding_;
|
||||
@@ -296,8 +296,8 @@ void MenuRenderer::updateResizeAnimation(float delta_time) {
|
||||
void MenuRenderer::updatePosition() {
|
||||
switch (position_mode_) {
|
||||
case PositionMode::CENTERED:
|
||||
rect_.x = anchor_x_ - rect_.w / 2.0F;
|
||||
rect_.y = anchor_y_ - rect_.h / 2.0F;
|
||||
rect_.x = anchor_x_ - (rect_.w / 2.0F);
|
||||
rect_.y = anchor_y_ - (rect_.h / 2.0F);
|
||||
break;
|
||||
case PositionMode::FIXED:
|
||||
rect_.x = anchor_x_;
|
||||
@@ -310,7 +310,7 @@ void MenuRenderer::updatePosition() {
|
||||
|
||||
// Resto de métodos (sin cambios significativos)
|
||||
|
||||
void MenuRenderer::precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>>& all_options, const ServiceMenu* menu_state) {
|
||||
void MenuRenderer::precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>>& all_options, const ServiceMenu* menu_state) { // NOLINT(readability-named-parameter)
|
||||
for (int& w : group_menu_widths_) {
|
||||
w = ServiceMenu::MIN_WIDTH;
|
||||
}
|
||||
@@ -341,7 +341,7 @@ void MenuRenderer::precalculateMenuWidths(const std::vector<std::unique_ptr<Menu
|
||||
if (menu_state->getCurrentGroupAlignment() == ServiceMenu::GroupAlignment::LEFT) {
|
||||
total_width += ServiceMenu::MIN_GAP_OPTION_VALUE + max_value_width;
|
||||
}
|
||||
group_menu_widths_[group] = std::min(std::max((int)ServiceMenu::MIN_WIDTH, (int)total_width), static_cast<int>(max_menu_width_));
|
||||
group_menu_widths_[group] = std::min(std::max(static_cast<int>(ServiceMenu::MIN_WIDTH), static_cast<int>(total_width)), static_cast<int>(max_menu_width_));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ class MenuRenderer {
|
||||
void updateShowHideAnimation(float delta_time);
|
||||
void updatePosition();
|
||||
|
||||
void precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>>& all_options, const ServiceMenu* menu_state);
|
||||
void precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>>& all_options, const ServiceMenu* menu_state); // NOLINT(readability-avoid-const-params-in-decls)
|
||||
[[nodiscard]] auto getMenuWidthForGroup(ServiceMenu::SettingsGroup group) const -> int;
|
||||
[[nodiscard]] auto getAnimatedSelectedColor() const -> Color;
|
||||
void updateColorCounter();
|
||||
|
||||
@@ -37,14 +37,14 @@ Notifier::Notifier(const std::string& icon_file, std::shared_ptr<Text> text)
|
||||
|
||||
// Dibuja las notificaciones por pantalla
|
||||
void Notifier::render() {
|
||||
for (int i = (int)notifications_.size() - 1; i >= 0; --i) {
|
||||
for (int i = static_cast<int>(notifications_.size()) - 1; i >= 0; --i) {
|
||||
notifications_[i].sprite->render();
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el estado de las notificaciones
|
||||
void Notifier::update(float delta_time) {
|
||||
for (int i = 0; i < (int)notifications_.size(); ++i) {
|
||||
for (int i = 0; std::cmp_less(i, notifications_.size()); ++i) {
|
||||
if (!shouldProcessNotification(i)) {
|
||||
break;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ void Notifier::transitionToStayState(int index) {
|
||||
|
||||
// Elimina las notificaciones finalizadas
|
||||
void Notifier::clearFinishedNotifications() {
|
||||
for (int i = (int)notifications_.size() - 1; i >= 0; --i) {
|
||||
for (int i = static_cast<int>(notifications_.size()) - 1; i >= 0; --i) {
|
||||
if (notifications_[i].state == State::FINISHED) {
|
||||
notifications_.erase(notifications_.begin() + i);
|
||||
}
|
||||
@@ -167,7 +167,7 @@ void Notifier::show(std::vector<std::string> texts, int icon, const std::string&
|
||||
}
|
||||
|
||||
// Elimina las cadenas vacías
|
||||
texts.erase(std::ranges::remove_if(texts, [](const std::string& s) { return s.empty(); }).begin(), texts.end());
|
||||
texts.erase(std::ranges::remove_if(texts, [](const std::string& s) -> bool { return s.empty(); }).begin(), texts.end());
|
||||
|
||||
// Encuentra la cadena más larga
|
||||
std::string longest;
|
||||
@@ -259,13 +259,13 @@ void Notifier::show(std::vector<std::string> texts, int icon, const std::string&
|
||||
|
||||
// Dibuja el icono de la notificación
|
||||
if (has_icons_ && icon >= 0 && texts.size() >= 2) {
|
||||
auto sp = std::make_unique<Sprite>(icon_texture_, (SDL_FRect){0, 0, ICON_SIZE, ICON_SIZE});
|
||||
sp->setPosition({PADDING_IN_H, PADDING_IN_V, ICON_SIZE, ICON_SIZE});
|
||||
auto sp = std::make_unique<Sprite>(icon_texture_, (SDL_FRect){.x = 0, .y = 0, .w = ICON_SIZE, .h = ICON_SIZE});
|
||||
sp->setPosition({.x = PADDING_IN_H, .y = PADDING_IN_V, .w = ICON_SIZE, .h = ICON_SIZE});
|
||||
sp->setSpriteClip(SDL_FRect{
|
||||
static_cast<float>(ICON_SIZE * (icon % 10)),
|
||||
static_cast<float>(ICON_SIZE * (icon / 10)),
|
||||
ICON_SIZE,
|
||||
ICON_SIZE});
|
||||
.x = static_cast<float>(ICON_SIZE * (icon % 10)),
|
||||
.y = static_cast<float>(ICON_SIZE * (icon / 10)),
|
||||
.w = ICON_SIZE,
|
||||
.h = ICON_SIZE});
|
||||
sp->render();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class Notifier {
|
||||
explicit Notification()
|
||||
: texture(nullptr),
|
||||
sprite(nullptr),
|
||||
rect{0, 0, 0, 0} {}
|
||||
rect{.x = 0, .y = 0, .w = 0, .h = 0} {}
|
||||
};
|
||||
|
||||
// --- Objetos y punteros ---
|
||||
|
||||
@@ -291,13 +291,13 @@ void ServiceMenu::initializeOptions() {
|
||||
Lang::getText("[SERVICE_MENU] CONTROLLER1"),
|
||||
SettingsGroup::CONTROLS,
|
||||
Input::get()->getControllerNames(),
|
||||
[]() {
|
||||
[]() -> std::string {
|
||||
return Options::gamepad_manager.getGamepad(Player::Id::PLAYER1).name;
|
||||
},
|
||||
[](const std::string& val) {
|
||||
[](const std::string& val) -> void {
|
||||
Options::gamepad_manager.assignGamepadToPlayer(Player::Id::PLAYER1, Input::get()->getGamepadByName(val), val);
|
||||
},
|
||||
[this]() {
|
||||
[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) {
|
||||
@@ -309,13 +309,13 @@ void ServiceMenu::initializeOptions() {
|
||||
Lang::getText("[SERVICE_MENU] CONTROLLER2"),
|
||||
SettingsGroup::CONTROLS,
|
||||
Input::get()->getControllerNames(),
|
||||
[]() {
|
||||
[]() -> std::string {
|
||||
return Options::gamepad_manager.getGamepad(Player::Id::PLAYER2).name;
|
||||
},
|
||||
[](const std::string& val) {
|
||||
[](const std::string& val) -> void {
|
||||
Options::gamepad_manager.assignGamepadToPlayer(Player::Id::PLAYER2, Input::get()->getGamepadByName(val), val);
|
||||
},
|
||||
[this]() {
|
||||
[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) {
|
||||
@@ -330,11 +330,11 @@ void ServiceMenu::initializeOptions() {
|
||||
std::vector<std::string>{
|
||||
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) {
|
||||
[](const std::string& val) -> void {
|
||||
// Asignar el teclado al jugador seleccionado
|
||||
Options::keyboard.assignTo(Options::stringToPlayerId(val));
|
||||
}));
|
||||
@@ -343,7 +343,7 @@ void ServiceMenu::initializeOptions() {
|
||||
options_.push_back(std::make_unique<ActionOption>(
|
||||
Lang::getText("[SERVICE_MENU] SWAP_CONTROLLERS"),
|
||||
SettingsGroup::CONTROLS,
|
||||
[this]() {
|
||||
[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
|
||||
@@ -421,10 +421,10 @@ void ServiceMenu::initializeOptions() {
|
||||
Lang::getText("[SERVICE_MENU] LANG_ES"),
|
||||
Lang::getText("[SERVICE_MENU] LANG_BA"),
|
||||
Lang::getText("[SERVICE_MENU] LANG_EN")},
|
||||
[]() {
|
||||
[]() -> std::string {
|
||||
return Lang::getNameFromCode(Options::pending_changes.new_language);
|
||||
},
|
||||
[](const std::string& val) {
|
||||
[](const std::string& val) -> void {
|
||||
Options::pending_changes.new_language = Lang::getCodeFromName(val);
|
||||
Options::checkPendingChanges();
|
||||
}));
|
||||
@@ -436,10 +436,10 @@ void ServiceMenu::initializeOptions() {
|
||||
Lang::getText("[SERVICE_MENU] EASY"),
|
||||
Lang::getText("[SERVICE_MENU] NORMAL"),
|
||||
Lang::getText("[SERVICE_MENU] HARD")},
|
||||
[]() {
|
||||
[]() -> std::string {
|
||||
return Difficulty::getNameFromCode(Options::pending_changes.new_difficulty);
|
||||
},
|
||||
[](const std::string& val) {
|
||||
[](const std::string& val) -> void {
|
||||
Options::pending_changes.new_difficulty = Difficulty::getCodeFromName(val);
|
||||
Options::checkPendingChanges();
|
||||
}));
|
||||
@@ -453,7 +453,7 @@ void ServiceMenu::initializeOptions() {
|
||||
options_.push_back(std::make_unique<ActionOption>(
|
||||
Lang::getText("[SERVICE_MENU] RESET"),
|
||||
SettingsGroup::SYSTEM,
|
||||
[this]() {
|
||||
[this]() -> void {
|
||||
Section::name = Section::Name::RESET;
|
||||
toggle();
|
||||
}));
|
||||
@@ -461,7 +461,7 @@ void ServiceMenu::initializeOptions() {
|
||||
options_.push_back(std::make_unique<ActionOption>(
|
||||
Lang::getText("[SERVICE_MENU] QUIT"),
|
||||
SettingsGroup::SYSTEM,
|
||||
[]() {
|
||||
[]() -> void {
|
||||
Section::name = Section::Name::QUIT;
|
||||
Section::options = Section::Options::NONE;
|
||||
}));
|
||||
@@ -469,7 +469,7 @@ void ServiceMenu::initializeOptions() {
|
||||
options_.push_back(std::make_unique<ActionOption>(
|
||||
Lang::getText("[SERVICE_MENU] SHUTDOWN"),
|
||||
SettingsGroup::SYSTEM,
|
||||
[]() {
|
||||
[]() -> void {
|
||||
Section::name = Section::Name::QUIT;
|
||||
Section::options = Section::Options::SHUTDOWN;
|
||||
},
|
||||
@@ -581,12 +581,12 @@ auto ServiceMenu::checkInput() -> bool {
|
||||
using Action = Input::Action;
|
||||
|
||||
const std::vector<std::pair<Action, std::function<void()>>> ACTIONS = {
|
||||
{Action::UP, [this]() { setSelectorUp(); }},
|
||||
{Action::DOWN, [this]() { setSelectorDown(); }},
|
||||
{Action::RIGHT, [this]() { adjustOption(true); }},
|
||||
{Action::LEFT, [this]() { adjustOption(false); }},
|
||||
{Action::SM_SELECT, [this]() { selectOption(); }},
|
||||
{Action::SM_BACK, [this]() { moveBack(); }},
|
||||
{Action::UP, [this]() -> void { setSelectorUp(); }},
|
||||
{Action::DOWN, [this]() -> void { setSelectorDown(); }},
|
||||
{Action::RIGHT, [this]() -> void { adjustOption(true); }},
|
||||
{Action::LEFT, [this]() -> void { adjustOption(false); }},
|
||||
{Action::SM_SELECT, [this]() -> void { selectOption(); }},
|
||||
{Action::SM_BACK, [this]() -> void { moveBack(); }},
|
||||
};
|
||||
|
||||
// Teclado
|
||||
|
||||
@@ -61,7 +61,7 @@ void UIMessage::updateAnimation(float delta_time) {
|
||||
t = pow(t, 3);
|
||||
}
|
||||
|
||||
y_offset_ = start_y_ + (target_y_ - start_y_) * t;
|
||||
y_offset_ = start_y_ + ((target_y_ - start_y_) * t);
|
||||
|
||||
if (animation_timer_ >= ANIMATION_DURATION_S) {
|
||||
y_offset_ = target_y_;
|
||||
|
||||
@@ -192,8 +192,8 @@ void WindowMessage::updateStyles() {
|
||||
void WindowMessage::updatePosition() {
|
||||
switch (position_mode_) {
|
||||
case PositionMode::CENTERED:
|
||||
rect_.x = anchor_.x - rect_.w / 2.0F;
|
||||
rect_.y = anchor_.y - rect_.h / 2.0F;
|
||||
rect_.x = anchor_.x - (rect_.w / 2.0F);
|
||||
rect_.y = anchor_.y - (rect_.h / 2.0F);
|
||||
break;
|
||||
case PositionMode::FIXED:
|
||||
rect_.x = anchor_.x;
|
||||
@@ -355,9 +355,9 @@ void WindowMessage::updateResizeAnimation(float delta_time) {
|
||||
float progress = easeOut(resize_animation_.getProgress(config_.animation_duration));
|
||||
|
||||
rect_.w = resize_animation_.start_width +
|
||||
(resize_animation_.target_width - resize_animation_.start_width) * progress;
|
||||
((resize_animation_.target_width - resize_animation_.start_width) * progress);
|
||||
rect_.h = resize_animation_.start_height +
|
||||
(resize_animation_.target_height - resize_animation_.start_height) * progress;
|
||||
((resize_animation_.target_height - resize_animation_.start_height) * progress);
|
||||
|
||||
updatePosition(); // Mantener la posición centrada durante la animación
|
||||
}
|
||||
|
||||
@@ -140,9 +140,9 @@ class WindowMessage {
|
||||
std::vector<std::string> texts_;
|
||||
|
||||
// Posición y tamaño
|
||||
SDL_FRect rect_{0, 0, 300, 200};
|
||||
SDL_FRect rect_{.x = 0, .y = 0, .w = 300, .h = 200};
|
||||
PositionMode position_mode_ = PositionMode::CENTERED;
|
||||
SDL_FPoint anchor_{0.0F, 0.0F};
|
||||
SDL_FPoint anchor_{.x = 0.0F, .y = 0.0F};
|
||||
|
||||
// Animación de redimensionado
|
||||
struct ResizeAnimation {
|
||||
|
||||
Reference in New Issue
Block a user