neteja clang-tidy: enums uint8_t, includes, naming i altres
This commit is contained in:
@@ -726,7 +726,7 @@ void Credits::drawBorderRect() {
|
||||
return; // no dibujar
|
||||
}
|
||||
|
||||
const Color COLOR = color_.LIGHTEN();
|
||||
const Color COLOR = color_.lighten();
|
||||
SDL_Renderer* rdr = Screen::get()->getRenderer();
|
||||
SDL_SetRenderDrawColor(rdr, COLOR.r, COLOR.g, COLOR.b, 0xFF);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/input/input_types.hpp" // Para InputAction
|
||||
#include "core/input/pause_manager.hpp" // Para PauseManager
|
||||
#include "core/locale/lang.hpp" // Para getText
|
||||
#include "core/rendering/background.hpp" // Para Background
|
||||
@@ -341,7 +340,7 @@ void Game::updateStage() {
|
||||
|
||||
// Modificar color de fondo en la última fase
|
||||
if (current_stage_index == total_stages - 1) { // Última fase
|
||||
background_->setColor(Color(0xdd, 0x19, 0x1d).DARKEN());
|
||||
background_->setColor(Color(0xdd, 0x19, 0x1d).darken());
|
||||
background_->setAlpha(96);
|
||||
}
|
||||
}
|
||||
@@ -2183,10 +2182,10 @@ void Game::handleDebugEvents(const SDL_Event& event) {
|
||||
break;
|
||||
}
|
||||
case SDLK_8: {
|
||||
const auto it = std::ranges::find_if(players_,
|
||||
const auto IT = std::ranges::find_if(players_,
|
||||
[](const auto& player) { return player->isPlaying(); });
|
||||
if (it != players_.end()) {
|
||||
createItem(ItemType::COFFEE_MACHINE, (*it)->getPosX(), param.game.game_area.rect.y - Item::COFFEE_MACHINE_HEIGHT);
|
||||
if (IT != players_.end()) {
|
||||
createItem(ItemType::COFFEE_MACHINE, (*IT)->getPosX(), param.game.game_area.rect.y - Item::COFFEE_MACHINE_HEIGHT);
|
||||
coffee_machine_enabled_ = true;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_Event, SDL_Renderer, SDL_Texture, Uint64
|
||||
|
||||
#include <list> // Para list
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
#include <cstdint> // Para std::uint8_t
|
||||
#include <list> // Para list
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "core/system/demo.hpp" // for Demo
|
||||
#include "game/entities/bullet.hpp" // for Bullet
|
||||
@@ -31,7 +32,7 @@ class Texture;
|
||||
struct Path;
|
||||
|
||||
namespace Difficulty {
|
||||
enum class Code;
|
||||
enum class Code : std::uint8_t;
|
||||
} // namespace Difficulty
|
||||
|
||||
// --- Clase Game: núcleo principal del gameplay ---
|
||||
@@ -71,7 +72,7 @@ class Game {
|
||||
using Players = std::vector<std::shared_ptr<Player>>;
|
||||
|
||||
// --- Enums ---
|
||||
enum class State {
|
||||
enum class State : std::uint8_t {
|
||||
FADE_IN, // Transición de entrada
|
||||
ENTERING_PLAYER, // Jugador entrando
|
||||
SHOWING_GET_READY_MESSAGE, // Mostrando mensaje de preparado
|
||||
|
||||
@@ -178,22 +178,17 @@ void HiScoreTable::updateFade(float delta_time) {
|
||||
|
||||
// Convierte un entero a un string con separadores de miles
|
||||
auto HiScoreTable::format(int number) -> std::string {
|
||||
const std::string SEPARATOR = ".";
|
||||
const std::string SCORE = std::to_string(number);
|
||||
const size_t SIZE = SCORE.size();
|
||||
|
||||
auto index = static_cast<int>(SCORE.size()) - 1;
|
||||
std::string result;
|
||||
auto i = 0;
|
||||
while (index >= 0) {
|
||||
result = SCORE.at(index) + result;
|
||||
index--;
|
||||
i++;
|
||||
if (i == 3) {
|
||||
i = 0;
|
||||
result = SEPARATOR + result;
|
||||
result.reserve(SIZE + (SIZE / 3));
|
||||
for (size_t i = 0; i < SIZE; ++i) {
|
||||
if (i > 0 && (SIZE - i) % 3 == 0) {
|
||||
result += '.';
|
||||
}
|
||||
result += SCORE[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -215,7 +210,7 @@ void HiScoreTable::createSprites() {
|
||||
const int FIRST_LINE = (param.game.height - SIZE) / 2;
|
||||
|
||||
// Crea el sprite para el texto de cabecera
|
||||
header_ = std::make_unique<Sprite>(header_text->writeDXToTexture(Text::COLOR, Lang::getText("[HIGHSCORE_TABLE] CAPTION"), -2, background_fade_color_.INVERSE().LIGHTEN(25)));
|
||||
header_ = std::make_unique<Sprite>(header_text->writeDXToTexture(Text::COLOR, Lang::getText("[HIGHSCORE_TABLE] CAPTION"), -2, background_fade_color_.inverse().lighten(25)));
|
||||
header_->setPosition(param.game.game_area.center_x - (header_->getWidth() / 2), FIRST_LINE);
|
||||
|
||||
// Crea los sprites para las entradas en la tabla de puntuaciones
|
||||
@@ -228,13 +223,14 @@ void HiScoreTable::createSprites() {
|
||||
const auto SCORE = format(Options::settings.hi_score_table.at(i).score);
|
||||
const auto NUM_DOTS = ENTRY_LENGTH - Options::settings.hi_score_table.at(i).name.size() - SCORE.size();
|
||||
const auto* const ONE_CC = Options::settings.hi_score_table.at(i).one_credit_complete ? " }" : "";
|
||||
std::string dots;
|
||||
for (int j = 0; std::cmp_less(j, NUM_DOTS); ++j) {
|
||||
dots = dots + ".";
|
||||
}
|
||||
const auto LINE = TABLE_POSITION + Options::settings.hi_score_table.at(i).name + dots + SCORE + ONE_CC;
|
||||
const std::string DOTS(NUM_DOTS, '.');
|
||||
std::string line = TABLE_POSITION;
|
||||
line += Options::settings.hi_score_table.at(i).name;
|
||||
line += DOTS;
|
||||
line += SCORE;
|
||||
line += ONE_CC;
|
||||
|
||||
entry_names_.emplace_back(std::make_shared<PathSprite>(entry_text->writeDXToTexture(Text::SHADOW, LINE, 1, Colors::NO_COLOR_MOD, 1, Colors::SHADOW_TEXT)));
|
||||
entry_names_.emplace_back(std::make_shared<PathSprite>(entry_text->writeDXToTexture(Text::SHADOW, line, 1, Colors::NO_COLOR_MOD, 1, Colors::SHADOW_TEXT)));
|
||||
const int DEFAULT_POS_X = (backbuffer_width - ENTRY_WIDTH) / 2;
|
||||
const int POS_X = (i < 9) ? DEFAULT_POS_X : DEFAULT_POS_X - entry_text->getCharacterSize();
|
||||
const int POS_Y = (i * SPACE_BETWEEN_LINES) + FIRST_LINE + SPACE_BETWEEN_HEADER;
|
||||
@@ -367,10 +363,10 @@ auto HiScoreTable::getEntryColor(int counter) -> Color {
|
||||
// Inicializa los colores de las entradas
|
||||
void HiScoreTable::iniEntryColors() {
|
||||
entry_colors_.clear();
|
||||
entry_colors_.emplace_back(background_fade_color_.INVERSE().LIGHTEN(75));
|
||||
entry_colors_.emplace_back(background_fade_color_.INVERSE().LIGHTEN(50));
|
||||
entry_colors_.emplace_back(background_fade_color_.INVERSE().LIGHTEN(25));
|
||||
entry_colors_.emplace_back(background_fade_color_.INVERSE());
|
||||
entry_colors_.emplace_back(background_fade_color_.inverse().lighten(75));
|
||||
entry_colors_.emplace_back(background_fade_color_.inverse().lighten(50));
|
||||
entry_colors_.emplace_back(background_fade_color_.inverse().lighten(25));
|
||||
entry_colors_.emplace_back(background_fade_color_.inverse());
|
||||
}
|
||||
|
||||
// Hace brillar los nombres de la tabla de records
|
||||
@@ -387,7 +383,7 @@ void HiScoreTable::glowEntryNames() {
|
||||
// Gestiona el contador
|
||||
void HiScoreTable::updateCounter() {
|
||||
if (elapsed_time_ >= BACKGROUND_CHANGE_S && !hiscore_flags_.background_changed) {
|
||||
background_->setColor(background_fade_color_.DARKEN());
|
||||
background_->setColor(background_fade_color_.darken());
|
||||
background_->setAlpha(96);
|
||||
hiscore_flags_.background_changed = true;
|
||||
}
|
||||
|
||||
@@ -392,17 +392,17 @@ void Intro::initSprites() {
|
||||
|
||||
const CardConfig CARD_CONFIGS[] = {
|
||||
// 0: Entra desde la izquierda. La 1 entra desde la derecha → sale empujada hacia la izquierda
|
||||
{-CARD_WIDTH, Y_DEST - 20.0F, CARD_ANGLE_0, -S, S * 0.1F, -A, 0.0F, -R},
|
||||
{.entry_x = -CARD_WIDTH, .entry_y = Y_DEST - 20.0F, .entry_angle = CARD_ANGLE_0, .exit_vx = -S, .exit_vy = S * 0.1F, .exit_ax = -A, .exit_ay = 0.0F, .exit_rotation = -R},
|
||||
// 1: Entra desde la derecha. La 2 entra desde arriba → sale empujada hacia abajo
|
||||
{W + CARD_WIDTH, Y_DEST + 15.0F, CARD_ANGLE_1, S * 0.15F, S, 0.0F, A, R * 1.1},
|
||||
{.entry_x = W + CARD_WIDTH, .entry_y = Y_DEST + 15.0F, .entry_angle = CARD_ANGLE_1, .exit_vx = S * 0.15F, .exit_vy = S, .exit_ax = 0.0F, .exit_ay = A, .exit_rotation = R * 1.1},
|
||||
// 2: Entra desde arriba. La 3 entra desde abajo → sale empujada hacia arriba
|
||||
{X_DEST + 30.0F, -CARD_HEIGHT, CARD_ANGLE_2, -S * 0.15F, -S, 0.0F, -A, -R * 0.9},
|
||||
{.entry_x = X_DEST + 30.0F, .entry_y = -CARD_HEIGHT, .entry_angle = CARD_ANGLE_2, .exit_vx = -S * 0.15F, .exit_vy = -S, .exit_ax = 0.0F, .exit_ay = -A, .exit_rotation = -R * 0.9},
|
||||
// 3: Entra desde abajo. La 4 entra desde arriba-izquierda → sale empujada hacia abajo-derecha
|
||||
{X_DEST - 25.0F, H + CARD_HEIGHT, CARD_ANGLE_3, S * 0.8F, S * 0.6F, A * 0.5F, A * 0.4F, R},
|
||||
{.entry_x = X_DEST - 25.0F, .entry_y = H + CARD_HEIGHT, .entry_angle = CARD_ANGLE_3, .exit_vx = S * 0.8F, .exit_vy = S * 0.6F, .exit_ax = A * 0.5F, .exit_ay = A * 0.4F, .exit_rotation = R},
|
||||
// 4: Entra desde arriba-izquierda. La 5 entra desde derecha-abajo → sale empujada hacia arriba-izquierda
|
||||
{-CARD_WIDTH * 0.5F, -CARD_HEIGHT, CARD_ANGLE_4, -S * 0.7F, -S * 0.5F, -A * 0.5F, -A * 0.3F, -R * 1.2},
|
||||
{.entry_x = -CARD_WIDTH * 0.5F, .entry_y = -CARD_HEIGHT, .entry_angle = CARD_ANGLE_4, .exit_vx = -S * 0.7F, .exit_vy = -S * 0.5F, .exit_ax = -A * 0.5F, .exit_ay = -A * 0.3F, .exit_rotation = -R * 1.2},
|
||||
// 5: Entra desde la derecha-abajo. Última: sale hacia la izquierda suave (viento)
|
||||
{W + CARD_WIDTH, H * 0.6F, CARD_ANGLE_5, -S * 0.6F, -S * 0.1F, -A * 0.5F, 0.0F, -R * 0.7},
|
||||
{.entry_x = W + CARD_WIDTH, .entry_y = H * 0.6F, .entry_angle = CARD_ANGLE_5, .exit_vx = -S * 0.6F, .exit_vy = -S * 0.1F, .exit_ax = -A * 0.5F, .exit_ay = 0.0F, .exit_rotation = -R * 0.7},
|
||||
};
|
||||
|
||||
// Inicializa los CardSprites
|
||||
@@ -534,15 +534,15 @@ void Intro::updatePostState() {
|
||||
if (ELAPSED_TIME >= POST_BG_STOP_DELAY_S) {
|
||||
tiled_bg_->stopGracefully();
|
||||
|
||||
if (!bg_color_.IS_EQUAL_TO(param.title.bg_color)) {
|
||||
bg_color_ = bg_color_.APPROACH_TO(param.title.bg_color, 1);
|
||||
if (!bg_color_.isEqualTo(param.title.bg_color)) {
|
||||
bg_color_ = bg_color_.approachTo(param.title.bg_color, 1);
|
||||
}
|
||||
|
||||
tiled_bg_->setColor(bg_color_);
|
||||
}
|
||||
|
||||
// Cambia de estado si el fondo se ha detenido y recuperado el color
|
||||
if (tiled_bg_->isStopped() && bg_color_.IS_EQUAL_TO(param.title.bg_color)) {
|
||||
if (tiled_bg_->isStopped() && bg_color_.isEqualTo(param.title.bg_color)) {
|
||||
post_state_ = PostState::END;
|
||||
state_start_time_ = SDL_GetTicks() / 1000.0F;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para Uint32, Uint64
|
||||
|
||||
#include <memory> // Para unique_ptr
|
||||
#include <vector> // Para vector
|
||||
#include <cstdint> // Para std::uint8_t
|
||||
#include <memory> // Para unique_ptr
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "core/rendering/sprite/card_sprite.hpp" // Para CardSprite
|
||||
#include "core/rendering/tiled_bg.hpp" // Para TiledBG
|
||||
@@ -79,12 +80,12 @@ class Intro {
|
||||
static constexpr double CARD_ANGLE_5 = -7.0;
|
||||
|
||||
// --- Estados internos ---
|
||||
enum class State {
|
||||
enum class State : std::uint8_t {
|
||||
SCENES,
|
||||
POST,
|
||||
};
|
||||
|
||||
enum class PostState {
|
||||
enum class PostState : std::uint8_t {
|
||||
STOP_BG,
|
||||
END,
|
||||
};
|
||||
|
||||
@@ -14,6 +14,6 @@ class Preload {
|
||||
~Preload() = default;
|
||||
|
||||
// --- Callbacks para el bucle SDL_MAIN_USE_CALLBACKS ---
|
||||
void iterate(); // Repinta la barra de progreso
|
||||
void handleEvent(const SDL_Event& event); // Detecta pulsación en modo wait_for_input
|
||||
static void iterate(); // Repinta la barra de progreso
|
||||
static void handleEvent(const SDL_Event& event); // Detecta pulsación en modo wait_for_input
|
||||
};
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_Event, SDL_Keycode, SDL_PollEvent, SDLK_A, SDLK_C, SDLK_D, SDLK_F, SDLK_S, SDLK_V, SDLK_X, SDLK_Z, SDL_EventType, Uint64
|
||||
|
||||
#include <ranges> // Para __find_if_fn, find_if
|
||||
#include <string> // Para basic_string, char_traits, operator+, to_string, string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/input/input_types.hpp" // Para InputAction
|
||||
#include "core/locale/lang.hpp" // Para getText
|
||||
#include "core/rendering/fade.hpp" // Para Fade
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
@@ -300,6 +298,9 @@ void Title::updateFade() {
|
||||
Section::options = Section::Options::GAME_PLAY_BOTH;
|
||||
Audio::get()->stopMusic();
|
||||
break;
|
||||
|
||||
default:
|
||||
break; // COMBO és un bitmask 2-bit (0..3); arribar ací és impossible.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_Keycode, SDL_Event, Uint64
|
||||
|
||||
#include <cstdint> // Para std::uint8_t
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <string_view> // Para string_view
|
||||
#include <vector> // Para vector
|
||||
@@ -69,7 +70,7 @@ class Title {
|
||||
static constexpr bool ALLOW_TITLE_ANIMATION_SKIP = false; // Permite saltar la animación del título
|
||||
|
||||
// --- Enums ---
|
||||
enum class State {
|
||||
enum class State : std::uint8_t {
|
||||
LOGO_ANIMATING, // El logo está animándose
|
||||
LOGO_FINISHED, // El logo ha terminado de animarse
|
||||
START_HAS_BEEN_PRESSED, // Se ha pulsado el botón de start
|
||||
|
||||
Reference in New Issue
Block a user