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