neteja tidy: ranges::fill, default member init, NOLINT _USE_MATH_DEFINES
This commit is contained in:
@@ -259,7 +259,7 @@ namespace Ja {
|
||||
sdl_audio_device = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &audio_spec);
|
||||
if (sdl_audio_device == 0) { std::cout << "Failed to initialize SDL audio!" << '\n'; }
|
||||
for (auto& ch : channels) { ch.state = ChannelState::FREE; }
|
||||
std::fill(std::begin(sound_volume), std::end(sound_volume), 0.5F);
|
||||
std::ranges::fill(sound_volume, 0.5F);
|
||||
}
|
||||
|
||||
inline void quit() {
|
||||
@@ -663,7 +663,7 @@ namespace Ja {
|
||||
const float V = SDL_clamp(volume, 0.0F, 1.0F);
|
||||
|
||||
if (group == -1) {
|
||||
std::fill(std::begin(sound_volume), std::end(sound_volume), V);
|
||||
std::ranges::fill(sound_volume, V);
|
||||
} else if (group >= 0 && group < MAX_GROUPS) {
|
||||
sound_volume[group] = V;
|
||||
} else {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// NOLINTNEXTLINE(bugprone-reserved-identifier) -- requerido por <cmath> para exponer M_PI en MSVC
|
||||
#define _USE_MATH_DEFINES
|
||||
#include "core/rendering/background.hpp"
|
||||
|
||||
|
||||
@@ -17,16 +17,13 @@
|
||||
#ifndef NO_SHADERS
|
||||
#include "core/rendering/sdl3gpu/sdl3gpu_shader.hpp" // Para SDL3GPUShader
|
||||
#endif
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/rendering/texture.hpp" // Para Texture
|
||||
#include "core/resources/asset.hpp" // Para Asset
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "core/system/director.hpp" // Para Director::debug_config
|
||||
#include "game/options.hpp" // Para Video, video, Window, window
|
||||
#include "game/ui/notifier.hpp" // Para Notifier
|
||||
#include "game/ui/service_menu.hpp" // Para ServiceMenu
|
||||
#include "utils/param.hpp" // Para Param, param, ParamGame, ParamDebug
|
||||
#include "utils/utils.hpp" // Para toLower
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/rendering/texture.hpp" // Para Texture
|
||||
#include "core/resources/asset.hpp" // Para Asset
|
||||
#include "game/options.hpp" // Para Video, video, Window, window
|
||||
#include "game/ui/notifier.hpp" // Para Notifier
|
||||
#include "game/ui/service_menu.hpp" // Para ServiceMenu
|
||||
#include "utils/param.hpp" // Para Param, param, ParamGame, ParamDebug
|
||||
|
||||
// Singleton
|
||||
Screen* Screen::instance = nullptr;
|
||||
@@ -82,12 +79,7 @@ auto Screen::get() -> Screen* { return Screen::instance; }
|
||||
|
||||
// Constructor
|
||||
Screen::Screen()
|
||||
: window_(nullptr),
|
||||
renderer_(nullptr),
|
||||
game_canvas_(nullptr),
|
||||
service_menu_(nullptr),
|
||||
notifier_(nullptr),
|
||||
src_rect_(SDL_FRect{.x = 0, .y = 0, .w = param.game.width, .h = param.game.height}),
|
||||
: src_rect_(SDL_FRect{.x = 0, .y = 0, .w = param.game.width, .h = param.game.height}),
|
||||
dst_rect_(SDL_FRect{.x = 0, .y = 0, .w = param.game.width, .h = param.game.height}) {
|
||||
// Arranca SDL VIDEO, crea la ventana y el renderizador
|
||||
initSDLVideo();
|
||||
|
||||
@@ -214,11 +214,11 @@ class Screen {
|
||||
#endif
|
||||
|
||||
// --- Objetos y punteros ---
|
||||
SDL_Window* window_; // Ventana de la aplicación
|
||||
SDL_Renderer* renderer_; // El renderizador de la ventana
|
||||
SDL_Texture* game_canvas_; // Textura donde se dibuja todo antes de volcarse al renderizador
|
||||
ServiceMenu* service_menu_; // Objeto para mostrar el menú de servicio
|
||||
Notifier* notifier_; // Objeto para mostrar las notificaciones por pantalla
|
||||
SDL_Window* window_ = nullptr; // Ventana de la aplicación
|
||||
SDL_Renderer* renderer_ = nullptr; // El renderizador de la ventana
|
||||
SDL_Texture* game_canvas_ = nullptr; // Textura donde se dibuja todo antes de volcarse al renderizador
|
||||
ServiceMenu* service_menu_ = nullptr; // Objeto para mostrar el menú de servicio
|
||||
Notifier* notifier_ = nullptr; // Objeto para mostrar las notificaciones por pantalla
|
||||
std::shared_ptr<Text> text_; // Objeto para escribir texto en pantalla
|
||||
std::unique_ptr<Rendering::ShaderBackend> shader_backend_; // Backend de shaders (SDL3GPU)
|
||||
|
||||
@@ -236,20 +236,20 @@ class Screen {
|
||||
#endif
|
||||
|
||||
// --- Métodos internos ---
|
||||
auto initSDLVideo() -> bool; // Arranca SDL VIDEO y crea la ventana
|
||||
void registerEmscriptenEventCallbacks(); // Registra callbacks nativos para restaurar el canvas en wasm (no-op fuera de emscripten)
|
||||
void renderFlash(); // Dibuja el efecto de flash en la pantalla
|
||||
void renderShake(); // Aplica el efecto de agitar la pantalla
|
||||
void renderInfo() const; // Muestra información por pantalla
|
||||
auto initSDLVideo() -> bool; // Arranca SDL VIDEO y crea la ventana
|
||||
void registerEmscriptenEventCallbacks(); // Registra callbacks nativos para restaurar el canvas en wasm (no-op fuera de emscripten)
|
||||
void renderFlash(); // Dibuja el efecto de flash en la pantalla
|
||||
void renderShake(); // Aplica el efecto de agitar la pantalla
|
||||
void renderInfo() const; // Muestra información por pantalla
|
||||
[[nodiscard]] auto buildDebugInfoText() const -> std::string; // Compone fps + driver + shader/preset para renderInfo
|
||||
void renderPresent(); // Selecciona y ejecuta el método de renderizado adecuado
|
||||
void applyCurrentPostFXPreset(); // Aplica el preset PostFX activo al backend
|
||||
void applyCurrentCrtPiPreset(); // Aplica el preset CrtPi activo al backend
|
||||
void adjustWindowSize(); // Calcula el tamaño de la ventana
|
||||
void getDisplayInfo(); // Obtiene información sobre la pantalla
|
||||
void renderOverlays(); // Renderiza todos los overlays y efectos
|
||||
void renderAttenuate(); // Atenúa la pantalla
|
||||
void createText(); // Crea el objeto de texto
|
||||
void renderPresent(); // Selecciona y ejecuta el método de renderizado adecuado
|
||||
void applyCurrentPostFXPreset(); // Aplica el preset PostFX activo al backend
|
||||
void applyCurrentCrtPiPreset(); // Aplica el preset CrtPi activo al backend
|
||||
void adjustWindowSize(); // Calcula el tamaño de la ventana
|
||||
void getDisplayInfo(); // Obtiene información sobre la pantalla
|
||||
void renderOverlays(); // Renderiza todos los overlays y efectos
|
||||
void renderAttenuate(); // Atenúa la pantalla
|
||||
void createText(); // Crea el objeto de texto
|
||||
|
||||
// --- Constructores y destructor privados (singleton) ---
|
||||
Screen(); // Constructor privado
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
|
||||
std::unique_ptr<ResourceLoader> ResourceLoader::instance = nullptr;
|
||||
|
||||
ResourceLoader::ResourceLoader()
|
||||
: resource_pack_(nullptr),
|
||||
fallback_to_files_(true) {}
|
||||
ResourceLoader::ResourceLoader() = default;
|
||||
|
||||
auto ResourceLoader::getInstance() -> ResourceLoader& {
|
||||
if (!instance) {
|
||||
|
||||
@@ -11,9 +11,9 @@ class ResourcePack;
|
||||
class ResourceLoader {
|
||||
private:
|
||||
static std::unique_ptr<ResourceLoader> instance;
|
||||
ResourcePack* resource_pack_;
|
||||
ResourcePack* resource_pack_ = nullptr;
|
||||
std::string pack_path_;
|
||||
bool fallback_to_files_;
|
||||
bool fallback_to_files_ = true;
|
||||
|
||||
ResourceLoader();
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
|
||||
const std::string ResourcePack::DEFAULT_ENCRYPT_KEY = "CCAE_RESOURCES__2024";
|
||||
|
||||
ResourcePack::ResourcePack()
|
||||
: loaded_(false) {}
|
||||
ResourcePack::ResourcePack() = default;
|
||||
|
||||
ResourcePack::~ResourcePack() {
|
||||
clear();
|
||||
|
||||
@@ -17,7 +17,7 @@ class ResourcePack {
|
||||
private:
|
||||
std::unordered_map<std::string, ResourceEntry> resources_;
|
||||
std::vector<uint8_t> data_;
|
||||
bool loaded_;
|
||||
bool loaded_ = false;
|
||||
|
||||
static auto calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t;
|
||||
static void encryptData(std::vector<uint8_t>& data, const std::string& key);
|
||||
|
||||
@@ -9,19 +9,13 @@
|
||||
|
||||
// Implementación de StageData
|
||||
StageData::StageData(int power_to_complete, int min_menace, int max_menace, std::string name)
|
||||
: status_(StageStatus::LOCKED),
|
||||
name_(std::move(name)),
|
||||
: name_(std::move(name)),
|
||||
power_to_complete_(power_to_complete),
|
||||
min_menace_(min_menace),
|
||||
max_menace_(max_menace) {}
|
||||
|
||||
// Implementación de StageManager
|
||||
StageManager::StageManager()
|
||||
: power_change_callback_(nullptr),
|
||||
power_collection_state_(PowerCollectionState::ENABLED),
|
||||
current_stage_index_(0),
|
||||
current_power_(0),
|
||||
total_power_(0) { initialize(); }
|
||||
StageManager::StageManager() { initialize(); }
|
||||
|
||||
void StageManager::initialize() {
|
||||
stages_.clear();
|
||||
|
||||
@@ -40,11 +40,11 @@ class StageData {
|
||||
|
||||
private:
|
||||
// --- Variables de estado ---
|
||||
StageStatus status_; // Estado actual de la fase
|
||||
std::string name_; // Nombre de la fase
|
||||
int power_to_complete_; // Poder necesario para completar la fase
|
||||
int min_menace_; // Nivel mínimo de amenaza
|
||||
int max_menace_; // Nivel máximo de amenaza
|
||||
StageStatus status_ = StageStatus::LOCKED; // Estado actual de la fase
|
||||
std::string name_; // Nombre de la fase
|
||||
int power_to_complete_; // Poder necesario para completar la fase
|
||||
int min_menace_; // Nivel mínimo de amenaza
|
||||
int max_menace_; // Nivel máximo de amenaza
|
||||
};
|
||||
|
||||
// --- Clase StageManager: gestor principal del sistema de fases del juego ---
|
||||
@@ -100,12 +100,12 @@ class StageManager : public IStageInfo {
|
||||
|
||||
private:
|
||||
// --- Variables de estado ---
|
||||
std::vector<StageData> stages_; // Lista de todas las fases
|
||||
PowerChangeCallback power_change_callback_; // Callback para notificar cambios de poder
|
||||
PowerCollectionState power_collection_state_; // Estado de recolección de poder
|
||||
size_t current_stage_index_; // Índice de la fase actual
|
||||
int current_power_; // Poder actual en la fase activa
|
||||
int total_power_; // Poder total acumulado en todo el juego
|
||||
std::vector<StageData> stages_; // Lista de todas las fases
|
||||
PowerChangeCallback power_change_callback_; // Callback para notificar cambios de poder
|
||||
PowerCollectionState power_collection_state_ = PowerCollectionState::ENABLED; // Estado de recolección de poder
|
||||
size_t current_stage_index_ = 0; // Índice de la fase actual
|
||||
int current_power_ = 0; // Poder actual en la fase activa
|
||||
int total_power_ = 0; // Poder total acumulado en todo el juego
|
||||
|
||||
// --- Métodos internos ---
|
||||
void createDefaultStages(); // Crea las fases predeterminadas del juego
|
||||
|
||||
@@ -36,7 +36,6 @@ HiScoreTable::HiScoreTable()
|
||||
background_(std::make_unique<Background>()),
|
||||
|
||||
view_area_(SDL_FRect{.x = 0, .y = 0, .w = param.game.width, .h = param.game.height}),
|
||||
fade_mode_(Fade::Mode::IN),
|
||||
background_fade_color_(Color(0, 0, 0)) {
|
||||
// Inicializa el resto
|
||||
Section::name = Section::Name::HI_SCORE_TABLE;
|
||||
|
||||
@@ -55,12 +55,12 @@ class HiScoreTable {
|
||||
std::vector<Path> paths_; // Vector con los recorridos precalculados
|
||||
|
||||
// --- Variables ---
|
||||
float elapsed_time_ = 0.0F; // Tiempo transcurrido (segundos)
|
||||
Uint64 last_time_ = 0; // Último timestamp para calcular delta-time
|
||||
SDL_FRect view_area_; // Parte de la textura que se muestra en pantalla
|
||||
Fade::Mode fade_mode_; // Modo de fade a utilizar
|
||||
Color background_fade_color_; // Color de atenuación del fondo
|
||||
std::vector<Color> entry_colors_; // Colores para destacar las entradas en la tabla
|
||||
float elapsed_time_ = 0.0F; // Tiempo transcurrido (segundos)
|
||||
Uint64 last_time_ = 0; // Último timestamp para calcular delta-time
|
||||
SDL_FRect view_area_; // Parte de la textura que se muestra en pantalla
|
||||
Fade::Mode fade_mode_ = Fade::Mode::IN; // Modo de fade a utilizar
|
||||
Color background_fade_color_; // Color de atenuación del fondo
|
||||
std::vector<Color> entry_colors_; // Colores para destacar las entradas en la tabla
|
||||
|
||||
// --- Flags para eventos basados en tiempo ---
|
||||
struct HiScoreFlags {
|
||||
|
||||
@@ -35,7 +35,6 @@ Title::Title()
|
||||
tiled_bg_(std::make_unique<TiledBG>(param.game.game_area.rect, TiledBGMode::RANDOM)),
|
||||
game_logo_(std::make_unique<GameLogo>(param.game.game_area.center_x, param.title.title_c_c_position)),
|
||||
mini_logo_sprite_(std::make_unique<Sprite>(Resource::get()->getTexture("logo_jailgames_mini.png"))),
|
||||
state_(State::LOGO_ANIMATING),
|
||||
num_controllers_(Input::get()->getNumGamepads()) {
|
||||
// Configura objetos
|
||||
tiled_bg_->setColor(param.title.bg_color);
|
||||
|
||||
@@ -94,7 +94,7 @@ class Title {
|
||||
Anchor anchor_; // Anclas para definir la posición de los elementos del título
|
||||
Section::Name next_section_; // Siguiente sección a cargar
|
||||
Section::Options selection_ = Section::Options::TITLE_TIME_OUT; // Opción elegida en el título
|
||||
State state_; // Estado actual de la sección
|
||||
State state_ = State::LOGO_ANIMATING; // Estado actual de la sección
|
||||
Uint64 last_time_ = 0; // Último timestamp para calcular delta-time
|
||||
float counter_time_ = 0.0F; // Temporizador para la pantalla de título (en segundos)
|
||||
float blink_accumulator_ = 0.0F; // Acumulador para el parpadeo (en segundos)
|
||||
|
||||
@@ -33,7 +33,6 @@ Notifier::Notifier(const std::string& icon_file, std::shared_ptr<Text> text)
|
||||
icon_texture_(!icon_file.empty() ? std::make_unique<Texture>(renderer_, icon_file) : nullptr),
|
||||
text_(std::move(text)),
|
||||
bg_color_(param.notification.color),
|
||||
stack_(false),
|
||||
has_icons_(!icon_file.empty()) {}
|
||||
|
||||
// Dibuja las notificaciones por pantalla
|
||||
|
||||
@@ -88,8 +88,8 @@ class Notifier {
|
||||
std::vector<Notification> notifications_; // Lista de notificaciones activas
|
||||
Color bg_color_; // Color de fondo de las notificaciones
|
||||
// Nota: wait_time_ eliminado, ahora se usa STAY_DURATION_S
|
||||
bool stack_; // Indica si las notificaciones se apilan
|
||||
bool has_icons_; // Indica si el notificador tiene textura para iconos
|
||||
bool stack_ = false; // Indica si las notificaciones se apilan
|
||||
bool has_icons_; // Indica si el notificador tiene textura para iconos
|
||||
|
||||
// --- Métodos internos ---
|
||||
void clearFinishedNotifications(); // Elimina las notificaciones cuyo estado es FINISHED
|
||||
|
||||
@@ -28,9 +28,7 @@ void ServiceMenu::destroy() { delete ServiceMenu::instance; }
|
||||
auto ServiceMenu::get() -> ServiceMenu* { return ServiceMenu::instance; }
|
||||
|
||||
// Constructor
|
||||
ServiceMenu::ServiceMenu()
|
||||
: current_settings_group_(SettingsGroup::MAIN),
|
||||
previous_settings_group_(current_settings_group_) {
|
||||
ServiceMenu::ServiceMenu() {
|
||||
auto element_text = Resource::get()->getText("04b_25_flat");
|
||||
auto title_text = Resource::get()->getText("04b_25_flat_2x");
|
||||
|
||||
|
||||
@@ -88,8 +88,8 @@ class ServiceMenu {
|
||||
std::vector<std::unique_ptr<MenuOption>> options_;
|
||||
std::vector<MenuOption*> display_options_;
|
||||
std::vector<std::pair<std::string, std::string>> option_pairs_;
|
||||
SettingsGroup current_settings_group_;
|
||||
SettingsGroup previous_settings_group_;
|
||||
SettingsGroup current_settings_group_ = SettingsGroup::MAIN;
|
||||
SettingsGroup previous_settings_group_ = SettingsGroup::MAIN;
|
||||
std::string title_;
|
||||
size_t selected_ = 0;
|
||||
size_t main_menu_selected_ = 0;
|
||||
@@ -103,15 +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 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();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// NOLINTNEXTLINE(bugprone-reserved-identifier) -- requerido por <cmath> para exponer M_PI en MSVC
|
||||
#define _USE_MATH_DEFINES
|
||||
#include "utils/color.hpp"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user