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

@@ -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);