clang-tidy modernize
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_FPoint, SDL_Texture, SDL_Renderer
|
||||
|
||||
#include <array>
|
||||
#include <cstddef> // Para size_t
|
||||
#include <memory> // Para unique_ptr, shared_ptr
|
||||
#include <vector> // Para vector
|
||||
@@ -81,9 +82,9 @@ class Background {
|
||||
SDL_Texture *color_texture_; // Textura para atenuar el fondo
|
||||
|
||||
// Variables de control
|
||||
SDL_FRect gradient_rect_[4];
|
||||
SDL_FRect top_clouds_rect_[4];
|
||||
SDL_FRect bottom_clouds_rect_[4];
|
||||
std::array<SDL_FRect, 4> gradient_rect_;
|
||||
std::array<SDL_FRect, 4> top_clouds_rect_;
|
||||
std::array<SDL_FRect, 4> bottom_clouds_rect_;
|
||||
int gradient_number_ = 0;
|
||||
int alpha_ = 0;
|
||||
float clouds_speed_ = 0;
|
||||
|
||||
@@ -319,8 +319,8 @@ void Balloon::shiftSprite() {
|
||||
|
||||
// Establece el nivel de zoom del sprite
|
||||
void Balloon::zoomSprite() {
|
||||
sprite_->setZoomW(bouncing_.zoom_w);
|
||||
sprite_->setZoomH(bouncing_.zoom_h);
|
||||
sprite_->setZoomW(bouncing_.horizontal_zoom);
|
||||
sprite_->setZoomH(bouncing_.verical_zoom);
|
||||
}
|
||||
|
||||
// Activa el efecto
|
||||
@@ -341,8 +341,8 @@ void Balloon::disableBounce() {
|
||||
void Balloon::updateBounce() {
|
||||
if (bouncing_.enabled) {
|
||||
const int INDEX = bouncing_.counter / bouncing_.speed;
|
||||
bouncing_.zoom_w = bouncing_.w[INDEX];
|
||||
bouncing_.zoom_h = bouncing_.h[INDEX];
|
||||
bouncing_.horizontal_zoom = bouncing_.horizontal_zoom_values[INDEX];
|
||||
bouncing_.verical_zoom = bouncing_.vertical_zoom_values[INDEX];
|
||||
|
||||
zoomSprite();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para Uint8, Uint16, SDL_FRect, Uint32
|
||||
|
||||
#include <array>
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <string> // Para basic_string, string
|
||||
#include <vector> // Para vector
|
||||
@@ -14,12 +15,16 @@ class Texture;
|
||||
// --- Constantes relacionadas con globos ---
|
||||
constexpr int MAX_BOUNCE = 10; // Cantidad de elementos del vector de deformación
|
||||
|
||||
constexpr int BALLOON_SCORE[] = {50, 100, 200, 400};
|
||||
constexpr int BALLOON_POWER[] = {1, 3, 7, 15};
|
||||
constexpr int BALLOON_MENACE[] = {1, 2, 4, 8};
|
||||
constexpr int BALLOON_SIZE[] = {10, 16, 26, 48, 49};
|
||||
const std::string BALLOON_BOUNCING_SOUND[] = {"bubble1.wav", "bubble2.wav", "bubble3.wav", "bubble4.wav"};
|
||||
const std::string BALLOON_POPPING_SOUND[] = {"balloon1.wav", "balloon2.wav", "balloon3.wav", "balloon4.wav"};
|
||||
constexpr std::array<int, 4> BALLOON_SCORE = {50, 100, 200, 400};
|
||||
constexpr std::array<int, 4> BALLOON_POWER = {1, 3, 7, 15};
|
||||
constexpr std::array<int, 4> BALLOON_MENACE = {1, 2, 4, 8};
|
||||
constexpr std::array<int, 5> BALLOON_SIZE = {10, 16, 26, 48, 49};
|
||||
|
||||
const std::array<std::string, 4> BALLOON_BOUNCING_SOUND = {
|
||||
"bubble1.wav", "bubble2.wav", "bubble3.wav", "bubble4.wav"};
|
||||
|
||||
const std::array<std::string, 4> BALLOON_POPPING_SOUND = {
|
||||
"balloon1.wav", "balloon2.wav", "balloon3.wav", "balloon4.wav"};
|
||||
|
||||
enum class BalloonSize : Uint8 {
|
||||
SIZE1 = 0,
|
||||
@@ -41,7 +46,7 @@ constexpr int BALLOON_MOVING_ANIMATION = 0;
|
||||
constexpr int BALLOON_POP_ANIMATION = 1;
|
||||
constexpr int BALLOON_BORN_ANIMATION = 2;
|
||||
|
||||
constexpr float BALLOON_SPEED[] = {0.60f, 0.70f, 0.80f, 0.90f, 1.00f};
|
||||
constexpr std::array<float, 5> BALLOON_SPEED = {0.60f, 0.70f, 0.80f, 0.90f, 1.00f};
|
||||
|
||||
constexpr int POWERBALL_SCREENPOWER_MINIMUM = 10;
|
||||
constexpr int POWERBALL_COUNTER = 8;
|
||||
@@ -109,19 +114,19 @@ class Balloon {
|
||||
bool enabled = false; // Si el efecto está activo
|
||||
Uint8 counter = 0; // Contador para el efecto
|
||||
Uint8 speed = 2; // Velocidad del efecto
|
||||
float zoom_w = 1.0f; // Zoom en anchura
|
||||
float zoom_h = 1.0f; // Zoom en altura
|
||||
float horizontal_zoom = 1.0f; // Zoom en anchura
|
||||
float verical_zoom = 1.0f; // Zoom en altura
|
||||
float desp_x = 0.0f; // Desplazamiento X antes de pintar
|
||||
float desp_y = 0.0f; // Desplazamiento Y antes de pintar
|
||||
|
||||
float w[MAX_BOUNCE] = {1.10f, 1.05f, 1.00f, 0.95f, 0.90f, 0.95f, 1.00f, 1.02f, 1.05f, 1.02f}; // Zoom ancho
|
||||
float h[MAX_BOUNCE] = {0.90f, 0.95f, 1.00f, 1.05f, 1.10f, 1.05f, 1.00f, 0.98f, 0.95f, 0.98f}; // Zoom alto
|
||||
std::array<float, MAX_BOUNCE> horizontal_zoom_values = {1.10f, 1.05f, 1.00f, 0.95f, 0.90f, 0.95f, 1.00f, 1.02f, 1.05f, 1.02f}; // Zoom ancho
|
||||
std::array<float, MAX_BOUNCE> vertical_zoom_values = {0.90f, 0.95f, 1.00f, 1.05f, 1.10f, 1.05f, 1.00f, 0.98f, 0.95f, 0.98f}; // Zoom alto
|
||||
|
||||
Bouncing() = default;
|
||||
void reset() {
|
||||
counter = 0;
|
||||
zoom_w = 1.0f;
|
||||
zoom_h = 1.0f;
|
||||
horizontal_zoom = 1.0f;
|
||||
verical_zoom = 1.0f;
|
||||
desp_x = 0.0f;
|
||||
desp_y = 0.0f;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "balloon_manager.h"
|
||||
|
||||
#include <algorithm> // Para remove_if
|
||||
#include <array>
|
||||
#include <cstdlib> // Para rand
|
||||
#include <numeric> // Para accumulate
|
||||
|
||||
@@ -209,8 +210,8 @@ void BalloonManager::createPowerBall() {
|
||||
const float RIGHT = param.game.play_area.rect.w - BALLOON_SIZE[4];
|
||||
|
||||
const int LUCK = rand() % VALUES;
|
||||
const float POS_X[VALUES] = {LEFT, LEFT, CENTER, CENTER, RIGHT, RIGHT};
|
||||
const float VEL_X[VALUES] = {BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE};
|
||||
const std::array<float, VALUES> POS_X = {LEFT, LEFT, CENTER, CENTER, RIGHT, RIGHT};
|
||||
const std::array<float, VALUES> VEL_X = {BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE};
|
||||
|
||||
balloons_.emplace_back(std::make_unique<Balloon>(POS_X[LUCK], POS_Y, BalloonType::POWERBALL, BalloonSize::SIZE4, VEL_X[LUCK], balloon_speed_, CREATION_TIME, play_area_, balloon_textures_[4], balloon_animations_[4]));
|
||||
balloons_.back()->setInvulnerable(true);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <cstdlib> // Para exit, EXIT_FAILURE, size_t, srand
|
||||
#include <ctime> // Para time
|
||||
#include <memory> // Para make_unique, unique_ptr
|
||||
#include <span>
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <string> // Para operator+, basic_string, allocator
|
||||
#include <vector> // Para vector
|
||||
@@ -41,7 +42,7 @@
|
||||
#endif
|
||||
|
||||
// Constructor
|
||||
Director::Director(int argc, const char *argv[]) {
|
||||
Director::Director(int argc, std::span<char *> argv) {
|
||||
#ifdef RECORDING
|
||||
Section::name = Section::Name::GAME;
|
||||
Section::options = Section::Options::GAME_PLAY_1P;
|
||||
@@ -434,7 +435,7 @@ void Director::setFileList() {
|
||||
}
|
||||
|
||||
// Comprueba los parametros del programa
|
||||
void Director::checkProgramArguments(int argc, const char *argv[]) {
|
||||
void Director::checkProgramArguments(int argc, std::span<char *> argv) {
|
||||
// Establece la ruta del programa
|
||||
executable_path_ = getPath(argv[0]);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string> // Para manejar cadenas de texto
|
||||
#include <span>
|
||||
|
||||
namespace Lang {
|
||||
enum class Code : int;
|
||||
@@ -9,7 +10,7 @@ enum class Code : int;
|
||||
class Director {
|
||||
public:
|
||||
// --- Constructor y destructor ---
|
||||
Director(int argc, const char *argv[]);
|
||||
Director(int argc, std::span<char*> argv);
|
||||
~Director();
|
||||
|
||||
// --- Bucle principal ---
|
||||
@@ -32,7 +33,7 @@ private:
|
||||
// --- Gestión de entrada y archivos ---
|
||||
void bindInputs(); // Asigna botones y teclas al sistema de entrada
|
||||
void setFileList(); // Crea el índice de archivos disponibles
|
||||
void checkProgramArguments(int argc, const char *argv[]); // Verifica los parámetros del programa
|
||||
void checkProgramArguments(int argc, std::span<char*> argv); // Verifica los parámetros del programa // NOLINT(modernize-avoid-c-arrays)
|
||||
|
||||
// --- Secciones del programa ---
|
||||
void runLogo(); // Ejecuta la pantalla con el logo
|
||||
|
||||
3
source/external/.clang-tidy
vendored
3
source/external/.clang-tidy
vendored
@@ -1 +1,4 @@
|
||||
# source/external/.clang-tidy
|
||||
Checks: '-*'
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
@@ -13,7 +13,7 @@ Actualizando a la versión "Arcade Edition" en 08/05/2024
|
||||
|
||||
auto main(int argc, char* argv[]) -> int {
|
||||
// Crea el objeto Director
|
||||
auto director = std::make_unique<Director>(argc, const_cast<const char **>(argv));
|
||||
auto director = std::make_unique<Director>(argc, std::span<char*>(argv, argc));
|
||||
|
||||
// Bucle principal
|
||||
return director->run();
|
||||
|
||||
@@ -60,9 +60,7 @@ struct MusicOptions {
|
||||
int volume{100}; // Volumen de la música
|
||||
|
||||
// Constructor por defecto
|
||||
MusicOptions()
|
||||
|
||||
{}
|
||||
MusicOptions() = default;
|
||||
};
|
||||
|
||||
// --- Opciones de sonido ---
|
||||
@@ -71,9 +69,7 @@ struct SoundOptions {
|
||||
int volume{100}; // Volumen de los sonidos
|
||||
|
||||
// Constructor por defecto
|
||||
SoundOptions()
|
||||
|
||||
{}
|
||||
SoundOptions() = default;
|
||||
};
|
||||
|
||||
// --- Opciones de audio ---
|
||||
@@ -125,9 +121,7 @@ struct GamepadOptions {
|
||||
GamepadOptions()
|
||||
: index(INVALID_INDEX),
|
||||
player_id(INVALID_INDEX),
|
||||
|
||||
name(),
|
||||
|
||||
inputs{
|
||||
InputAction::FIRE_LEFT,
|
||||
InputAction::FIRE_CENTER,
|
||||
@@ -149,9 +143,7 @@ struct PendingChanges {
|
||||
bool has_pending_changes{false}; // Indica si hay cambios pendientes
|
||||
|
||||
// Constructor por defecto con valores iniciales
|
||||
PendingChanges()
|
||||
|
||||
{}
|
||||
PendingChanges() = default;
|
||||
};
|
||||
|
||||
// --- Variables globales ---
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_FPoint, SDL_GetTicks, SDL_FRect, SDL_Texture, SDL_Renderer, Uint64
|
||||
|
||||
#include <array>
|
||||
#include <cstddef> // Para size_t
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <string> // Para basic_string, string
|
||||
@@ -76,13 +77,14 @@ class Scoreboard {
|
||||
std::vector<SDL_Texture *> panel_texture_; // Texturas para dibujar cada panel
|
||||
|
||||
// --- Variables de estado ---
|
||||
std::string name_[SCOREBOARD_MAX_PANELS] = {}; // Nombre de cada jugador
|
||||
std::string record_name_[SCOREBOARD_MAX_PANELS] = {}; // Nombre introducido para la tabla de records
|
||||
size_t selector_pos_[SCOREBOARD_MAX_PANELS] = {}; // Posición del selector de letra para introducir el nombre
|
||||
int score_[SCOREBOARD_MAX_PANELS] = {}; // Puntuación de los jugadores
|
||||
float mult_[SCOREBOARD_MAX_PANELS] = {}; // Multiplicador de los jugadores
|
||||
int continue_counter_[SCOREBOARD_MAX_PANELS] = {}; // Tiempo para continuar de los jugadores
|
||||
Panel panel_[SCOREBOARD_MAX_PANELS] = {}; // Lista con todos los paneles del marcador
|
||||
std::array<std::string, SCOREBOARD_MAX_PANELS> name_ = {}; // Nombre de cada jugador
|
||||
std::array<std::string, SCOREBOARD_MAX_PANELS> record_name_ = {}; // Nombre introducido para la tabla de records
|
||||
std::array<size_t, SCOREBOARD_MAX_PANELS> selector_pos_ = {}; // Posición del selector de letra para introducir el nombre
|
||||
std::array<int, SCOREBOARD_MAX_PANELS> score_ = {}; // Puntuación de los jugadores
|
||||
std::array<float, SCOREBOARD_MAX_PANELS> mult_ = {}; // Multiplicador de los jugadores
|
||||
std::array<int, SCOREBOARD_MAX_PANELS> continue_counter_ = {}; // Tiempo para continuar de los jugadores
|
||||
std::array<Panel, SCOREBOARD_MAX_PANELS> panel_ = {}; // Lista con todos los paneles del marcador
|
||||
|
||||
int stage_ = 1; // Número de fase actual
|
||||
int hi_score_ = 0; // Máxima puntuación
|
||||
float power_ = 0; // Poder actual de la fase
|
||||
|
||||
@@ -70,7 +70,7 @@ class Screen {
|
||||
int frame_count{0}; // Número acumulado de frames en el intervalo.
|
||||
int last_value{0}; // Número de frames calculado en el último segundo.
|
||||
|
||||
FPS() {}
|
||||
FPS() = default;
|
||||
void increment() { frame_count++; }
|
||||
auto calculate(Uint32 current_ticks) -> int {
|
||||
if (current_ticks - ticks >= 1000) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <cmath> // Para abs
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <string> // Para basic_string, string
|
||||
#include <string_view>
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "audio.h" // Para Audio
|
||||
@@ -30,7 +31,8 @@
|
||||
#include "utils.h" // Para Color, Zone, SHADOW_TEXT_COLOR, NO_TEXT...
|
||||
|
||||
// Textos
|
||||
constexpr const char TEXT_COPYRIGHT[] = "@2020,2025 JailDesigner";
|
||||
constexpr std::string_view TEXT_COPYRIGHT = "@2020,2025 JailDesigner";
|
||||
|
||||
|
||||
// Constructor
|
||||
Credits::Credits()
|
||||
@@ -218,7 +220,7 @@ void Credits::fillTextTexture() {
|
||||
|
||||
// Texto con el copyright
|
||||
y += mini_logo_sprite->getHeight() + 3;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXT_COPYRIGHT, 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, std::string(TEXT_COPYRIGHT), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
|
||||
// Resetea el renderizador
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderTarget
|
||||
|
||||
#include <array>
|
||||
#include <algorithm> // Para find_if, clamp, find, min
|
||||
#include <cstdlib> // Para rand, size_t
|
||||
#include <functional> // Para function
|
||||
@@ -1404,7 +1405,7 @@ void Game::initDemo(int player_id) {
|
||||
{
|
||||
constexpr auto NUM_DEMOS = 3;
|
||||
const auto DEMO = rand() % NUM_DEMOS;
|
||||
const int STAGES[NUM_DEMOS] = {0, 3, 5};
|
||||
constexpr std::array<int, NUM_DEMOS> STAGES = {0, 3, 5};
|
||||
Stage::number = STAGES[DEMO];
|
||||
}
|
||||
|
||||
@@ -1695,7 +1696,7 @@ void Game::checkAndUpdateBalloonSpeed() {
|
||||
return;
|
||||
|
||||
const float PERCENT = static_cast<float>(Stage::power) / Stage::get(Stage::number).power_to_complete;
|
||||
const float THRESHOLDS[] = {0.2f, 0.4f, 0.6f, 0.8f};
|
||||
constexpr std::array<float, 4> THRESHOLDS = {0.2f, 0.4f, 0.6f, 0.8f};
|
||||
|
||||
for (size_t i = 0; i < std::size(THRESHOLDS); ++i) {
|
||||
if (balloon_manager_->getBalloonSpeed() == BALLOON_SPEED[i] && PERCENT > THRESHOLDS[i]) {
|
||||
|
||||
@@ -433,7 +433,7 @@ void Title::renderCopyright() {
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW,
|
||||
param.game.game_area.center_x,
|
||||
anchor_.copyright_text,
|
||||
TEXT_COPYRIGHT,
|
||||
std::string(TEXT_COPYRIGHT),
|
||||
1,
|
||||
NO_TEXT_COLOR,
|
||||
1,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <memory> // Para unique_ptr, shared_ptr
|
||||
#include <vector>
|
||||
#include <string_view>
|
||||
|
||||
#include "section.h" // Para Options
|
||||
|
||||
@@ -16,7 +17,8 @@ class Text;
|
||||
class TiledBG;
|
||||
|
||||
// Textos
|
||||
constexpr const char TEXT_COPYRIGHT[] = "@2020,2025 JailDesigner";
|
||||
constexpr std::string_view TEXT_COPYRIGHT = "@2020,2025 JailDesigner";
|
||||
|
||||
|
||||
// Parámetros
|
||||
constexpr bool ALLOW_TITLE_ANIMATION_SKIP = false;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <SDL3/SDL.h> // Para SDL_FlipMode, SDL_GetTicks
|
||||
|
||||
#include <algorithm> // Para max
|
||||
#include <array>
|
||||
#include <cmath> // Para abs
|
||||
#include <cstdlib> // Para rand, abs
|
||||
#include <string> // Para basic_string
|
||||
@@ -81,9 +82,22 @@ void Tabe::move() {
|
||||
--waiting_counter_;
|
||||
} else {
|
||||
constexpr int CHOICES = 4;
|
||||
const TabeDirection LEFT[CHOICES] = {TabeDirection::TO_THE_LEFT, TabeDirection::TO_THE_LEFT, TabeDirection::TO_THE_LEFT, TabeDirection::TO_THE_RIGHT};
|
||||
const TabeDirection RIGHT[CHOICES] = {TabeDirection::TO_THE_LEFT, TabeDirection::TO_THE_RIGHT, TabeDirection::TO_THE_RIGHT, TabeDirection::TO_THE_RIGHT};
|
||||
const TabeDirection DIRECTION = destiny_ == TabeDirection::TO_THE_LEFT ? LEFT[rand() % CHOICES] : RIGHT[rand() % CHOICES];
|
||||
const std::array<TabeDirection, CHOICES> LEFT = {
|
||||
TabeDirection::TO_THE_LEFT,
|
||||
TabeDirection::TO_THE_LEFT,
|
||||
TabeDirection::TO_THE_LEFT,
|
||||
TabeDirection::TO_THE_RIGHT};
|
||||
|
||||
const std::array<TabeDirection, CHOICES> RIGHT = {
|
||||
TabeDirection::TO_THE_LEFT,
|
||||
TabeDirection::TO_THE_RIGHT,
|
||||
TabeDirection::TO_THE_RIGHT,
|
||||
TabeDirection::TO_THE_RIGHT};
|
||||
|
||||
const TabeDirection DIRECTION = destiny_ == TabeDirection::TO_THE_LEFT
|
||||
? LEFT[rand() % CHOICES]
|
||||
: RIGHT[rand() % CHOICES];
|
||||
|
||||
setRandomFlyPath(DIRECTION, 20 + rand() % 40);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para Uint8
|
||||
|
||||
#include <array>
|
||||
#include <memory> // Para unique_ptr, shared_ptr
|
||||
#include <string> // Para string
|
||||
|
||||
@@ -24,7 +25,7 @@ struct TextOffset {
|
||||
struct TextFile {
|
||||
int box_width; // Anchura de la caja de cada caracter en el png
|
||||
int box_height; // Altura de la caja de cada caracter en el png
|
||||
TextOffset offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||
std::array<TextOffset, 128> offset = {}; // Vector con las posiciones y ancho de cada letra
|
||||
};
|
||||
|
||||
// Llena una estructura TextFile desde un fichero
|
||||
@@ -68,5 +69,6 @@ class Text {
|
||||
int box_width_ = 0; // Anchura de la caja de cada caracter en el png
|
||||
int box_height_ = 0; // Altura de la caja de cada caracter en el png
|
||||
bool fixed_width_ = false; // Indica si el texto se ha de escribir con longitud fija en todas las letras
|
||||
TextOffset offset_[128] = {}; // Vector con las posiciones y ancho de cada letra
|
||||
std::array<TextOffset, 128> offset_ = {};
|
||||
; // Vector con las posiciones y ancho de cada letra
|
||||
};
|
||||
@@ -240,7 +240,7 @@ auto Texture::loadSurface(const std::string &file_path) -> std::shared_ptr<Surfa
|
||||
|
||||
// Si el constructor de Surface espera un std::shared_ptr<Uint8[]>:
|
||||
size_t pixel_count = raw_pixels.size();
|
||||
auto pixels = std::shared_ptr<Uint8[]>(new Uint8[pixel_count], std::default_delete<Uint8[]>());
|
||||
auto pixels = std::shared_ptr<Uint8[]>(new Uint8[pixel_count], std::default_delete<Uint8[]>()); // NOLINT(modernize-avoid-c-arrays)
|
||||
std::memcpy(pixels.get(), raw_pixels.data(), pixel_count);
|
||||
|
||||
auto surface = std::make_shared<Surface>(w, h, pixels);
|
||||
|
||||
@@ -16,11 +16,11 @@ using Palette = std::array<Uint32, 256>;
|
||||
|
||||
// Definición de Surface para imágenes con paleta
|
||||
struct Surface {
|
||||
std::shared_ptr<Uint8[]> data;
|
||||
std::shared_ptr<Uint8[]> data; // NOLINT(modernize-avoid-c-arrays)
|
||||
Uint16 w, h;
|
||||
|
||||
// Constructor
|
||||
Surface(Uint16 width, Uint16 height, std::shared_ptr<Uint8[]> pixels)
|
||||
Surface(Uint16 width, Uint16 height, std::shared_ptr<Uint8[]> pixels) // NOLINT(modernize-avoid-c-arrays)
|
||||
: data(std::move(pixels)), w(width), h(height) {}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_SetTextureColorMod, SDL_Renderer, SDL_Texture
|
||||
#include <array>
|
||||
|
||||
#include "utils.h" // Para Color
|
||||
|
||||
@@ -50,7 +51,7 @@ private:
|
||||
SDL_FRect pos_; // Posición y tamaño del mosaico
|
||||
SDL_FRect window_; // Ventana visible para la textura de fondo del título
|
||||
TiledBGMode mode_; // Tipo de movimiento del mosaico
|
||||
double sin_[360]; // Vector con los valores del seno precalculados
|
||||
std::array<double, 360> sin_; // Vector con los valores del seno precalculados
|
||||
float desp_ = 0.0f; // Desplazamiento aplicado
|
||||
float speed_ = 1.0f; // Incremento que se añade al desplazamiento a cada bucle
|
||||
bool stopping_ = false; // Indica si se está deteniendo
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_FRect, Uint32
|
||||
|
||||
#include <array>
|
||||
#include <cstddef> // Para size_t
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <vector> // Para vector
|
||||
@@ -56,7 +57,7 @@ private:
|
||||
bool resizing_ = false;
|
||||
|
||||
// --- Anchos precalculados ---
|
||||
int group_menu_widths_[5]{};
|
||||
std::array<int, 5> group_menu_widths_ = {};
|
||||
|
||||
// --- Métodos privados de la vista ---
|
||||
void setAnchors(const ServiceMenu *menu_state);
|
||||
|
||||
@@ -31,10 +31,14 @@ class ServiceMenu {
|
||||
static constexpr size_t MIN_WIDTH = 240;
|
||||
static constexpr size_t MIN_GAP_OPTION_VALUE = 30;
|
||||
|
||||
// --- Métodos de singleton ---
|
||||
static void init();
|
||||
static void destroy();
|
||||
static auto get() -> ServiceMenu *;
|
||||
ServiceMenu(const ServiceMenu &) = delete;
|
||||
auto operator=(const ServiceMenu &) -> ServiceMenu & = delete;
|
||||
|
||||
// --- Métodos principales ---
|
||||
void toggle();
|
||||
void render();
|
||||
void update();
|
||||
@@ -96,10 +100,10 @@ private:
|
||||
[[nodiscard]] auto settingsGroupToString(SettingsGroup group) const -> std::string;
|
||||
void setHiddenOptions();
|
||||
|
||||
// --- Singleton ---
|
||||
// --- Constructores y destructor privados (singleton) ---
|
||||
ServiceMenu();
|
||||
~ServiceMenu() = default;
|
||||
ServiceMenu(const ServiceMenu &) = delete;
|
||||
auto operator=(const ServiceMenu &) -> ServiceMenu & = delete;
|
||||
|
||||
// --- Instancia singleton ---
|
||||
static ServiceMenu *instance;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user