diff --git a/config/assets.yaml b/config/assets.yaml index 0dc7b3a..ed30514 100644 --- a/config/assets.yaml +++ b/config/assets.yaml @@ -82,127 +82,23 @@ assets: tilesets: BITMAP: - ${PREFIX}/data/tilesets/neighborhood.gif + - ${PREFIX}/data/tilesets/city.gif + - ${PREFIX}/data/tilesets/forest.gif + - ${PREFIX}/data/tilesets/lab.gif + - ${PREFIX}/data/tilesets/sewers.gif - ${PREFIX}/data/tilesets/cave.gif - ${PREFIX}/data/tilesets/collision.gif # ENEMIES enemies: ANIMATION: - - ${PREFIX}/data/enemies/abad_bell.yaml - - ${PREFIX}/data/enemies/abad.yaml - - ${PREFIX}/data/enemies/amstrad_cs.yaml - - ${PREFIX}/data/enemies/flying_arounder.yaml - - ${PREFIX}/data/enemies/stopped_arounder.yaml - - ${PREFIX}/data/enemies/walking_arounder.yaml - - ${PREFIX}/data/enemies/arounders_door.yaml - - ${PREFIX}/data/enemies/arounders_machine.yaml - - ${PREFIX}/data/enemies/bat.yaml - - ${PREFIX}/data/enemies/batman_bell.yaml - - ${PREFIX}/data/enemies/batman_fire.yaml - - ${PREFIX}/data/enemies/batman.yaml - - ${PREFIX}/data/enemies/bell.yaml - ${PREFIX}/data/enemies/bin.yaml - - ${PREFIX}/data/enemies/bird.yaml - - ${PREFIX}/data/enemies/breakout.yaml - - ${PREFIX}/data/enemies/bry.yaml - - ${PREFIX}/data/enemies/chip.yaml - ${PREFIX}/data/enemies/code.yaml - - ${PREFIX}/data/enemies/congo.yaml - - ${PREFIX}/data/enemies/crosshair.yaml - - ${PREFIX}/data/enemies/demon.yaml - - ${PREFIX}/data/enemies/dimallas.yaml - - ${PREFIX}/data/enemies/floppy.yaml - - ${PREFIX}/data/enemies/dong.yaml - - ${PREFIX}/data/enemies/guitar.yaml - - ${PREFIX}/data/enemies/heavy.yaml - - ${PREFIX}/data/enemies/jailer1.yaml - - ${PREFIX}/data/enemies/jailer2.yaml - - ${PREFIX}/data/enemies/jailer3.yaml - - ${PREFIX}/data/enemies/jailbattle_alien.yaml - - ${PREFIX}/data/enemies/jailbattle_human.yaml - - ${PREFIX}/data/enemies/jeannine.yaml - - ${PREFIX}/data/enemies/lamp.yaml - - ${PREFIX}/data/enemies/lord_abad.yaml - - ${PREFIX}/data/enemies/matatunos.yaml - - ${PREFIX}/data/enemies/mummy.yaml - - ${PREFIX}/data/enemies/paco.yaml - - ${PREFIX}/data/enemies/elsa.yaml - - ${PREFIX}/data/enemies/qvoid.yaml - - ${PREFIX}/data/enemies/robot.yaml - - ${PREFIX}/data/enemies/sam.yaml - - ${PREFIX}/data/enemies/shock.yaml - - ${PREFIX}/data/enemies/sigmasua.yaml - - ${PREFIX}/data/enemies/spark.yaml - - ${PREFIX}/data/enemies/special/aerojailer.yaml - - ${PREFIX}/data/enemies/special/arounder.yaml - - ${PREFIX}/data/enemies/special/pepe_rosita_job.yaml - - ${PREFIX}/data/enemies/special/shooting_star.yaml - - ${PREFIX}/data/enemies/spider.yaml - - ${PREFIX}/data/enemies/tree_thing.yaml - - ${PREFIX}/data/enemies/tuno.yaml - - ${PREFIX}/data/enemies/tv_panel.yaml - - ${PREFIX}/data/enemies/tv.yaml - ${PREFIX}/data/enemies/upv_student.yaml - - ${PREFIX}/data/enemies/wave.yaml - - ${PREFIX}/data/enemies/z80.yaml BITMAP: - - ${PREFIX}/data/enemies/abad_bell.gif - - ${PREFIX}/data/enemies/abad.gif - - ${PREFIX}/data/enemies/amstrad_cs.gif - - ${PREFIX}/data/enemies/flying_arounder.gif - - ${PREFIX}/data/enemies/stopped_arounder.gif - - ${PREFIX}/data/enemies/walking_arounder.gif - - ${PREFIX}/data/enemies/arounders_door.gif - - ${PREFIX}/data/enemies/arounders_machine.gif - - ${PREFIX}/data/enemies/bat.gif - - ${PREFIX}/data/enemies/batman_bell.gif - - ${PREFIX}/data/enemies/batman_fire.gif - - ${PREFIX}/data/enemies/batman.gif - - ${PREFIX}/data/enemies/bell.gif - ${PREFIX}/data/enemies/bin.gif - - ${PREFIX}/data/enemies/bird.gif - - ${PREFIX}/data/enemies/breakout.gif - - ${PREFIX}/data/enemies/bry.gif - - ${PREFIX}/data/enemies/chip.gif - ${PREFIX}/data/enemies/code.gif - - ${PREFIX}/data/enemies/congo.gif - - ${PREFIX}/data/enemies/crosshair.gif - - ${PREFIX}/data/enemies/demon.gif - - ${PREFIX}/data/enemies/dimallas.gif - - ${PREFIX}/data/enemies/floppy.gif - - ${PREFIX}/data/enemies/dong.gif - - ${PREFIX}/data/enemies/guitar.gif - - ${PREFIX}/data/enemies/heavy.gif - - ${PREFIX}/data/enemies/jailer1.gif - - ${PREFIX}/data/enemies/jailer2.gif - - ${PREFIX}/data/enemies/jailer3.gif - - ${PREFIX}/data/enemies/jailbattle_alien.gif - - ${PREFIX}/data/enemies/jailbattle_human.gif - - ${PREFIX}/data/enemies/jeannine.gif - - ${PREFIX}/data/enemies/lamp.gif - - ${PREFIX}/data/enemies/lord_abad.gif - - ${PREFIX}/data/enemies/matatunos.gif - - ${PREFIX}/data/enemies/mummy.gif - - ${PREFIX}/data/enemies/paco.gif - - ${PREFIX}/data/enemies/elsa.gif - - ${PREFIX}/data/enemies/qvoid.gif - - ${PREFIX}/data/enemies/robot.gif - - ${PREFIX}/data/enemies/sam.gif - - ${PREFIX}/data/enemies/shock.gif - - ${PREFIX}/data/enemies/sigmasua.gif - - ${PREFIX}/data/enemies/spark.gif - - ${PREFIX}/data/enemies/special/aerojailer.gif - - ${PREFIX}/data/enemies/special/arounder.gif - - ${PREFIX}/data/enemies/special/pepe_rosita_job.gif - - ${PREFIX}/data/enemies/special/shooting_star.gif - - ${PREFIX}/data/enemies/spider.gif - - ${PREFIX}/data/enemies/tree_thing.gif - - ${PREFIX}/data/enemies/tuno.gif - - ${PREFIX}/data/enemies/tv_panel.gif - - ${PREFIX}/data/enemies/tv.gif - ${PREFIX}/data/enemies/upv_student.gif - - ${PREFIX}/data/enemies/wave.gif - - ${PREFIX}/data/enemies/z80.gif # PLATFORMS platforms: diff --git a/data/room/03.yaml b/data/room/03.yaml index bc3030a..0093c7b 100644 --- a/data/room/03.yaml +++ b/data/room/03.yaml @@ -40,9 +40,9 @@ tilemap: - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] - [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, 0, 0, 4, 1, 1, 1, 1, 1, 1, 1, 1] - - [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 1, 1] - - [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1] - - [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] + - [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1] + - [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1] + - [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1] - [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] - [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] - [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] diff --git a/data/room/06.yaml b/data/room/06.yaml index f1c73cf..956915e 100644 --- a/data/room/06.yaml +++ b/data/room/06.yaml @@ -1,5 +1,5 @@ room: - zone: cave + zone: forest # Conexiones de la habitación (null = sin conexión) connections: @@ -8,21 +8,12 @@ room: left: null right: 01.yaml - # Colores de los objetos - itemColor1: 11 - itemColor2: 12 - - # Dirección de la cinta transportadora: left, none, right - conveyorBelt: none - # Tilemap: 21 filas x 32 columnas @ 8px/tile tilemap: # Mapa de dibujo (indices de tiles, -1 = vacio) draw: - - [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25] - - [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25] - - [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25] - - [49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49] + - [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15] + - [13, 14, 13, 14, 13, 13, 13, 14, 13, 13, 13, 13, 14, 13, 13, 13, 14, 13, 14, 13, 14, 13, 13, 13, 13, 14, 14, 13, 13, 13, 14, 13] - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] @@ -34,19 +25,21 @@ tilemap: - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] - - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 513, 25] - - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 513, 25, 25] - - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 513, 25, 25, 25] - - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 513, 25, 25, 25, 25] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 11, 57] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 11, 57, 25] + - [54, 54, 55, 61, 54, 55, 56, 54, 61, 55, 54, 55, 62, 54, 61, 61, 54, 54, 54, 54, 54, 61, 61, 54, 55, 56, 54, 9, 11, 57, 25, 25] - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 25] - [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25] # Mapa de colisiones (0 = vacio, 1 = solido) collision: - - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] - - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] - - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] - - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] - - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] diff --git a/data/tilesets/city.gif b/data/tilesets/city.gif new file mode 100644 index 0000000..e497073 Binary files /dev/null and b/data/tilesets/city.gif differ diff --git a/data/tilesets/forest.gif b/data/tilesets/forest.gif new file mode 100644 index 0000000..995ef14 Binary files /dev/null and b/data/tilesets/forest.gif differ diff --git a/data/tilesets/lab.gif b/data/tilesets/lab.gif new file mode 100644 index 0000000..e497073 Binary files /dev/null and b/data/tilesets/lab.gif differ diff --git a/data/tilesets/sewers.gif b/data/tilesets/sewers.gif new file mode 100644 index 0000000..e497073 Binary files /dev/null and b/data/tilesets/sewers.gif differ diff --git a/data/zones/zones.yaml b/data/zones/zones.yaml index f76d28e..ceb49ee 100644 --- a/data/zones/zones.yaml +++ b/data/zones/zones.yaml @@ -7,7 +7,29 @@ zones: - name: neighborhood tileSetFile: neighborhood.gif music: 574070_KUVO_Farewell_to_school.ogg + bgColor: 0 - name: cave tileSetFile: cave.gif music: 574071_EA_DTV.ogg + bgColor: 0 + + - name: forest + tileSetFile: forest.gif + music: 574070_KUVO_Farewell_to_school.ogg + bgColor: 35 + + - name: sewers + tileSetFile: sewers.gif + music: 574071_EA_DTV.ogg + bgColor: 0 + + - name: lab + tileSetFile: lab.gif + music: 574071_EA_DTV.ogg + bgColor: 0 + + - name: city + tileSetFile: city.gif + music: 574071_EA_DTV.ogg + bgColor: 0 \ No newline at end of file diff --git a/source/core/input/global_inputs.cpp b/source/core/input/global_inputs.cpp index cae33a6..83fd1d7 100644 --- a/source/core/input/global_inputs.cpp +++ b/source/core/input/global_inputs.cpp @@ -9,6 +9,9 @@ #include "core/locale/locale.hpp" // Para Locale #include "core/rendering/render_info.hpp" // Para RenderInfo #include "core/rendering/screen.hpp" // Para Screen +#ifdef _DEBUG +#include "core/system/debug.hpp" // Para Debug (persistencia de render_info en debug.yaml) +#endif #include "game/options.hpp" // Para Options, options, OptionsVideo, Section #include "game/scene_manager.hpp" // Para SceneManager #include "game/ui/console.hpp" // Para Console @@ -292,7 +295,16 @@ namespace GlobalInputs { break; case InputAction::TOGGLE_INFO: - if (RenderInfo::get() != nullptr) { RenderInfo::get()->toggle(); } + if (RenderInfo::get() != nullptr) { + // Leemos la intención antes del toggle: isActive() incluye la + // animación VANISHING, así que justo después de un toggle ACTIVE→OFF + // seguiría devolviendo true y la persistencia no detectaría el cambio. + const bool WAS_ACTIVE = RenderInfo::get()->isActive(); + RenderInfo::get()->toggle(); +#ifdef _DEBUG + if (Debug::get() != nullptr) { Debug::get()->setRenderInfoEnabled(!WAS_ACTIVE); } +#endif + } break; case InputAction::NONE: diff --git a/source/core/system/debug.cpp b/source/core/system/debug.cpp index 37cda18..f2590f5 100644 --- a/source/core/system/debug.cpp +++ b/source/core/system/debug.cpp @@ -178,6 +178,13 @@ void Debug::loadFromFile() { if (needs_save) { saveToFile(); } } +// Persiste el estado del overlay RenderInfo en debug.yaml +void Debug::setRenderInfoEnabled(bool value) { + if (render_info_enabled_ == value) { return; } + render_info_enabled_ = value; + saveToFile(); +} + // Guarda la configuración de debug en debug.yaml void Debug::saveToFile() const { std::ofstream file(debug_file_path_); diff --git a/source/core/system/debug.hpp b/source/core/system/debug.hpp index b19a82e..e97e9b9 100644 --- a/source/core/system/debug.hpp +++ b/source/core/system/debug.hpp @@ -49,6 +49,7 @@ class 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 + void setRenderInfoEnabled(bool value); // Persiste el estado del overlay RenderInfo en debug.yaml private: static Debug* debug; // [SINGLETON] Objeto privado diff --git a/source/game/editor/map_editor.cpp b/source/game/editor/map_editor.cpp index ef1d30c..6faee10 100644 --- a/source/game/editor/map_editor.cpp +++ b/source/game/editor/map_editor.cpp @@ -20,6 +20,7 @@ #include "core/resources/resource_cache.hpp" // Para Resource::Cache #include "core/resources/resource_list.hpp" // Para Resource::List #include "core/resources/resource_types.hpp" // Para RoomResource +#include "core/system/debug.hpp" // Para Debug (persistencia de render_info) #include "external/fkyaml_node.hpp" // Para fkyaml::node (loadSettings) #include "game/editor/editor_statusbar.hpp" // Para EditorStatusBar #include "game/entities/player.hpp" // Para Player @@ -76,7 +77,6 @@ void MapEditor::loadSettings() { try { auto yaml = fkyaml::node::deserialize(content); if (yaml.contains("grid")) { settings_.grid = yaml["grid"].get_value(); } - if (yaml.contains("show_render_info")) { settings_.show_render_info = yaml["show_render_info"].get_value(); } if (yaml.contains("minimap_bg")) { if (yaml["minimap_bg"].is_integer()) { settings_.minimap_bg = static_cast(yaml["minimap_bg"].get_value()); @@ -106,19 +106,17 @@ void MapEditor::saveSettings() const { file << "# Map Editor Settings\n"; file << "grid: " << (settings_.grid ? "true" : "false") << "\n"; - file << "show_render_info: " << (settings_.show_render_info ? "true" : "false") << "\n"; file << "minimap_bg: " << static_cast(settings_.minimap_bg) << "\n"; file << "minimap_conn: " << static_cast(settings_.minimap_conn) << "\n"; file.close(); } -// Muestra/oculta render info (persistente) +// Muestra/oculta render info (persistente en debug.yaml, fuente de verdad global) auto MapEditor::showInfo(bool show) -> std::string { - settings_.show_render_info = show; if (RenderInfo::get()->isActive() != show) { RenderInfo::get()->toggle(); } - saveSettings(); + if (Debug::get() != nullptr) { Debug::get()->setRenderInfoEnabled(show); } return show ? "Info ON" : "Info OFF"; } @@ -203,18 +201,12 @@ void MapEditor::enter(std::shared_ptr room, std::shared_ptr player if (!reenter_) { // Solo guardar estado previo en el primer enter (no en re-enter tras cambio de room) invincible_before_editor_ = Options::cheats.invincible; - render_info_before_editor_ = RenderInfo::get()->isActive(); } reenter_ = false; // Forzar invencibilidad Options::cheats.invincible = Options::Cheat::State::ENABLED; - // Aplicar el setting de render_info del editor - if (settings_.show_render_info != RenderInfo::get()->isActive()) { - RenderInfo::get()->toggle(); - } - // Activar scope de la consola para el editor Console::get()->setScope("editor"); @@ -256,10 +248,6 @@ void MapEditor::exit() { if (!reenter_) { // Solo restaurar en el exit final (no en cambio de room) Options::cheats.invincible = invincible_before_editor_; - - if (RenderInfo::get()->isActive() != render_info_before_editor_) { - RenderInfo::get()->toggle(); - } } // Restaurar prompt y scope de la consola @@ -443,8 +431,13 @@ void MapEditor::render() { // Maneja eventos del editor void MapEditor::handleEvent(const SDL_Event& event) { // NOLINT(readability-function-cognitive-complexity) - // Si el tile picker está abierto, los eventos van a él + // Si el tile picker está abierto, los eventos van a él. + // Excepción: la T lo cierra como toggle (sin tocar el brush). if (tile_picker_.isOpen()) { + if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_T && static_cast(event.key.repeat) == 0) { + tile_picker_.close(); + return; + } tile_picker_.handleEvent(event); return; } @@ -528,7 +521,7 @@ void MapEditor::handleEvent(const SDL_Event& event) { // NOLINT(readability-fun } } - // T: abrir TilePicker + // T: abrir TilePicker (el cierre con T también se gestiona arriba, antes de delegar al picker) if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_T && static_cast(event.key.repeat) == 0) { // Deseleccionar entidades selection_.clear(); @@ -1464,7 +1457,8 @@ void MapEditor::updateStatusBarInfo() { // NOLINT(readability-function-cognitiv // Propiedades de la habitación std::string ts_marker = room_data_.tile_set_overridden ? " (ts*)" : ""; std::string mu_marker = room_data_.music_overridden ? " (mu*)" : ""; - line2 = "zone:" + room_data_.zone + ts_marker + mu_marker; + std::string bg_marker = room_data_.bg_color_overridden ? "*" : ""; + line2 = "zone:" + room_data_.zone + ts_marker + mu_marker + " bg:" + std::to_string(room_data_.bg_color) + bg_marker; line3 = "u:" + conn(room_data_.upper_room) + " d:" + conn(room_data_.lower_room) + " l:" + conn(room_data_.left_room) + " r:" + conn(room_data_.right_room); break; @@ -1509,7 +1503,7 @@ auto MapEditor::getSetCompletions() const -> std::vector { case EntityType::DOOR: return {"ID", "ANIMATION"}; default: - return {"ZONE", "TILESET", "MUSIC", "UP", "DOWN", "LEFT", "RIGHT"}; + return {"ZONE", "TILESET", "MUSIC", "BGCOLOR", "UP", "DOWN", "LEFT", "RIGHT"}; } } @@ -1733,6 +1727,10 @@ auto MapEditor::setRoomProperty(const std::string& property, const std::string& if (!room_data_.music_overridden) { room_data_.music = zone->music; } + if (!room_data_.bg_color_overridden) { + room_data_.bg_color = zone->bg_color; + room_->setBgColor(zone->bg_color); + } autosave(); return "zone: " + val; } @@ -1758,6 +1756,30 @@ auto MapEditor::setRoomProperty(const std::string& property, const std::string& return "tileset: " + tileset; } + if (property == "BGCOLOR") { + // "reset" / "none" limpia el override y vuelve a heredar de la zona + if (val == "reset" || val == "none") { + room_data_.bg_color_overridden = false; + const Zone::Data* zone = ZoneManager::get()->getZone(room_data_.zone); + if (zone != nullptr) { + room_data_.bg_color = zone->bg_color; + room_->setBgColor(zone->bg_color); + } + autosave(); + return "bgcolor: (inherit from zone)"; + } + int color = 0; + try { + color = std::stoi(val); + } catch (...) { return "usage: set bgcolor <0-255|reset>"; } + if (color < 0 || color > 255) { return "bgcolor must be 0-255"; } + room_data_.bg_color = static_cast(color); + room_data_.bg_color_overridden = true; + room_->setBgColor(static_cast(color)); + autosave(); + return "bgcolor: " + std::to_string(color); + } + if (property == "MUSIC") { // "reset" / "none" limpia el override y vuelve a heredar de la zona if (val == "reset" || val == "none") { @@ -1875,7 +1897,7 @@ auto MapEditor::setRoomProperty(const std::string& property, const std::string& return toLower(property) + ": " + connection; } - return "Unknown property: " + property + " (use: zone, itemcolor1, itemcolor2, conveyor, tileset, music, up, down, left, right)"; + return "Unknown property: " + property + " (use: zone, itemcolor1, itemcolor2, conveyor, tileset, music, bgcolor, up, down, left, right)"; } // Crea una nueva habitación diff --git a/source/game/editor/map_editor.hpp b/source/game/editor/map_editor.hpp index 649e2ca..524ccf9 100644 --- a/source/game/editor/map_editor.hpp +++ b/source/game/editor/map_editor.hpp @@ -156,7 +156,6 @@ class MapEditor { // Opciones persistentes del editor struct Settings { bool grid{false}; - bool show_render_info{false}; Uint8 minimap_bg{2}; Uint8 minimap_conn{14}; }; @@ -257,8 +256,7 @@ class MapEditor { // Estado previo (para restaurar al salir) Options::Cheat::State invincible_before_editor_{Options::Cheat::State::DISABLED}; - bool render_info_before_editor_{false}; - bool reenter_{false}; // true cuando es un re-enter tras cambio de room (no tocar render_info) + bool reenter_{false}; // true cuando es un re-enter tras cambio de room }; #endif // _DEBUG diff --git a/source/game/gameplay/room.cpp b/source/game/gameplay/room.cpp index 6604cd3..13bf605 100644 --- a/source/game/gameplay/room.cpp +++ b/source/game/gameplay/room.cpp @@ -198,6 +198,17 @@ void Room::setTileSet(const std::string& tile_set_file) { bg_color_); tilemap_renderer_->initialize(collision_map_->getCollisionTileMap()); } + +// Cambia el color de fondo en vivo (para editor) +void Room::setBgColor(Uint8 bg_color) { + bg_color_ = bg_color; + tilemap_renderer_ = std::make_unique( + tile_map_, + tile_set_width_, + surface_, + bg_color_); + tilemap_renderer_->initialize(collision_map_->getCollisionTileMap()); +} #endif // Actualiza las variables y objetos de la habitación diff --git a/source/game/gameplay/room.hpp b/source/game/gameplay/room.hpp index cea365f..0a2c4d5 100644 --- a/source/game/gameplay/room.hpp +++ b/source/game/gameplay/room.hpp @@ -47,6 +47,7 @@ class Room { std::string music; // Resuelto: zona o override del yaml bool tile_set_overridden{false}; // True si el yaml tenía tileSetFile explícito bool music_overridden{false}; // True si el yaml tenía music explícito + bool bg_color_overridden{false}; // True si el yaml tenía bgColor explícito std::vector tile_map; std::vector collision_tile_map; std::vector enemies; @@ -85,6 +86,7 @@ class Room { void setCollisionTile(int index, int value); void setConnection(Border border, const std::string& room_name); void setTileSet(const std::string& tile_set_file); + void setBgColor(Uint8 bg_color); [[nodiscard]] auto getTileSetWidth() const -> int { return tile_set_width_; } #endif void update(float delta_time); diff --git a/source/game/gameplay/room_format.cpp b/source/game/gameplay/room_format.cpp index 7b50999..0fe0c8a 100644 --- a/source/game/gameplay/room_format.cpp +++ b/source/game/gameplay/room_format.cpp @@ -136,6 +136,14 @@ void RoomFormat::parseRoomConfig(const fkyaml::node& yaml, Room::Data& room, con room.music = zone->music; } + // bgColor: zona, override si está en el yaml + if (room_node.contains("bgColor")) { + room.bg_color = readColorNode(room_node["bgColor"]); + room.bg_color_overridden = true; + } else if (zone != nullptr) { + room.bg_color = zone->bg_color; + } + // Room connections if (room_node.contains("connections")) { parseRoomConnections(room_node["connections"], room); @@ -508,15 +516,17 @@ auto RoomFormat::loadFromString(const std::string& yaml_content, const std::stri auto RoomFormat::createDefault() -> Room::Data { Room::Data data; - // Zona por defecto (resuelve tile_set_file y music desde ZoneManager) + // Zona por defecto (resuelve tile_set_file, music y bg_color desde ZoneManager) const Zone::Data* zone = ZoneManager::get()->getDefaultZone(); if (zone != nullptr) { data.zone = zone->name; data.tile_set_file = zone->tile_set_file; data.music = zone->music; + data.bg_color = zone->bg_color; } data.tile_set_overridden = false; data.music_overridden = false; + data.bg_color_overridden = false; // Conexiones a cero data.upper_room = "0"; @@ -559,6 +569,11 @@ auto RoomFormat::buildContent(const Room::Data& room_data) -> std::string { // out << " music: " << room_data.music << "\n"; } + // bgColor solo si es override explícito del valor heredado de la zona + if (room_data.bg_color_overridden) { + out << " bgColor: " << static_cast(room_data.bg_color) << "\n"; + } + // Conexiones out << "\n"; out << " # Conexiones de la habitación (null = sin conexión)\n"; diff --git a/source/game/gameplay/zone.hpp b/source/game/gameplay/zone.hpp index c278f41..1352efc 100644 --- a/source/game/gameplay/zone.hpp +++ b/source/game/gameplay/zone.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include // Para string /** @@ -17,6 +19,7 @@ namespace Zone { std::string name; // Nombre único de la zona (ej. "neighborhood", "cave") std::string tile_set_file; // Fichero de tileset por defecto (ej. "neighborhood.gif") std::string music; // Pista de música por defecto (ej. "574070_KUVO_Farewell_to_school.ogg") + Uint8 bg_color{0}; // Color de fondo por defecto (índice de paleta) }; } // namespace Zone diff --git a/source/game/gameplay/zone_manager.cpp b/source/game/gameplay/zone_manager.cpp index 926297b..4a4c215 100644 --- a/source/game/gameplay/zone_manager.cpp +++ b/source/game/gameplay/zone_manager.cpp @@ -57,6 +57,9 @@ void ZoneManager::loadFromFile(const std::string& file_path) { if (zone_node.contains("music")) { zone.music = zone_node["music"].get_value(); } + if (zone_node.contains("bgColor")) { + zone.bg_color = static_cast(zone_node["bgColor"].get_value()); + } if (zone.name.empty()) { std::cerr << "ZoneManager: skipping zone without name\n"; diff --git a/source/game/ui/console_commands.cpp b/source/game/ui/console_commands.cpp index 81bd10b..c9d1e6b 100644 --- a/source/game/ui/console_commands.cpp +++ b/source/game/ui/console_commands.cpp @@ -850,6 +850,9 @@ static auto cmdShow(const std::vector& args) -> std::string { #endif if (RenderInfo::get()->isActive()) { return "Info overlay already ON"; } RenderInfo::get()->toggle(); +#ifdef _DEBUG + if (Debug::get() != nullptr) { Debug::get()->setRenderInfoEnabled(true); } +#endif return "Info overlay ON"; } @@ -858,6 +861,9 @@ static auto cmdHide(const std::vector& args) -> std::string { if (args.empty() || args[0] != "INFO") { return "usage: hide [info]"; } if (!RenderInfo::get()->isActive()) { return "Info overlay already OFF"; } RenderInfo::get()->toggle(); +#ifdef _DEBUG + if (Debug::get() != nullptr) { Debug::get()->setRenderInfoEnabled(false); } +#endif return "Info overlay OFF"; } @@ -1087,6 +1093,7 @@ void CommandRegistry::registerHandlers() { // NOLINT(readability-function-cogni }; dynamic_providers_["SET ITEMCOLOR1"] = color_provider; dynamic_providers_["SET ITEMCOLOR2"] = color_provider; + dynamic_providers_["SET BGCOLOR"] = color_provider; // SET ANIMATION: animaciones disponibles para la entidad seleccionada en // el editor. La lista la calcula MapEditor escaneando data// del