neteja clang-tidy
This commit is contained in:
@@ -38,6 +38,38 @@
|
||||
#include "game/ui/service_menu.hpp" // Para ServiceMenu
|
||||
#include "utils/param.hpp" // Para loadParamsFromFile
|
||||
|
||||
namespace {
|
||||
// Llig un camp opcional d'un YAML cap a `dest`. Si no existeix, no toca `dest`.
|
||||
// Si existeix però el tipus no encaixa, deixa el valor per defecte i avisa per stderr
|
||||
// (un debug.yaml mal escrit no ha de tombar l'arrencada, però l'usuari ha de saber-ho).
|
||||
template <typename T>
|
||||
void loadYamlField(const fkyaml::node& yaml, const std::string& key, T& dest) {
|
||||
if (!yaml.contains(key)) { return; }
|
||||
try {
|
||||
dest = yaml[key].get_value<T>();
|
||||
} catch (...) {
|
||||
std::cerr << "debug.yaml: valor invàlid per a '" << key << "', es manté el valor per defecte\n";
|
||||
}
|
||||
}
|
||||
|
||||
auto parseInitialSection(const std::string& value) -> Section::Name {
|
||||
if (value == "logo") { return Section::Name::LOGO; }
|
||||
if (value == "intro") { return Section::Name::INTRO; }
|
||||
if (value == "title") { return Section::Name::TITLE; }
|
||||
if (value == "credits") { return Section::Name::CREDITS; }
|
||||
if (value == "instructions") { return Section::Name::INSTRUCTIONS; }
|
||||
if (value == "hiscore") { return Section::Name::HI_SCORE_TABLE; }
|
||||
return Section::Name::GAME; // "game" i qualsevol valor desconegut
|
||||
}
|
||||
|
||||
auto parseInitialOptions(const std::string& value) -> Section::Options {
|
||||
if (value == "none") { return Section::Options::NONE; }
|
||||
if (value == "2p") { return Section::Options::GAME_PLAY_2P; }
|
||||
if (value == "both") { return Section::Options::GAME_PLAY_BOTH; }
|
||||
return Section::Options::GAME_PLAY_1P; // "1p" i qualsevol valor desconegut
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Constructor
|
||||
Director::Director() {
|
||||
Section::attract_mode = Section::AttractMode::TITLE_TO_DEMO;
|
||||
@@ -275,78 +307,20 @@ void Director::loadDebugConfig() {
|
||||
file.close();
|
||||
try {
|
||||
auto yaml = fkyaml::node::deserialize(content);
|
||||
if (yaml.contains("initial_section")) {
|
||||
try {
|
||||
debug_config.initial_section = yaml["initial_section"].get_value<std::string>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (yaml.contains("initial_options")) {
|
||||
try {
|
||||
debug_config.initial_options = yaml["initial_options"].get_value<std::string>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (yaml.contains("initial_stage")) {
|
||||
try {
|
||||
debug_config.initial_stage = yaml["initial_stage"].get_value<int>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (yaml.contains("show_render_info")) {
|
||||
try {
|
||||
debug_config.show_render_info = yaml["show_render_info"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (yaml.contains("resource_loading")) {
|
||||
try {
|
||||
debug_config.resource_loading = yaml["resource_loading"].get_value<std::string>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (yaml.contains("autoplay")) {
|
||||
try {
|
||||
debug_config.autoplay = yaml["autoplay"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (yaml.contains("invincibility")) {
|
||||
try {
|
||||
debug_config.invincibility = yaml["invincibility"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
loadYamlField(yaml, "initial_section", debug_config.initial_section);
|
||||
loadYamlField(yaml, "initial_options", debug_config.initial_options);
|
||||
loadYamlField(yaml, "initial_stage", debug_config.initial_stage);
|
||||
loadYamlField(yaml, "show_render_info", debug_config.show_render_info);
|
||||
loadYamlField(yaml, "resource_loading", debug_config.resource_loading);
|
||||
loadYamlField(yaml, "autoplay", debug_config.autoplay);
|
||||
loadYamlField(yaml, "invincibility", debug_config.invincibility);
|
||||
} catch (...) {
|
||||
std::cout << "Error parsing debug.yaml, using defaults" << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
// Mapear strings a enums
|
||||
const auto& sec = debug_config.initial_section;
|
||||
if (sec == "logo") {
|
||||
Section::name = Section::Name::LOGO;
|
||||
} else if (sec == "intro") {
|
||||
Section::name = Section::Name::INTRO;
|
||||
} else if (sec == "title") {
|
||||
Section::name = Section::Name::TITLE;
|
||||
} else if (sec == "game") {
|
||||
Section::name = Section::Name::GAME;
|
||||
} else if (sec == "credits") {
|
||||
Section::name = Section::Name::CREDITS;
|
||||
} else if (sec == "instructions") {
|
||||
Section::name = Section::Name::INSTRUCTIONS;
|
||||
} else if (sec == "hiscore") {
|
||||
Section::name = Section::Name::HI_SCORE_TABLE;
|
||||
} else {
|
||||
Section::name = Section::Name::GAME;
|
||||
}
|
||||
|
||||
const auto& opt = debug_config.initial_options;
|
||||
if (opt == "none") {
|
||||
Section::options = Section::Options::NONE;
|
||||
} else if (opt == "1p") {
|
||||
Section::options = Section::Options::GAME_PLAY_1P;
|
||||
} else if (opt == "2p") {
|
||||
Section::options = Section::Options::GAME_PLAY_2P;
|
||||
} else if (opt == "both") {
|
||||
Section::options = Section::Options::GAME_PLAY_BOTH;
|
||||
} else {
|
||||
Section::options = Section::Options::GAME_PLAY_1P;
|
||||
}
|
||||
Section::name = parseInitialSection(debug_config.initial_section);
|
||||
Section::options = parseInitialOptions(debug_config.initial_options);
|
||||
}
|
||||
|
||||
// Crea la carpeta del sistema donde guardar datos
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
|
||||
#include "core/system/section.hpp" // Para Section::Name
|
||||
|
||||
#include <cstdint> // Para std::uint8_t
|
||||
|
||||
namespace Lang {
|
||||
enum class Code : int;
|
||||
enum class Code : std::uint8_t;
|
||||
}
|
||||
|
||||
// Declaraciones adelantadas de las secciones
|
||||
@@ -70,7 +72,7 @@ class Director {
|
||||
|
||||
// --- Inicialización y cierre del sistema ---
|
||||
void init(); // Inicializa la aplicación (pre-boot)
|
||||
void finishBoot(); // Post-boot: inicializa lo que depende de recursos cargados
|
||||
static void finishBoot(); // Post-boot: inicializa lo que depende de recursos cargados
|
||||
static void close(); // Cierra y libera recursos
|
||||
|
||||
// --- Configuración inicial ---
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/*
|
||||
Namespace section: define los estados/secciones principales del programa,
|
||||
así como las opciones y modos especiales (como el Attract Mode).
|
||||
@@ -8,7 +10,7 @@
|
||||
|
||||
namespace Section {
|
||||
// --- Enumeraciones de secciones del programa ---
|
||||
enum class Name {
|
||||
enum class Name : std::uint8_t {
|
||||
RESET, // Inicialización
|
||||
PRELOAD, // Carga incremental de recursos
|
||||
LOGO, // Pantalla de logo
|
||||
@@ -23,7 +25,7 @@ namespace Section {
|
||||
};
|
||||
|
||||
// --- Opciones para la sección actual ---
|
||||
enum class Options {
|
||||
enum class Options : std::uint8_t {
|
||||
GAME_PLAY_1P, // Iniciar el juego con el jugador 1
|
||||
GAME_PLAY_2P, // Iniciar el juego con el jugador 2
|
||||
GAME_PLAY_BOTH, // Iniciar el juego con los dos jugadores
|
||||
@@ -37,7 +39,7 @@ namespace Section {
|
||||
};
|
||||
|
||||
// --- Modos para el Attract Mode ---
|
||||
enum class AttractMode {
|
||||
enum class AttractMode : std::uint8_t {
|
||||
TITLE_TO_DEMO, // Pasar de título a demo
|
||||
TITLE_TO_LOGO, // Pasar de título a logo
|
||||
};
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// --- Namespace SystemShutdown: utilidad multiplataforma para apagar el sistema de forma segura ---
|
||||
namespace SystemShutdown {
|
||||
|
||||
// --- Enums ---
|
||||
enum class ShutdownResult {
|
||||
enum class ShutdownResult : std::uint8_t {
|
||||
SUCCESS = 0, // Éxito
|
||||
ERROR_PERMISSION, // Error de permisos insuficientes
|
||||
ERROR_SYSTEM_CALL, // Error en la llamada al sistema
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
// --- Namespace SystemUtils: utilidades multiplataforma para operaciones del sistema ---
|
||||
namespace SystemUtils {
|
||||
// --- Enums ---
|
||||
enum class Result { // Códigos de resultado para operaciones del sistema
|
||||
enum class Result : std::uint8_t { // Códigos de resultado para operaciones del sistema
|
||||
SUCCESS = 0,
|
||||
PERMISSION_DENIED, // Sin permisos para crear la carpeta
|
||||
PATH_TOO_LONG, // Ruta demasiado larga
|
||||
|
||||
Reference in New Issue
Block a user