This commit is contained in:
2026-04-05 23:47:54 +02:00
parent 25ecc74251
commit c4a26ffa0f
96 changed files with 457 additions and 307 deletions

View File

@@ -33,6 +33,7 @@ Input::Input(std::string game_controller_db_path)
{Action::LEFT, KeyState{.scancode = SDL_SCANCODE_LEFT}},
{Action::RIGHT, KeyState{.scancode = SDL_SCANCODE_RIGHT}},
{Action::JUMP, KeyState{.scancode = SDL_SCANCODE_UP}},
{Action::DOWN, KeyState{.scancode = SDL_SCANCODE_DOWN}},
// Inputs de control
{Action::ACCEPT, KeyState{.scancode = SDL_SCANCODE_RETURN}},

View File

@@ -7,6 +7,7 @@ const std::unordered_map<InputAction, std::string> ACTION_TO_STRING = {
{InputAction::LEFT, "LEFT"},
{InputAction::RIGHT, "RIGHT"},
{InputAction::JUMP, "JUMP"},
{InputAction::DOWN, "DOWN"},
{InputAction::PAUSE, "PAUSE"},
{InputAction::EXIT, "EXIT"},
{InputAction::ACCEPT, "ACCEPT"},
@@ -30,6 +31,7 @@ const std::unordered_map<std::string, InputAction> STRING_TO_ACTION = {
{"LEFT", InputAction::LEFT},
{"RIGHT", InputAction::RIGHT},
{"JUMP", InputAction::JUMP},
{"DOWN", InputAction::DOWN},
{"PAUSE", InputAction::PAUSE},
{"EXIT", InputAction::EXIT},
{"ACCEPT", InputAction::ACCEPT},

View File

@@ -11,6 +11,7 @@ enum class InputAction : int { // Acciones de entrada posibles en el juego
LEFT,
RIGHT,
JUMP,
DOWN,
// Inputs de control
PAUSE,

View File

@@ -35,12 +35,8 @@ auto RenderInfo::get() -> RenderInfo* {
return RenderInfo::render_info;
}
// Constructor: en DEBUG se activa inmediatamente (notifica a Notifier del offset)
RenderInfo::RenderInfo() {
#ifdef _DEBUG
toggle();
#endif
}
// Constructor: arranca oculto; quien quiera activarlo debe llamar a toggle()
RenderInfo::RenderInfo() = default;
// Actualiza la animación de entrada/salida del overlay
void RenderInfo::update(float delta_time) {

View File

@@ -135,6 +135,7 @@ void Debug::loadFromFile() {
spawn_settings_.flip = Defaults::Game::Player::SPAWN_FLIP;
initial_scene_ = SceneManager::Scene::GAME;
lazy_loading_ = false;
render_info_enabled_ = false;
std::ifstream file(debug_file_path_);
if (!file.good()) {
@@ -145,8 +146,13 @@ void Debug::loadFromFile() {
std::string content((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
file.close();
bool needs_save = false;
try {
auto yaml = fkyaml::node::deserialize(content);
// Detecta si falta alguna clave esperada para regenerar el fichero con los nuevos defaults
for (const char* key : {"room", "spawn_x", "spawn_y", "spawn_flip", "initial_scene", "lazy_loading", "render_info"}) {
if (!yaml.contains(key)) { needs_save = true; break; }
}
if (yaml.contains("room")) {
spawn_settings_.room = yaml["room"].get_value<std::string>();
}
@@ -166,6 +172,9 @@ void Debug::loadFromFile() {
if (yaml.contains("lazy_loading")) {
lazy_loading_ = yaml["lazy_loading"].get_value<bool>();
}
if (yaml.contains("render_info")) {
render_info_enabled_ = yaml["render_info"].get_value<bool>();
}
} catch (...) {
// YAML inválido: resetear a defaults y sobreescribir
spawn_settings_.room = Defaults::Game::Room::INITIAL;
@@ -174,8 +183,11 @@ void Debug::loadFromFile() {
spawn_settings_.flip = Defaults::Game::Player::SPAWN_FLIP;
initial_scene_ = SceneManager::Scene::GAME;
lazy_loading_ = false;
render_info_enabled_ = false;
saveToFile();
return;
}
if (needs_save) { saveToFile(); }
}
// Guarda la configuración de debug en debug.yaml
@@ -190,6 +202,7 @@ void Debug::saveToFile() const {
file << "spawn_flip: " << ((spawn_settings_.flip == Flip::RIGHT) ? "right" : "left") << "\n";
file << "initial_scene: " << sceneToString(initial_scene_) << "\n";
file << "lazy_loading: " << (lazy_loading_ ? "true" : "false") << " # carga perezosa de recursos (dev)\n";
file << "render_info: " << (render_info_enabled_ ? "true" : "false") << " # overlay de info activo al arrancar\n";
}
#endif // _DEBUG

View File

@@ -48,6 +48,7 @@ class Debug {
[[nodiscard]] auto getInitialScene() const -> SceneManager::Scene { return initial_scene_; } // Obtiene la escena inicial de debug
void setInitialScene(SceneManager::Scene s) { initial_scene_ = s; } // Establece la escena inicial de debug
[[nodiscard]] auto getLazyLoading() const -> bool { return lazy_loading_; } // Indica si el modo lazy de recursos está activo
[[nodiscard]] auto getRenderInfoEnabled() const -> bool { return render_info_enabled_; } // Indica si el overlay RenderInfo arranca activo
private:
static Debug* debug; // [SINGLETON] Objeto privado
@@ -66,6 +67,7 @@ class Debug {
SpawnSettings spawn_settings_; // Configuración de spawn para debug
SceneManager::Scene initial_scene_ = SceneManager::Scene::GAME; // Escena inicial en debug
bool lazy_loading_ = false; // Carga lazy de recursos (dev)
bool render_info_enabled_ = false; // Overlay de RenderInfo activo al arrancar
};
#endif // _DEBUG

View File

@@ -177,6 +177,9 @@ Director::Director() {
#endif
Notifier::init("", "8bithud");
RenderInfo::init();
#ifdef _DEBUG
if (Debug::get()->getRenderInfoEnabled()) { RenderInfo::get()->toggle(); }
#endif
Console::init("8bithud");
Screen::get()->setNotificationsEnabled(true);