ajustant el jugador
This commit is contained in:
@@ -134,6 +134,7 @@ void Debug::loadFromFile() {
|
||||
spawn_settings_.spawn_y = Defaults::Game::Player::SPAWN_Y;
|
||||
spawn_settings_.flip = Defaults::Game::Player::SPAWN_FLIP;
|
||||
initial_scene_ = SceneManager::Scene::GAME;
|
||||
lazy_loading_ = false;
|
||||
|
||||
std::ifstream file(debug_file_path_);
|
||||
if (!file.good()) {
|
||||
@@ -162,6 +163,9 @@ void Debug::loadFromFile() {
|
||||
if (yaml.contains("initial_scene")) {
|
||||
initial_scene_ = sceneFromString(yaml["initial_scene"].get_value<std::string>());
|
||||
}
|
||||
if (yaml.contains("lazy_loading")) {
|
||||
lazy_loading_ = yaml["lazy_loading"].get_value<bool>();
|
||||
}
|
||||
} catch (...) {
|
||||
// YAML inválido: resetear a defaults y sobreescribir
|
||||
spawn_settings_.room = Defaults::Game::Room::INITIAL;
|
||||
@@ -169,6 +173,7 @@ void Debug::loadFromFile() {
|
||||
spawn_settings_.spawn_y = Defaults::Game::Player::SPAWN_Y;
|
||||
spawn_settings_.flip = Defaults::Game::Player::SPAWN_FLIP;
|
||||
initial_scene_ = SceneManager::Scene::GAME;
|
||||
lazy_loading_ = false;
|
||||
saveToFile();
|
||||
}
|
||||
}
|
||||
@@ -184,6 +189,7 @@ void Debug::saveToFile() const {
|
||||
file << "spawn_y: " << (spawn_settings_.spawn_y / Tile::SIZE) << " # en tiles\n";
|
||||
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";
|
||||
}
|
||||
|
||||
#endif // _DEBUG
|
||||
@@ -47,6 +47,7 @@ class Debug {
|
||||
void setSpawnSettings(const SpawnSettings& s) { spawn_settings_ = s; } // Establece los valores de spawn
|
||||
[[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
|
||||
|
||||
private:
|
||||
static Debug* debug; // [SINGLETON] Objeto privado
|
||||
@@ -64,6 +65,7 @@ class Debug {
|
||||
std::string debug_file_path_; // Ruta del archivo debug.yaml
|
||||
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)
|
||||
};
|
||||
|
||||
#endif // _DEBUG
|
||||
@@ -160,8 +160,21 @@ Director::Director() {
|
||||
// Crea los objetos
|
||||
Screen::init();
|
||||
|
||||
#ifdef _DEBUG
|
||||
// En debug inicializamos Debug antes de Cache para leer el flag lazy_loading
|
||||
Debug::init();
|
||||
Debug::get()->setDebugFile(Resource::List::get()->get("debug.yaml"));
|
||||
Debug::get()->loadFromFile();
|
||||
#endif
|
||||
|
||||
// Initialize resources (works for both release and development)
|
||||
#ifdef _DEBUG
|
||||
Resource::Cache::init(Debug::get()->getLazyLoading()
|
||||
? Resource::Cache::LoadingMode::LAZY
|
||||
: Resource::Cache::LoadingMode::EAGER);
|
||||
#else
|
||||
Resource::Cache::init();
|
||||
#endif
|
||||
Notifier::init("", "8bithud");
|
||||
RenderInfo::init();
|
||||
Console::init("8bithud");
|
||||
@@ -182,9 +195,6 @@ Director::Director() {
|
||||
Input::get()->applyGamepadBindingsFromOptions();
|
||||
|
||||
#ifdef _DEBUG
|
||||
Debug::init();
|
||||
Debug::get()->setDebugFile(Resource::List::get()->get("debug.yaml"));
|
||||
Debug::get()->loadFromFile();
|
||||
SceneManager::current = Debug::get()->getInitialScene();
|
||||
MapEditor::init();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user