clang-tidy
This commit is contained in:
@@ -78,8 +78,8 @@ class IntOption : public MenuOption {
|
||||
Behavior getBehavior() const override { return Behavior::ADJUST; }
|
||||
std::string getValueAsString() const override { return std::to_string(*linked_variable_); }
|
||||
void adjustValue(bool adjust_up) override {
|
||||
int newValue = *linked_variable_ + (adjust_up ? step_value_ : -step_value_);
|
||||
*linked_variable_ = std::clamp(newValue, min_value_, max_value_);
|
||||
int new_value = *linked_variable_ + (adjust_up ? step_value_ : -step_value_);
|
||||
*linked_variable_ = std::clamp(new_value, min_value_, max_value_);
|
||||
}
|
||||
int getMaxValueWidth(Text *text_renderer) const override {
|
||||
int max_width = 0;
|
||||
|
||||
@@ -37,7 +37,7 @@ void MenuRenderer::render(const ServiceMenu *menu_state) {
|
||||
// Dibuja la línea separadora
|
||||
y = rect_.y + upper_height_;
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), BORDER_COLOR.r, BORDER_COLOR.g, BORDER_COLOR.b, 255);
|
||||
SDL_RenderLine(Screen::get()->getRenderer(), rect_.x + ServiceMenu::OPTIONS_HORIZONTAL_PADDING_, y, rect_.x + rect_.w - ServiceMenu::OPTIONS_HORIZONTAL_PADDING_, y);
|
||||
SDL_RenderLine(Screen::get()->getRenderer(), rect_.x + ServiceMenu::OPTIONS_HORIZONTAL_PADDING, y, rect_.x + rect_.w - ServiceMenu::OPTIONS_HORIZONTAL_PADDING, y);
|
||||
|
||||
// Dibuja las opciones
|
||||
y = options_y_;
|
||||
@@ -47,8 +47,8 @@ void MenuRenderer::render(const ServiceMenu *menu_state) {
|
||||
const Color ¤t_color = IS_SELECTED ? param.service_menu.selected_color : param.service_menu.text_color;
|
||||
|
||||
if (menu_state->getCurrentGroupAlignment() == ServiceMenu::GroupAlignment::LEFT) {
|
||||
element_text_->writeColored(rect_.x + ServiceMenu::OPTIONS_HORIZONTAL_PADDING_, y, option_pairs.at(i).first, current_color, -2);
|
||||
const int X = rect_.x + rect_.w - ServiceMenu::OPTIONS_HORIZONTAL_PADDING_ - element_text_->lenght(option_pairs.at(i).second, -2);
|
||||
element_text_->writeColored(rect_.x + ServiceMenu::OPTIONS_HORIZONTAL_PADDING, y, option_pairs.at(i).first, current_color, -2);
|
||||
const int X = rect_.x + rect_.w - ServiceMenu::OPTIONS_HORIZONTAL_PADDING - element_text_->lenght(option_pairs.at(i).second, -2);
|
||||
element_text_->writeColored(X, y, option_pairs.at(i).second, current_color, -2);
|
||||
} else {
|
||||
element_text_->writeDX(TEXT_CENTER | TEXT_COLOR, rect_.x + rect_.w / 2, y, option_pairs.at(i).first, -2, current_color);
|
||||
@@ -96,7 +96,7 @@ void MenuRenderer::setAnchors(const ServiceMenu *menu_state) {
|
||||
lower_padding_ = (options_padding_ * 3);
|
||||
lower_height_ = ((max_entries > 0 ? max_entries - 1 : 0) * (options_height_ + options_padding_)) + options_height_ + (lower_padding_ * 2);
|
||||
|
||||
width_ = ServiceMenu::MIN_WIDTH_;
|
||||
width_ = ServiceMenu::MIN_WIDTH;
|
||||
height_ = upper_height_ + lower_height_;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ void MenuRenderer::updateResizeAnimation() {
|
||||
|
||||
void MenuRenderer::precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>> &all_options, const ServiceMenu *menu_state) {
|
||||
for (int &w : group_menu_widths_)
|
||||
w = ServiceMenu::MIN_WIDTH_;
|
||||
w = ServiceMenu::MIN_WIDTH;
|
||||
for (int group = 0; group < 5; ++group) {
|
||||
auto sg = static_cast<ServiceMenu::SettingsGroup>(group);
|
||||
int max_option_width = 0;
|
||||
@@ -164,11 +164,11 @@ void MenuRenderer::precalculateMenuWidths(const std::vector<std::unique_ptr<Menu
|
||||
max_value_width = std::max(max_value_width, option->getMaxValueWidth(element_text_.get()));
|
||||
}
|
||||
}
|
||||
size_t total_width = max_option_width + (ServiceMenu::OPTIONS_HORIZONTAL_PADDING_ * 2);
|
||||
size_t total_width = max_option_width + (ServiceMenu::OPTIONS_HORIZONTAL_PADDING * 2);
|
||||
if (menu_state->getCurrentGroupAlignment() == ServiceMenu::GroupAlignment::LEFT) {
|
||||
total_width += ServiceMenu::MIN_GAP_OPTION_VALUE_ + max_value_width;
|
||||
total_width += ServiceMenu::MIN_GAP_OPTION_VALUE + max_value_width;
|
||||
}
|
||||
group_menu_widths_[group] = std::max((int)ServiceMenu::MIN_WIDTH_, (int)total_width);
|
||||
group_menu_widths_[group] = std::max((int)ServiceMenu::MIN_WIDTH, (int)total_width);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
#include "utils.h" // Para Zone
|
||||
|
||||
// Singleton
|
||||
ServiceMenu *ServiceMenu::instance_ = nullptr;
|
||||
void ServiceMenu::init() { ServiceMenu::instance_ = new ServiceMenu(); }
|
||||
void ServiceMenu::destroy() { delete ServiceMenu::instance_; }
|
||||
ServiceMenu *ServiceMenu::get() { return ServiceMenu::instance_; }
|
||||
ServiceMenu *ServiceMenu::instance = nullptr;
|
||||
void ServiceMenu::init() { ServiceMenu::instance = new ServiceMenu(); }
|
||||
void ServiceMenu::destroy() { delete ServiceMenu::instance; }
|
||||
ServiceMenu *ServiceMenu::get() { return ServiceMenu::instance; }
|
||||
|
||||
// Constructor
|
||||
ServiceMenu::ServiceMenu()
|
||||
@@ -150,7 +150,7 @@ void ServiceMenu::updateOptionPairs() {
|
||||
|
||||
void ServiceMenu::updateMenu() {
|
||||
title_ = settingsGroupToString(current_settings_group_);
|
||||
AdjustListValues();
|
||||
adjustListValues();
|
||||
|
||||
// Actualiza las opciones visibles
|
||||
updateDisplayOptions();
|
||||
@@ -254,7 +254,7 @@ void ServiceMenu::initializeOptions() {
|
||||
}
|
||||
|
||||
// Sincroniza los valores de las opciones tipo lista
|
||||
void ServiceMenu::AdjustListValues() {
|
||||
void ServiceMenu::adjustListValues() {
|
||||
for (auto &option : options_) {
|
||||
if (auto list_option = dynamic_cast<ListOption *>(option.get())) {
|
||||
list_option->sync();
|
||||
|
||||
@@ -28,9 +28,9 @@ class ServiceMenu {
|
||||
};
|
||||
|
||||
// --- Constantes públicas que el Renderer podría necesitar ---
|
||||
static constexpr size_t OPTIONS_HORIZONTAL_PADDING_ = 20;
|
||||
static constexpr size_t MIN_WIDTH_ = 240;
|
||||
static constexpr size_t MIN_GAP_OPTION_VALUE_ = 30;
|
||||
static constexpr size_t OPTIONS_HORIZONTAL_PADDING = 20;
|
||||
static constexpr size_t MIN_WIDTH = 240;
|
||||
static constexpr size_t MIN_GAP_OPTION_VALUE = 30;
|
||||
|
||||
static void init();
|
||||
static void destroy();
|
||||
@@ -89,7 +89,7 @@ class ServiceMenu {
|
||||
void applyAudioSettings();
|
||||
void applySettingsSettings();
|
||||
MenuOption *getOptionByCaption(const std::string &caption) const;
|
||||
void AdjustListValues();
|
||||
void adjustListValues();
|
||||
void playMoveSound();
|
||||
void playAdjustSound();
|
||||
void playSelectSound();
|
||||
@@ -102,5 +102,5 @@ class ServiceMenu {
|
||||
~ServiceMenu() = default;
|
||||
ServiceMenu(const ServiceMenu &) = delete;
|
||||
ServiceMenu &operator=(const ServiceMenu &) = delete;
|
||||
static ServiceMenu *instance_;
|
||||
static ServiceMenu *instance;
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ void UIMessage::show() {
|
||||
if (visible_ && target_y_ == 0.0f)
|
||||
return; // Ya está visible y quieto
|
||||
|
||||
start_y_ = DESP_; // Empieza 8 píxeles arriba de la posición base
|
||||
start_y_ = DESP; // Empieza 8 píxeles arriba de la posición base
|
||||
target_y_ = 0.0f; // La posición final es la base
|
||||
y_offset_ = start_y_;
|
||||
anim_step_ = 0;
|
||||
@@ -27,7 +27,7 @@ void UIMessage::hide() {
|
||||
return;
|
||||
|
||||
start_y_ = y_offset_; // Comienza desde la posición actual
|
||||
target_y_ = DESP_; // Termina 8 píxeles arriba de la base
|
||||
target_y_ = DESP; // Termina 8 píxeles arriba de la base
|
||||
anim_step_ = 0;
|
||||
animating_ = true;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class UIMessage {
|
||||
float target_y_ = 0.0f; // Posición Y objetivo de la animación
|
||||
int anim_step_ = 0; // Paso actual de la animación
|
||||
static constexpr int ANIMATION_STEPS = 8; // Número total de pasos de la animación
|
||||
static constexpr float DESP_ = -8.0f; // Distancia a desplazarse
|
||||
static constexpr float DESP = -8.0f; // Distancia a desplazarse
|
||||
|
||||
// Actualiza la interpolación de la animación (ease out/in cubic)
|
||||
void updateAnimation();
|
||||
|
||||
Reference in New Issue
Block a user