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
+1 -1
View File
@@ -351,7 +351,7 @@ void Screen::renderInfo() const {
if (!debug_info_.show) { return; }
const Color GOLD(0xFF, 0xD7, 0x00);
const Color GOLD_SHADOW = GOLD.DARKEN(150);
const Color GOLD_SHADOW = GOLD.darken(150);
const std::string INFO_TEXT = buildDebugInfoText();
const int TEXT_WIDTH = debug_info_.text->length(INFO_TEXT);
+16 -16
View File
@@ -606,11 +606,11 @@ void Resource::createPlayerTextures() {
if (palette_idx == 0) {
// Textura 0 - usar la ya cargada y modificar solo paleta 0 (default_shirt)
texture = getTexture(player.base_texture);
texture->setPaletteColor(0, 16, param.player.default_shirt[player_idx].darkest.TO_UINT32());
texture->setPaletteColor(0, 17, param.player.default_shirt[player_idx].dark.TO_UINT32());
texture->setPaletteColor(0, 18, param.player.default_shirt[player_idx].base.TO_UINT32());
texture->setPaletteColor(0, 19, param.player.default_shirt[player_idx].light.TO_UINT32());
texture->setPaletteColor(0, 56, param.player.outline_color[player_idx].TO_UINT32());
texture->setPaletteColor(0, 16, param.player.default_shirt[player_idx].darkest.toUint32());
texture->setPaletteColor(0, 17, param.player.default_shirt[player_idx].dark.toUint32());
texture->setPaletteColor(0, 18, param.player.default_shirt[player_idx].base.toUint32());
texture->setPaletteColor(0, 19, param.player.default_shirt[player_idx].light.toUint32());
texture->setPaletteColor(0, 56, param.player.outline_color[player_idx].toUint32());
} else {
// Crear textura nueva desde archivo usando ResourceHelper
texture = std::make_shared<Texture>(Screen::get()->getRenderer(), TEXTURE_FILE_PATH);
@@ -622,18 +622,18 @@ void Resource::createPlayerTextures() {
if (palette_idx == 1) {
// Textura 1 - modificar solo paleta 1 (one_coffee_shirt)
texture->setPaletteColor(1, 16, param.player.one_coffee_shirt[player_idx].darkest.TO_UINT32());
texture->setPaletteColor(1, 17, param.player.one_coffee_shirt[player_idx].dark.TO_UINT32());
texture->setPaletteColor(1, 18, param.player.one_coffee_shirt[player_idx].base.TO_UINT32());
texture->setPaletteColor(1, 19, param.player.one_coffee_shirt[player_idx].light.TO_UINT32());
texture->setPaletteColor(1, 56, param.player.outline_color[player_idx].TO_UINT32());
texture->setPaletteColor(1, 16, param.player.one_coffee_shirt[player_idx].darkest.toUint32());
texture->setPaletteColor(1, 17, param.player.one_coffee_shirt[player_idx].dark.toUint32());
texture->setPaletteColor(1, 18, param.player.one_coffee_shirt[player_idx].base.toUint32());
texture->setPaletteColor(1, 19, param.player.one_coffee_shirt[player_idx].light.toUint32());
texture->setPaletteColor(1, 56, param.player.outline_color[player_idx].toUint32());
} else if (palette_idx == 2) {
// Textura 2 - modificar solo paleta 2 (two_coffee_shirt)
texture->setPaletteColor(2, 16, param.player.two_coffee_shirt[player_idx].darkest.TO_UINT32());
texture->setPaletteColor(2, 17, param.player.two_coffee_shirt[player_idx].dark.TO_UINT32());
texture->setPaletteColor(2, 18, param.player.two_coffee_shirt[player_idx].base.TO_UINT32());
texture->setPaletteColor(2, 19, param.player.two_coffee_shirt[player_idx].light.TO_UINT32());
texture->setPaletteColor(2, 56, param.player.outline_color[player_idx].TO_UINT32());
texture->setPaletteColor(2, 16, param.player.two_coffee_shirt[player_idx].darkest.toUint32());
texture->setPaletteColor(2, 17, param.player.two_coffee_shirt[player_idx].dark.toUint32());
texture->setPaletteColor(2, 18, param.player.two_coffee_shirt[player_idx].base.toUint32());
texture->setPaletteColor(2, 19, param.player.two_coffee_shirt[player_idx].light.toUint32());
texture->setPaletteColor(2, 56, param.player.outline_color[player_idx].toUint32());
}
// Textura 3 (palette_idx == 3) - no modificar nada, usar colores originales
}
@@ -797,7 +797,7 @@ void Resource::renderProgress() {
const bool WAITING_FOR_INPUT = isLoadDone() && Options::loading.wait_for_input;
auto text_color = param.resource.color;
auto bar_color = param.resource.color.DARKEN(100);
auto bar_color = param.resource.color.darken(100);
const auto TEXT_HEIGHT = loading_text_->getCharacterSize();
// Dibuja el interior de la barra de progreso
-1
View File
@@ -6,7 +6,6 @@
#include <stdexcept> // Para runtime_error
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
#include "utils/utils.hpp" // Para getFileName
// Carga el fichero de datos para la demo
auto loadDemoDataFromFile(const std::string& file_path) -> DemoData {
+2 -2
View File
@@ -473,7 +473,7 @@ auto Director::iterate() -> SDL_AppResult {
// Ejecuta un frame de la sección activa
if (preload_) {
preload_->iterate();
Preload::iterate();
} else if (logo_) {
logo_->iterate();
} else if (intro_) {
@@ -500,7 +500,7 @@ auto Director::handleEvent(const SDL_Event& event) -> SDL_AppResult {
// Reenvía a la sección activa
if (preload_) {
preload_->handleEvent(event);
Preload::handleEvent(event);
} else if (logo_) {
logo_->handleEvent(event);
} else if (intro_) {
+1 -1
View File
@@ -7,7 +7,7 @@
#include "core/audio/audio.hpp" // Para Audio
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
#include "core/rendering/sprite/sprite.hpp" // Para Sprite
#include "core/rendering/texture.hpp" // Para Texture
#include "core/rendering/texture.hpp" // IWYU pragma: keep
#include "utils/param.hpp" // Para Param, ParamBalloon, param
// Constructor
+5 -4
View File
@@ -2,9 +2,10 @@
#include <SDL3/SDL.h> // Para SDL_FRect, Uint16
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include <vector> // Para vector
#include <cstdint> // Para std::uint8_t
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include <vector> // Para vector
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
#include "utils/utils.hpp" // Para Circle
@@ -12,7 +13,7 @@
class Texture;
// --- Enums ---
enum class ItemType : int {
enum class ItemType : std::uint8_t {
DISK = 1, // Disco
GAVINA = 2, // Gavina
PACMAR = 3, // Pacman
-5
View File
@@ -8,7 +8,6 @@
#include "core/audio/audio.hpp" // Para Audio
#include "core/input/input.hpp" // Para Input
#include "core/input/input_types.hpp" // Para InputAction
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
#include "core/rendering/texture.hpp" // Para Texture
#include "core/resources/asset.hpp" // Para Asset
@@ -1135,8 +1134,6 @@ void Player::updateFiringStateFromVisual() {
firing_state_ = State::RECOILING_RIGHT;
break;
case State::FIRING_UP:
firing_state_ = State::RECOILING_UP;
break;
default:
firing_state_ = State::RECOILING_UP;
break;
@@ -1152,8 +1149,6 @@ void Player::updateFiringStateFromVisual() {
firing_state_ = State::COOLING_RIGHT;
break;
case State::FIRING_UP:
firing_state_ = State::COOLING_UP;
break;
default:
firing_state_ = State::COOLING_UP;
break;
+9 -9
View File
@@ -2,12 +2,12 @@
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_FlipMode
#include <cstddef> // Para size_t
#include <iterator> // Para pair
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para basic_string, string
#include <utility> // Para move, pair
#include <vector> // Para vector
#include <cstddef> // Para size_t
#include <cstdint> // Para std::uint8_t, std::int8_t
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para basic_string, string
#include <utility> // Para move, pair
#include <vector> // Para vector
#include "core/input/input.hpp" // for Input
#include "core/rendering/sprite/animated_sprite.hpp" // for AnimatedSprite
@@ -49,14 +49,14 @@ class Player {
};
// --- Enums ---
enum class Id : int {
enum class Id : std::int8_t {
NO_PLAYER = -1, // Sin jugador
BOTH_PLAYERS = 0, // Ambos jugadores
PLAYER1 = 1, // Jugador 1
PLAYER2 = 2 // Jugador 2
};
enum class State {
enum class State : std::uint8_t {
// Estados de movimiento
WALKING_LEFT, // Caminando hacia la izquierda
WALKING_RIGHT, // Caminando hacia la derecha
@@ -293,7 +293,7 @@ class Player {
bool can_fire_new_system_ = true; // true si puede disparar ahora mismo
// LÍNEA 2: SISTEMA VISUAL (Animaciones)
enum class VisualFireState {
enum class VisualFireState : std::uint8_t {
NORMAL, // Brazo en posición neutral
AIMING, // Brazo alzado (disparando)
RECOILING, // Brazo en retroceso
+3 -2
View File
@@ -2,6 +2,7 @@
#include <SDL3/SDL.h> // Para Uint32, SDL_GetTicks, SDL_FRect
#include <cstdint> // Para std::uint8_t
#include <cstdlib> // Para rand
#include <memory> // Para unique_ptr
@@ -11,12 +12,12 @@
class Tabe {
public:
// --- Enumeraciones para dirección y estado ---
enum class Direction : int {
enum class Direction : std::uint8_t {
TO_THE_LEFT = 0,
TO_THE_RIGHT = 1,
};
enum class State : int {
enum class State : std::uint8_t {
FLY = 0,
HIT = 1,
};
@@ -201,6 +201,8 @@ auto BalloonFormations::evaluateSimpleExpression(const std::string& expr, const
return left_val * right_val;
case '/':
return right_val != 0 ? left_val / right_val : 0;
default:
break; // Inalcanzable: el if exterior solo deja pasar '+', '-', '*', '/'
}
}
}
@@ -1,7 +1,6 @@
#pragma once
#include <cstddef> // Para size_t
#include <iterator> // Para pair
#include <map> // Para map
#include <optional> // Para optional
#include <string> // Para string
-1
View File
@@ -1,6 +1,5 @@
#include "game/gameplay/bullet_manager.hpp"
#include <algorithm> // Para remove_if
#include <utility>
#include "game/entities/bullet.hpp" // Para Bullet
-1
View File
@@ -5,7 +5,6 @@
#include <functional> // Para function
#include <list> // Para list
#include <memory> // Para shared_ptr
#include <vector> // Para vector
#include "game/entities/bullet.hpp" // for Bullet
+6 -6
View File
@@ -19,19 +19,19 @@ namespace Difficulty {
}
auto getNameFromCode(Code code) -> std::string {
const auto it = std::ranges::find_if(difficulties_list,
const auto IT = std::ranges::find_if(difficulties_list,
[code](const auto& difficulty) { return difficulty.code == code; });
if (it != difficulties_list.end()) {
return it->name;
if (IT != difficulties_list.end()) {
return IT->name;
}
return !difficulties_list.empty() ? difficulties_list.front().name : "Unknown";
}
auto getCodeFromName(const std::string& name) -> Code {
const auto it = std::ranges::find_if(difficulties_list,
const auto IT = std::ranges::find_if(difficulties_list,
[&name](const auto& difficulty) { return difficulty.name == name; });
if (it != difficulties_list.end()) {
return it->code;
if (IT != difficulties_list.end()) {
return IT->code;
}
return !difficulties_list.empty() ? difficulties_list.front().code : Code::NORMAL;
}
+4 -3
View File
@@ -1,12 +1,13 @@
#pragma once
#include <string> // Para string
#include <vector> // Para vector
#include <cstdint> // Para std::uint8_t
#include <string> // Para string
#include <vector> // Para vector
namespace Difficulty {
// --- Enums ---
enum class Code {
enum class Code : std::uint8_t {
EASY = 0, // Dificultad fácil
NORMAL = 1, // Dificultad normal
HARD = 2, // Dificultad difícil
+3 -2
View File
@@ -1,6 +1,7 @@
#pragma once
#include <memory> // Para unique_ptr, shared_ptr
#include <cstdint> // Para std::uint8_t
#include <memory> // Para unique_ptr, shared_ptr
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
#include "core/rendering/sprite/smart_sprite.hpp" // Para SmartSprite
@@ -36,7 +37,7 @@ class GameLogo {
private:
// --- Enums ---
enum class Status {
enum class Status : std::uint8_t {
DISABLED, // Deshabilitado
MOVING, // En movimiento
SHAKING, // Temblando
@@ -2,15 +2,13 @@
#include <SDL3/SDL.h> // Para SDL_ReadIO, SDL_WriteIO, SDL_CloseIO, SDL_GetError, SDL_IOFromFile, SDL_LogError, SDL_LogCategory, SDL_LogInfo
#include <algorithm> // Para __sort_fn, sort
#include <array> // Para array
#include <functional> // Para identity
#include <iomanip> // Para std::setw, std::setfill
#include <iostream> // Para std::cout
#include <iterator> // Para distance
#include <numeric> // Para accumulate
#include <ranges> // Para __find_if_fn, find_if
#include <utility> // Para move
#include <algorithm> // Para sort, ranges::find_if, ranges::sort
#include <array> // Para array
#include <iomanip> // Para std::setw, std::setfill
#include <iostream> // Para std::cout
#include <iterator> // Para distance
#include <numeric> // Para accumulate
#include <utility> // Para move
#include "utils/utils.hpp" // Para getFileName
+10 -10
View File
@@ -79,7 +79,7 @@ Scoreboard::Scoreboard()
fillBackgroundTexture();
// Inicializa el ciclo de colores para el nombre
name_color_cycle_ = Colors::generateMirroredCycle(color_.INVERSE(), ColorCycleStyle::VIBRANT);
name_color_cycle_ = Colors::generateMirroredCycle(color_.inverse(), ColorCycleStyle::VIBRANT);
animated_color_ = name_color_cycle_.at(0);
}
@@ -337,13 +337,13 @@ void Scoreboard::render() {
void Scoreboard::setColor(Color color) {
// Actualiza las variables de colores
color_ = color;
text_color1_ = param.scoreboard.text_autocolor ? color_.LIGHTEN(100) : param.scoreboard.text_color1;
text_color2_ = param.scoreboard.text_autocolor ? color_.LIGHTEN(150) : param.scoreboard.text_color2;
text_color1_ = param.scoreboard.text_autocolor ? color_.lighten(100) : param.scoreboard.text_color1;
text_color2_ = param.scoreboard.text_autocolor ? color_.lighten(150) : param.scoreboard.text_color2;
// Aplica los colores
power_meter_sprite_->getTexture()->setColor(text_color2_);
fillBackgroundTexture();
name_color_cycle_ = Colors::generateMirroredCycle(color_.INVERSE(), ColorCycleStyle::VIBRANT);
name_color_cycle_ = Colors::generateMirroredCycle(color_.inverse(), ColorCycleStyle::VIBRANT);
}
// Establece el valor de la variable
@@ -383,9 +383,9 @@ void Scoreboard::fillPanelTextures() {
}
// Interpolar entre color base y color aclarado
Color target_color = color_.LIGHTEN(PANEL_PULSE_LIGHTEN_AMOUNT);
Color target_color = color_.lighten(PANEL_PULSE_LIGHTEN_AMOUNT);
// Color target_color = color_.INVERSE();
background_color = color_.LERP(target_color, pulse_intensity);
background_color = color_.lerp(target_color, pulse_intensity);
background_color.a = 255; // Opaco durante el pulso
}
@@ -716,7 +716,7 @@ void Scoreboard::createPanelTextures() {
// Dibuja la linea que separa la zona de juego del marcador
void Scoreboard::renderSeparator() {
// Dibuja la linea que separa el marcador de la zona de juego
auto color = param.scoreboard.separator_autocolor ? color_.DARKEN() : param.scoreboard.separator_color;
auto color = param.scoreboard.separator_autocolor ? color_.darken() : param.scoreboard.separator_color;
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 255);
SDL_RenderLine(renderer_, 0, 0, rect_.w, 0);
}
@@ -755,7 +755,7 @@ void Scoreboard::renderCarousel(size_t panel_index, int center_x, int y) {
}
const float FRACTIONAL_OFFSET = frac;
const int PIXEL_OFFSET = static_cast<int>((FRACTIONAL_OFFSET * CHAR_STEP) + 0.5F);
const int PIXEL_OFFSET = static_cast<int>(std::lround(FRACTIONAL_OFFSET * CHAR_STEP));
// Índice base en la lista de caracteres (posición central)
const int BASE_INDEX = static_cast<int>(std::floor(carousel_pos));
@@ -790,13 +790,13 @@ void Scoreboard::renderCarousel(size_t panel_index, int center_x, int y) {
if (DISTANCE_FROM_CENTER < 0.5F) {
// Letra central → transiciona hacia animated_color_
float lerp_to_animated = DISTANCE_FROM_CENTER / 0.5F; // 0.0 a 1.0
letter_color = animated_color_.LERP(text_color1_, lerp_to_animated);
letter_color = animated_color_.lerp(text_color1_, lerp_to_animated);
} else {
// Letras alejadas → degradan hacia color_ base
float base_lerp = (DISTANCE_FROM_CENTER - 0.5F) / (HALF_VISIBLE - 0.5F);
base_lerp = std::min(base_lerp, 1.0F);
const float LERP_FACTOR = base_lerp * 0.85F;
letter_color = text_color1_.LERP(color_, LERP_FACTOR);
letter_color = text_color1_.lerp(color_, LERP_FACTOR);
}
// Calcular posición X de la letra
+3 -2
View File
@@ -4,6 +4,7 @@
#include <array> // Para array
#include <cstddef> // Para size_t
#include <cstdint> // Para std::uint8_t
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string, basic_string
#include <vector> // Para vector
@@ -21,14 +22,14 @@ class Texture;
class Scoreboard {
public:
// --- Enums ---
enum class Id : size_t {
enum class Id : std::uint8_t {
LEFT = 0,
CENTER = 1,
RIGHT = 2,
SIZE = 3
};
enum class Mode : int {
enum class Mode : std::uint8_t {
SCORE,
STAGE_INFO,
CONTINUE,
+3 -2
View File
@@ -1,6 +1,7 @@
#pragma once
#include <cstddef> // Para size_t
#include <cstdint> // Para std::uint8_t
#include <functional> // Para function
#include <optional> // Para optional
#include <string> // Para basic_string, string
@@ -9,12 +10,12 @@
#include "core/system/stage_interface.hpp" // for IStageInfo
// --- Enums ---
enum class PowerCollectionState {
enum class PowerCollectionState : std::uint8_t {
ENABLED, // Recolección habilitada
DISABLED // Recolección deshabilitada
};
enum class StageStatus {
enum class StageStatus : std::uint8_t {
LOCKED, // Fase bloqueada
IN_PROGRESS, // Fase en progreso
COMPLETED // Fase completada
+1 -1
View File
@@ -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);
+4 -5
View File
@@ -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;
+7 -6
View File
@@ -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
+19 -23
View File
@@ -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;
}
+9 -9
View File
@@ -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;
}
+5 -4
View File
@@ -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,
};
+2 -2
View File
@@ -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
};
+3 -2
View File
@@ -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 -1
View File
@@ -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
+5 -3
View File
@@ -1,7 +1,9 @@
#pragma once
#include <algorithm> // Para max, clamp
#include <cmath> // Para std::lround
#include <cstddef> // Para size_t
#include <cstdint> // Para std::uint8_t
#include <functional> // Para function
#include <numeric> // Para accumulate
#include <string> // Para allocator, string, basic_string, to_string, operator==, char_traits
@@ -16,7 +18,7 @@
class MenuOption {
public:
// --- Enums ---
enum class Behavior {
enum class Behavior : std::uint8_t {
ADJUST, // Solo puede ajustar valor (como IntOption, BoolOption, ListOption)
SELECT, // Solo puede ejecutar acción (como ActionOption, FolderOption)
BOTH // Puede tanto ajustar como ejecutar acción (como ActionListOption)
@@ -119,11 +121,11 @@ class VolumeOption : public MenuOption {
[[nodiscard]] auto getBehavior() const -> Behavior override { return Behavior::ADJUST; }
[[nodiscard]] auto getValueAsString() const -> std::string override {
int pct = static_cast<int>(*linked_variable_ * 100.0F + 0.5F);
int pct = static_cast<int>(std::lround(*linked_variable_ * 100.0F));
return std::to_string(pct);
}
void adjustValue(bool adjust_up) override {
int current = static_cast<int>(*linked_variable_ * 100.0F + 0.5F);
int current = static_cast<int>(std::lround(*linked_variable_ * 100.0F));
int new_value = std::clamp(current + (adjust_up ? step_value_ : -step_value_), 0, 100);
*linked_variable_ = static_cast<float>(new_value) / 100.0F;
}
+2 -2
View File
@@ -69,7 +69,7 @@ void MenuRenderer::render(const ServiceMenu* menu_state) {
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_);
// Dibuja el borde
const Color BORDER_COLOR = param.service_menu.title_color.DARKEN();
const Color BORDER_COLOR = param.service_menu.title_color.darken();
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), BORDER_COLOR.r, BORDER_COLOR.g, BORDER_COLOR.b, 255);
SDL_RenderRect(Screen::get()->getRenderer(), &rect_);
SDL_RenderRect(Screen::get()->getRenderer(), &border_rect_);
@@ -111,7 +111,7 @@ void MenuRenderer::render(const ServiceMenu* menu_state) {
// Dibuja las opciones
y = options_y_;
const auto& option_pairs = menu_state->getOptionPairs();
const float ROW_HEIGHT = static_cast<float>(options_height_ + options_padding_);
const auto ROW_HEIGHT = static_cast<float>(options_height_ + options_padding_);
for (size_t i = 0; i < option_pairs.size(); ++i) {
const bool IS_SELECTED = (i == menu_state->getSelectedIndex());
+3 -2
View File
@@ -4,6 +4,7 @@
#include <array>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
@@ -17,7 +18,7 @@ class Text;
class MenuRenderer {
public:
// --- Nuevo: Enum para el modo de posicionamiento ---
enum class PositionMode {
enum class PositionMode : std::uint8_t {
CENTERED, // La ventana se centra en el punto especificado
FIXED // La esquina superior izquierda coincide con el punto
};
@@ -94,7 +95,7 @@ class MenuRenderer {
} resize_animation_;
struct ShowHideAnimation {
enum class Type { NONE,
enum class Type : std::uint8_t { NONE,
SHOWING,
HIDING };
Type type = Type::NONE;
+7 -6
View File
@@ -2,9 +2,10 @@
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_Renderer
#include <memory> // Para shared_ptr
#include <string> // Para basic_string, string
#include <vector> // Para vector
#include <cstdint> // Para std::uint8_t
#include <memory> // Para shared_ptr
#include <string> // Para basic_string, string
#include <vector> // Para vector
#include "utils/color.hpp" // Para stringInVector, Color
#include "utils/utils.hpp"
@@ -17,7 +18,7 @@ class Texture;
class Notifier {
public:
// --- Enums ---
enum class Position {
enum class Position : std::uint8_t {
TOP, // Parte superior
BOTTOM, // Parte inferior
LEFT, // Lado izquierdo
@@ -46,14 +47,14 @@ class Notifier {
static constexpr float ANIMATION_SPEED_PX_PER_S = 60.0F; // Velocidad de animación (1 pixel/frame @ 60fps)
// --- Enums privados ---
enum class State {
enum class State : std::uint8_t {
RISING, // Apareciendo
STAY, // Visible
VANISHING, // Desapareciendo
FINISHED, // Terminada
};
enum class Shape {
enum class Shape : std::uint8_t {
ROUNDED, // Forma redondeada
SQUARED, // Forma cuadrada
};
+115 -110
View File
@@ -8,7 +8,6 @@
#include "core/audio/audio.hpp" // Para Audio
#include "core/input/define_buttons.hpp" // Para DefineButtons
#include "core/input/input.hpp" // Para Input
#include "core/input/input_types.hpp" // Para InputAction
#include "core/locale/lang.hpp" // Para getText, getCodeFromName, getNameFromCode
#include "core/rendering/screen.hpp" // Para Screen
#include "core/resources/resource.hpp" // Para Resource
@@ -252,9 +251,9 @@ void ServiceMenu::applySettingsSettings() {
}
auto ServiceMenu::getOptionByCaption(const std::string& caption) const -> MenuOption* {
const auto it = std::ranges::find_if(options_,
const auto IT = std::ranges::find_if(options_,
[&caption](const auto& option) { return option->getCaption() == caption; });
return it != options_.end() ? it->get() : nullptr;
return IT != options_.end() ? IT->get() : nullptr;
}
// --- Getters y otros ---
@@ -279,8 +278,16 @@ auto ServiceMenu::countOptionsInGroup(SettingsGroup group) const -> size_t {
// Inicializa todas las opciones del menú
void ServiceMenu::initializeOptions() {
options_.clear();
addControlsOptions();
addVideoOptions();
addAudioOptions();
addSettingsOptions();
addSystemOptions();
addMainMenuOptions();
setHiddenOptions();
}
// CONTROLS - Usando ActionListOption para mandos
void ServiceMenu::addControlsOptions() {
options_.push_back(std::make_unique<ActionListOption>(
Lang::getText("[SERVICE_MENU] CONTROLLER1"),
SettingsGroup::CONTROLS,
@@ -292,7 +299,6 @@ void ServiceMenu::initializeOptions() {
Options::gamepad_manager.assignGamepadToPlayer(Player::Id::PLAYER1, Input::get()->getGamepadByName(val), val);
},
[this]() -> void {
// Acción: configurar botones del mando del jugador 1
auto* gamepad = &Options::gamepad_manager.getGamepad(Player::Id::PLAYER1);
if (gamepad->instance != nullptr) {
define_buttons_->enable(gamepad);
@@ -310,14 +316,12 @@ void ServiceMenu::initializeOptions() {
Options::gamepad_manager.assignGamepadToPlayer(Player::Id::PLAYER2, Input::get()->getGamepadByName(val), val);
},
[this]() -> void {
// Acción: configurar botones del mando del jugador 2
auto* gamepad = &Options::gamepad_manager.getGamepad(Player::Id::PLAYER2);
if (gamepad->instance != nullptr) {
define_buttons_->enable(gamepad);
}
}));
// CONTROLS - Opción para teclado (solo lista, sin acción)
options_.push_back(std::make_unique<ListOption>(
Lang::getText("[SERVICE_MENU] KEYBOARD"),
SettingsGroup::CONTROLS,
@@ -325,26 +329,22 @@ void ServiceMenu::initializeOptions() {
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) -> void {
// Asignar el teclado al jugador seleccionado
Options::keyboard.assignTo(Options::stringToPlayerId(val));
}));
// CONTROLS - Acción para intercambiar mandos
options_.push_back(std::make_unique<ActionOption>(
Lang::getText("[SERVICE_MENU] SWAP_CONTROLLERS"),
SettingsGroup::CONTROLS,
[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
adjustListValues();
updateOptionPairs();
// Feedback visual: anima el intercambio de los valores entre
// las filas de MANDO 1 y MANDO 2, imprescindible cuando los dos
// mandos tienen el mismo nombre (el texto no cambia al swap).
// Feedback visual: anima el intercambio de las filas de MANDO 1 y MANDO 2,
// imprescindible cuando ambos mandos tienen el mismo nombre (el texto no cambia).
const std::string CAPTION1 = Lang::getText("[SERVICE_MENU] CONTROLLER1");
const std::string CAPTION2 = Lang::getText("[SERVICE_MENU] CONTROLLER2");
size_t idx1 = display_options_.size();
@@ -358,8 +358,9 @@ void ServiceMenu::initializeOptions() {
renderer_->startSwapAnimation(idx1, idx2);
}
}));
}
// VIDEO
void ServiceMenu::addVideoOptions() {
options_.push_back(std::make_unique<BoolOption>(
Lang::getText("[SERVICE_MENU] FULLSCREEN"),
SettingsGroup::VIDEO,
@@ -373,76 +374,8 @@ void ServiceMenu::initializeOptions() {
Options::window.max_zoom,
1));
// Shader: Desactivat / PostFX / CrtPi
{
std::string disabled_text = Lang::getText("[SERVICE_MENU] SHADER_DISABLED");
std::vector<std::string> shader_values = {disabled_text, "PostFX", "CrtPi"};
auto shader_getter = [disabled_text]() -> std::string {
// NOLINTNEXTLINE(performance-no-automatic-move) -- captura por valor en lambda const, no se puede mover
if (!Options::video.shader.enabled) { return disabled_text; }
return (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) ? "CrtPi" : "PostFX";
};
auto shader_setter = [disabled_text](const std::string& val) {
if (val == disabled_text) {
Options::video.shader.enabled = false;
} else {
Options::video.shader.enabled = true;
const auto TYPE = (val == "CrtPi") ? Rendering::ShaderType::CRTPI : Rendering::ShaderType::POSTFX;
Options::video.shader.current_shader = TYPE;
auto* screen = Screen::get();
if (screen != nullptr) {
screen->applySettings();
}
}
Screen::initShaders();
};
options_.push_back(std::make_unique<ListOption>(
Lang::getText("[SERVICE_MENU] SHADER"),
SettingsGroup::VIDEO,
shader_values,
shader_getter,
shader_setter));
}
// Preset: muestra nombre, cicla circularmente entre presets del shader activo
{
auto preset_getter = []() -> std::string {
if (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) {
if (Options::crtpi_presets.empty()) { return ""; }
return Options::crtpi_presets.at(static_cast<size_t>(Options::video.shader.current_crtpi_preset)).name;
}
if (Options::postfx_presets.empty()) { return ""; }
return Options::postfx_presets.at(static_cast<size_t>(Options::video.shader.current_postfx_preset)).name;
};
auto preset_adjuster = [](bool up) {
if (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) {
if (Options::crtpi_presets.empty()) { return; }
const int SIZE = static_cast<int>(Options::crtpi_presets.size());
Options::video.shader.current_crtpi_preset = up
? (Options::video.shader.current_crtpi_preset + 1) % SIZE
: (Options::video.shader.current_crtpi_preset + SIZE - 1) % SIZE;
} else {
if (Options::postfx_presets.empty()) { return; }
const int SIZE = static_cast<int>(Options::postfx_presets.size());
Options::video.shader.current_postfx_preset = up
? (Options::video.shader.current_postfx_preset + 1) % SIZE
: (Options::video.shader.current_postfx_preset + SIZE - 1) % SIZE;
}
Screen::initShaders();
};
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>(
Lang::getText("[SERVICE_MENU] SHADER_PRESET"),
SettingsGroup::VIDEO,
preset_getter,
preset_adjuster,
preset_max_width));
}
addVideoShaderOption();
addVideoPresetOption();
options_.push_back(std::make_unique<BoolOption>(
Lang::getText("[SERVICE_MENU] SUPERSAMPLING"),
@@ -459,25 +392,97 @@ void ServiceMenu::initializeOptions() {
SettingsGroup::VIDEO,
&Options::video.integer_scale));
// FILTER: Nearest / Linear (solo visible en el fallback SDL, sin GPU acelerada)
{
std::vector<std::string> filter_values = {"Nearest", "Linear"};
auto filter_getter = []() -> std::string {
return (Options::video.scale_mode == SDL_SCALEMODE_LINEAR) ? "Linear" : "Nearest";
};
auto filter_setter = [](const std::string& val) {
Options::video.scale_mode = (val == "Linear") ? SDL_SCALEMODE_LINEAR : SDL_SCALEMODE_NEAREST;
if (Screen::get() != nullptr) { Screen::get()->applyFilter(); }
};
options_.push_back(std::make_unique<ListOption>(
Lang::getText("[SERVICE_MENU] FILTER"),
SettingsGroup::VIDEO,
filter_values,
filter_getter,
filter_setter));
}
addVideoFilterOption();
}
// AUDIO
void ServiceMenu::addVideoShaderOption() {
std::string disabled_text = Lang::getText("[SERVICE_MENU] SHADER_DISABLED");
std::vector<std::string> shader_values = {disabled_text, "PostFX", "CrtPi"};
auto shader_getter = [disabled_text]() -> std::string {
// NOLINTNEXTLINE(performance-no-automatic-move) -- captura por valor en lambda const, no se puede mover
if (!Options::video.shader.enabled) { return disabled_text; }
return (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) ? "CrtPi" : "PostFX";
};
auto shader_setter = [disabled_text](const std::string& val) {
if (val == disabled_text) {
Options::video.shader.enabled = false;
} else {
Options::video.shader.enabled = true;
const auto TYPE = (val == "CrtPi") ? Rendering::ShaderType::CRTPI : Rendering::ShaderType::POSTFX;
Options::video.shader.current_shader = TYPE;
auto* screen = Screen::get();
if (screen != nullptr) {
screen->applySettings();
}
}
Screen::initShaders();
};
options_.push_back(std::make_unique<ListOption>(
Lang::getText("[SERVICE_MENU] SHADER"),
SettingsGroup::VIDEO,
shader_values,
shader_getter,
shader_setter));
}
void ServiceMenu::addVideoPresetOption() {
auto preset_getter = []() -> std::string {
if (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) {
if (Options::crtpi_presets.empty()) { return ""; }
return Options::crtpi_presets.at(static_cast<size_t>(Options::video.shader.current_crtpi_preset)).name;
}
if (Options::postfx_presets.empty()) { return ""; }
return Options::postfx_presets.at(static_cast<size_t>(Options::video.shader.current_postfx_preset)).name;
};
auto preset_adjuster = [](bool up) {
if (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) {
if (Options::crtpi_presets.empty()) { return; }
const int SIZE = static_cast<int>(Options::crtpi_presets.size());
Options::video.shader.current_crtpi_preset = up
? (Options::video.shader.current_crtpi_preset + 1) % SIZE
: (Options::video.shader.current_crtpi_preset + SIZE - 1) % SIZE;
} else {
if (Options::postfx_presets.empty()) { return; }
const int SIZE = static_cast<int>(Options::postfx_presets.size());
Options::video.shader.current_postfx_preset = up
? (Options::video.shader.current_postfx_preset + 1) % SIZE
: (Options::video.shader.current_postfx_preset + SIZE - 1) % SIZE;
}
Screen::initShaders();
};
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>(
Lang::getText("[SERVICE_MENU] SHADER_PRESET"),
SettingsGroup::VIDEO,
preset_getter,
preset_adjuster,
preset_max_width));
}
void ServiceMenu::addVideoFilterOption() {
// FILTER: Nearest / Linear (solo visible en el fallback SDL, sin GPU acelerada)
std::vector<std::string> filter_values = {"Nearest", "Linear"};
auto filter_getter = []() -> std::string {
return (Options::video.scale_mode == SDL_SCALEMODE_LINEAR) ? "Linear" : "Nearest";
};
auto filter_setter = [](const std::string& val) {
Options::video.scale_mode = (val == "Linear") ? SDL_SCALEMODE_LINEAR : SDL_SCALEMODE_NEAREST;
if (Screen::get() != nullptr) { Screen::get()->applyFilter(); }
};
options_.push_back(std::make_unique<ListOption>(
Lang::getText("[SERVICE_MENU] FILTER"),
SettingsGroup::VIDEO,
filter_values,
filter_getter,
filter_setter));
}
void ServiceMenu::addAudioOptions() {
options_.push_back(std::make_unique<BoolOption>(
Lang::getText("[SERVICE_MENU] AUDIO"),
SettingsGroup::AUDIO,
@@ -500,8 +505,9 @@ void ServiceMenu::initializeOptions() {
SettingsGroup::AUDIO,
&Options::audio.sound.volume,
5));
}
// SETTINGS
void ServiceMenu::addSettingsOptions() {
options_.push_back(std::make_unique<BoolOption>(
Lang::getText("[SERVICE_MENU] AUTOFIRE"),
SettingsGroup::SETTINGS,
@@ -541,8 +547,9 @@ void ServiceMenu::initializeOptions() {
Lang::getText("[SERVICE_MENU] ENABLE_SHUTDOWN"),
SettingsGroup::SETTINGS,
&Options::settings.shutdown_enabled));
}
// SYSTEM
void ServiceMenu::addSystemOptions() {
options_.push_back(std::make_unique<ActionOption>(
Lang::getText("[SERVICE_MENU] RESET"),
SettingsGroup::SYSTEM,
@@ -567,8 +574,9 @@ void ServiceMenu::initializeOptions() {
Section::options = Section::Options::SHUTDOWN;
},
!Options::settings.shutdown_enabled));
}
// MAIN MENU
void ServiceMenu::addMainMenuOptions() {
options_.push_back(std::make_unique<FolderOption>(
Lang::getText("[SERVICE_MENU] CONTROLS"),
SettingsGroup::MAIN,
@@ -593,9 +601,6 @@ void ServiceMenu::initializeOptions() {
Lang::getText("[SERVICE_MENU] SYSTEM"),
SettingsGroup::MAIN,
SettingsGroup::SYSTEM));
// Oculta opciones según configuración
setHiddenOptions();
}
// Sincroniza los valores de las opciones tipo lista
+9 -1
View File
@@ -5,7 +5,6 @@
#include <cstddef> // Para size_t
#include <cstdint> // Para std::uint8_t
#include <functional> // Para function
#include <iterator> // Para pair
#include <memory> // Para unique_ptr
#include <string> // Para basic_string, string
#include <utility> // Para pair
@@ -104,6 +103,15 @@ class ServiceMenu {
void updateDisplayOptions();
void updateOptionPairs();
void initializeOptions();
void addControlsOptions(); // CONTROLS: mandos 1/2, teclat, swap
void addVideoOptions(); // VIDEO: orquestra els blocs de vídeo
void addVideoShaderOption(); // VIDEO: tria de shader (Disabled/PostFX/CrtPi)
void addVideoPresetOption(); // VIDEO: cicla presets del shader actiu
void addVideoFilterOption(); // VIDEO: filtre Nearest/Linear (fallback SDL)
void addAudioOptions(); // AUDIO: enabled + tres volums
void addSettingsOptions(); // SETTINGS: autofire, idioma, dificultat, shutdown
void addSystemOptions(); // SYSTEM: reset, quit, shutdown
void addMainMenuOptions(); // MAIN: carpetes de menú
void updateMenu();
void applySettings();
void applyControlsSettings();
+3 -3
View File
@@ -12,16 +12,16 @@ Actualizando a la versión "Arcade Edition" en 08/05/2024
#include "core/system/director.hpp" // Para Director
SDL_AppResult SDL_AppInit(void** appstate, int /*argc*/, char** /*argv*/) {
auto SDL_AppInit(void** appstate, int /*argc*/, char** /*argv*/) -> SDL_AppResult {
*appstate = new Director();
return SDL_APP_CONTINUE;
}
SDL_AppResult SDL_AppIterate(void* appstate) {
auto SDL_AppIterate(void* appstate) -> SDL_AppResult {
return static_cast<Director*>(appstate)->iterate();
}
SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) {
auto SDL_AppEvent(void* appstate, SDL_Event* event) -> SDL_AppResult {
return static_cast<Director*>(appstate)->handleEvent(*event);
}
+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+