afegits cheats a la consola
This commit is contained in:
@@ -92,6 +92,32 @@ void Debug::setDebugFile(const std::string& path) {
|
||||
debug_file_path_ = path;
|
||||
}
|
||||
|
||||
// Convierte string a SceneManager::Scene (para debug.yaml)
|
||||
static auto sceneFromString(const std::string& s) -> SceneManager::Scene {
|
||||
if (s == "LOGO") { return SceneManager::Scene::LOGO; }
|
||||
if (s == "LOADING") { return SceneManager::Scene::LOADING_SCREEN; }
|
||||
if (s == "TITLE") { return SceneManager::Scene::TITLE; }
|
||||
if (s == "CREDITS") { return SceneManager::Scene::CREDITS; }
|
||||
if (s == "DEMO") { return SceneManager::Scene::DEMO; }
|
||||
if (s == "ENDING") { return SceneManager::Scene::ENDING; }
|
||||
if (s == "ENDING2") { return SceneManager::Scene::ENDING2; }
|
||||
return SceneManager::Scene::GAME; // Fallback seguro
|
||||
}
|
||||
|
||||
// Convierte SceneManager::Scene a string (para debug.yaml)
|
||||
static auto sceneToString(SceneManager::Scene scene) -> std::string {
|
||||
switch (scene) {
|
||||
case SceneManager::Scene::LOGO: return "LOGO";
|
||||
case SceneManager::Scene::LOADING_SCREEN: return "LOADING";
|
||||
case SceneManager::Scene::TITLE: return "TITLE";
|
||||
case SceneManager::Scene::CREDITS: return "CREDITS";
|
||||
case SceneManager::Scene::DEMO: return "DEMO";
|
||||
case SceneManager::Scene::ENDING: return "ENDING";
|
||||
case SceneManager::Scene::ENDING2: return "ENDING2";
|
||||
default: return "GAME";
|
||||
}
|
||||
}
|
||||
|
||||
// Carga la configuración de debug desde debug.yaml
|
||||
void Debug::loadFromFile() {
|
||||
// Inicializar con valores de release por defecto
|
||||
@@ -99,6 +125,7 @@ void Debug::loadFromFile() {
|
||||
spawn_settings_.spawn_x = Defaults::Game::Player::SPAWN_X;
|
||||
spawn_settings_.spawn_y = Defaults::Game::Player::SPAWN_Y;
|
||||
spawn_settings_.flip = Defaults::Game::Player::SPAWN_FLIP;
|
||||
initial_scene_ = SceneManager::Scene::GAME;
|
||||
|
||||
std::ifstream file(debug_file_path_);
|
||||
if (!file.good()) {
|
||||
@@ -124,12 +151,16 @@ void Debug::loadFromFile() {
|
||||
auto s = yaml["spawn_flip"].get_value<std::string>();
|
||||
spawn_settings_.flip = (s == "right") ? Flip::RIGHT : Flip::LEFT;
|
||||
}
|
||||
if (yaml.contains("initial_scene")) {
|
||||
initial_scene_ = sceneFromString(yaml["initial_scene"].get_value<std::string>());
|
||||
}
|
||||
} catch (...) {
|
||||
// YAML inválido: resetear a defaults y sobreescribir
|
||||
spawn_settings_.room = Defaults::Game::Room::INITIAL;
|
||||
spawn_settings_.spawn_x = Defaults::Game::Player::SPAWN_X;
|
||||
spawn_settings_.spawn_y = Defaults::Game::Player::SPAWN_Y;
|
||||
spawn_settings_.flip = Defaults::Game::Player::SPAWN_FLIP;
|
||||
initial_scene_ = SceneManager::Scene::GAME;
|
||||
saveToFile();
|
||||
}
|
||||
}
|
||||
@@ -144,6 +175,7 @@ void Debug::saveToFile() const {
|
||||
file << "spawn_x: " << (spawn_settings_.spawn_x / Tile::SIZE) << " # en tiles\n";
|
||||
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";
|
||||
}
|
||||
|
||||
#endif // _DEBUG
|
||||
Reference in New Issue
Block a user