neteja clang-tidy: enums uint8_t, includes, naming i altres

This commit is contained in:
2026-05-16 23:48:07 +02:00
parent a903343385
commit 0647eceab7
41 changed files with 300 additions and 288 deletions
+4 -4
View File
@@ -42,7 +42,7 @@ auto Color::fromHex(const std::string& hex_str) -> Color {
}
// Implementaciones de métodos estáticos de Color
constexpr auto Color::RGB_TO_HSV(Color color) -> HSV {
constexpr auto Color::rgbToHsv(Color color) -> HSV {
float r = color.r / 255.0F;
float g = color.g / 255.0F;
float b = color.b / 255.0F;
@@ -72,7 +72,7 @@ constexpr auto Color::RGB_TO_HSV(Color color) -> HSV {
return {.h = h, .s = s, .v = v};
}
constexpr auto Color::HSV_TO_RGB(HSV hsv) -> Color {
constexpr auto Color::hsvToRgb(HSV hsv) -> Color {
float c = hsv.v * hsv.s;
float x = c * (1 - std::abs(std::fmod(hsv.h / 60.0F, 2) - 1));
float m = hsv.v - c;
@@ -132,7 +132,7 @@ namespace Colors {
auto generateMirroredCycle(Color base, ColorCycleStyle style) -> Cycle {
Cycle result{};
HSV base_hsv = Color::RGB_TO_HSV(base);
HSV base_hsv = Color::rgbToHsv(base);
for (size_t i = 0; i < CYCLE_SIZE; ++i) {
float t = static_cast<float>(i) / (CYCLE_SIZE - 1); // 0 → 1
@@ -175,7 +175,7 @@ namespace Colors {
.s = fminf(1.0F, fmaxf(0.0F, base_hsv.s + sat_shift)),
.v = fminf(1.0F, fmaxf(0.0F, base_hsv.v + val_shift))};
Color c = Color::HSV_TO_RGB(adjusted);
Color c = Color::hsvToRgb(adjusted);
result[i] = c;
result[(2 * CYCLE_SIZE) - 1 - i] = c; // espejo
}
+13 -12
View File
@@ -5,6 +5,7 @@
#include <algorithm> // Para max, min
#include <array> // Para array
#include <cstdint> // Para std::uint8_t
#include <cstdlib> // Para size_t, abs
#include <string> // Para string
#include <vector> // Para vector
@@ -48,11 +49,11 @@ struct Color {
b(blue),
a(alpha) {}
[[nodiscard]] constexpr auto INVERSE() const -> Color {
[[nodiscard]] constexpr auto inverse() const -> Color {
return Color(MAX_COLOR_VALUE - r, MAX_COLOR_VALUE - g, MAX_COLOR_VALUE - b, a);
}
[[nodiscard]] constexpr auto LIGHTEN(int amount = DEFAULT_LIGHTEN_AMOUNT) const -> Color {
[[nodiscard]] constexpr auto lighten(int amount = DEFAULT_LIGHTEN_AMOUNT) const -> Color {
return Color(
std::min(static_cast<int>(MAX_COLOR_VALUE), r + amount),
std::min(static_cast<int>(MAX_COLOR_VALUE), g + amount),
@@ -60,7 +61,7 @@ struct Color {
a);
}
[[nodiscard]] constexpr auto DARKEN(int amount = DEFAULT_DARKEN_AMOUNT) const -> Color {
[[nodiscard]] constexpr auto darken(int amount = DEFAULT_DARKEN_AMOUNT) const -> Color {
return Color(
std::max(static_cast<int>(MIN_COLOR_VALUE), r - amount),
std::max(static_cast<int>(MIN_COLOR_VALUE), g - amount),
@@ -72,14 +73,14 @@ struct Color {
static auto fromHex(const std::string& hex_str) -> Color;
// Conversiones de formato de color
[[nodiscard]] constexpr static auto RGB_TO_HSV(Color color) -> HSV;
[[nodiscard]] constexpr static auto HSV_TO_RGB(HSV hsv) -> Color;
[[nodiscard]] constexpr static auto rgbToHsv(Color color) -> HSV;
[[nodiscard]] constexpr static auto hsvToRgb(HSV hsv) -> Color;
[[nodiscard]] constexpr auto IS_EQUAL_TO(const Color& other) const -> bool {
[[nodiscard]] constexpr auto isEqualTo(const Color& other) const -> bool {
return r == other.r && g == other.g && b == other.b && a == other.a;
}
[[nodiscard]] constexpr auto APPROACH_TO(const Color& target, int step = DEFAULT_APPROACH_STEP) const -> Color {
[[nodiscard]] constexpr auto approachTo(const Color& target, int step = DEFAULT_APPROACH_STEP) const -> Color {
auto approach_component = [step](Uint8 current, Uint8 target_val) -> Uint8 {
if (std::abs(current - target_val) <= step) {
return target_val;
@@ -96,7 +97,7 @@ struct Color {
}
// Interpolación lineal hacia otro color (t=0.0: this, t=1.0: target)
[[nodiscard]] constexpr auto LERP(const Color& target, float t) const -> Color {
[[nodiscard]] constexpr auto lerp(const Color& target, float t) const -> Color {
// Asegurar que t esté en el rango [0.0, 1.0]
t = std::clamp(t, 0.0F, 1.0F);
@@ -113,12 +114,12 @@ struct Color {
}
// Sobrecarga para aceptar componentes RGBA directamente
[[nodiscard]] constexpr auto LERP(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha, float t) const -> Color {
return LERP(Color(red, green, blue, alpha), t);
[[nodiscard]] constexpr auto lerp(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha, float t) const -> Color {
return lerp(Color(red, green, blue, alpha), t);
}
// Convierte el color a un entero de 32 bits en formato RGBA
[[nodiscard]] constexpr auto TO_UINT32() const -> Uint32 {
[[nodiscard]] constexpr auto toUint32() const -> Uint32 {
return (static_cast<Uint32>(r) << 24) |
(static_cast<Uint32>(g) << 16) |
(static_cast<Uint32>(b) << 8) |
@@ -127,7 +128,7 @@ struct Color {
};
// --- Enum ColorCycleStyle: define estilos de ciclo de color ---
enum class ColorCycleStyle {
enum class ColorCycleStyle : std::uint8_t {
SUBTLE_PULSE, // Variación leve en brillo (por defecto)
HUE_WAVE, // Variación suave en tono (sin verde)
VIBRANT, // Cambios agresivos en tono y brillo
-1
View File
@@ -9,7 +9,6 @@
#include <stdexcept> // Para runtime_error
#include <string> // Para string, basic_string, stoi, stof, hash, allocator, operator==, char_traits, operator+, operator>>, getline
#include <unordered_map> // Para unordered_map, operator==, _Node_iterator_base
#include <utility> // Para pair
#include "game/ui/notifier.hpp" // Para Notifier
#include "utils/color.hpp" // Para Color
+12 -12
View File
@@ -167,51 +167,51 @@ struct ParamPlayer {
};
// Inicialización con valores por defecto
const Shirt default_player0_shirt = Shirt(
const Shirt DEFAULT_PLAYER0_SHIRT = Shirt(
Color::fromHex(Defaults::Player::DefaultShirt::PLAYER0_DARKEST),
Color::fromHex(Defaults::Player::DefaultShirt::PLAYER0_DARK),
Color::fromHex(Defaults::Player::DefaultShirt::PLAYER0_BASE),
Color::fromHex(Defaults::Player::DefaultShirt::PLAYER0_LIGHT));
const Shirt default_player1_shirt = Shirt(
const Shirt DEFAULT_PLAYER1_SHIRT = Shirt(
Color::fromHex(Defaults::Player::DefaultShirt::PLAYER1_DARKEST),
Color::fromHex(Defaults::Player::DefaultShirt::PLAYER1_DARK),
Color::fromHex(Defaults::Player::DefaultShirt::PLAYER1_BASE),
Color::fromHex(Defaults::Player::DefaultShirt::PLAYER1_LIGHT));
std::array<Shirt, 2> default_shirt = {default_player0_shirt, default_player1_shirt};
std::array<Shirt, 2> default_shirt = {DEFAULT_PLAYER0_SHIRT, DEFAULT_PLAYER1_SHIRT};
const Shirt one_coffee_player0_shirt = Shirt(
const Shirt ONE_COFFEE_PLAYER0_SHIRT = Shirt(
Color::fromHex(Defaults::Player::OneCoffeeShirt::PLAYER0_DARKEST),
Color::fromHex(Defaults::Player::OneCoffeeShirt::PLAYER0_DARK),
Color::fromHex(Defaults::Player::OneCoffeeShirt::PLAYER0_BASE),
Color::fromHex(Defaults::Player::OneCoffeeShirt::PLAYER0_LIGHT));
const Shirt one_coffee_player1_shirt = Shirt(
const Shirt ONE_COFFEE_PLAYER1_SHIRT = Shirt(
Color::fromHex(Defaults::Player::OneCoffeeShirt::PLAYER1_DARKEST),
Color::fromHex(Defaults::Player::OneCoffeeShirt::PLAYER1_DARK),
Color::fromHex(Defaults::Player::OneCoffeeShirt::PLAYER1_BASE),
Color::fromHex(Defaults::Player::OneCoffeeShirt::PLAYER1_LIGHT));
std::array<Shirt, 2> one_coffee_shirt = {one_coffee_player0_shirt, one_coffee_player1_shirt};
std::array<Shirt, 2> one_coffee_shirt = {ONE_COFFEE_PLAYER0_SHIRT, ONE_COFFEE_PLAYER1_SHIRT};
const Shirt two_coffee_player0_shirt = Shirt(
const Shirt TWO_COFFEE_PLAYER0_SHIRT = Shirt(
Color::fromHex(Defaults::Player::TwoCoffeeShirt::PLAYER0_DARKEST),
Color::fromHex(Defaults::Player::TwoCoffeeShirt::PLAYER0_DARK),
Color::fromHex(Defaults::Player::TwoCoffeeShirt::PLAYER0_BASE),
Color::fromHex(Defaults::Player::TwoCoffeeShirt::PLAYER0_LIGHT));
const Shirt two_coffee_player1_shirt = Shirt(
const Shirt TWO_COFFEE_PLAYER1_SHIRT = Shirt(
Color::fromHex(Defaults::Player::TwoCoffeeShirt::PLAYER1_DARKEST),
Color::fromHex(Defaults::Player::TwoCoffeeShirt::PLAYER1_DARK),
Color::fromHex(Defaults::Player::TwoCoffeeShirt::PLAYER1_BASE),
Color::fromHex(Defaults::Player::TwoCoffeeShirt::PLAYER1_LIGHT));
std::array<Shirt, 2> two_coffee_shirt = {two_coffee_player0_shirt, two_coffee_player1_shirt};
std::array<Shirt, 2> two_coffee_shirt = {TWO_COFFEE_PLAYER0_SHIRT, TWO_COFFEE_PLAYER1_SHIRT};
const Color outline_player0_color = Color::fromHex(Defaults::Player::OutlineColor::PLAYER0);
const Color outline_player1_color = Color::fromHex(Defaults::Player::OutlineColor::PLAYER1);
std::array<Color, 2> outline_color = {outline_player0_color, outline_player1_color};
const Color OUTLINE_PLAYER0_COLOR = Color::fromHex(Defaults::Player::OutlineColor::PLAYER0);
const Color OUTLINE_PLAYER1_COLOR = Color::fromHex(Defaults::Player::OutlineColor::PLAYER1);
std::array<Color, 2> outline_color = {OUTLINE_PLAYER0_COLOR, OUTLINE_PLAYER1_COLOR};
};
// --- Estructura Param: almacena todos los parámetros del juego ---
-1
View File
@@ -7,7 +7,6 @@
#include <algorithm> // Para clamp, __transform_fn, transform
#include <cctype> // Para tolower, isspace
#include <cmath> // Para pow, sin, M_PI, cos, sqrt
#include <compare> // Para operator<
#include <filesystem> // Para path
#include <ranges> // Para __find_if_not_fn, find_if_not, reverse_view, __find_fn, find, ref_view
#include <string> // Para basic_string, string, allocator, char_traits, operator==, operator+