fix: bug que feia que en el editor, al canviar d'habitació el renderInfo tornara a eixir

This commit is contained in:
2026-04-02 19:55:28 +02:00
parent cccb2359cf
commit cea5492abc
3 changed files with 21 additions and 12 deletions

View File

@@ -122,7 +122,7 @@ void MapEditor::toggleMiniMap() {
mini_map_ = std::make_unique<MiniMap>(parseColor(settings_.minimap_bg), parseColor(settings_.minimap_conn)); mini_map_ = std::make_unique<MiniMap>(parseColor(settings_.minimap_bg), parseColor(settings_.minimap_conn));
mini_map_->on_navigate = [this](const std::string& room_name) { mini_map_->on_navigate = [this](const std::string& room_name) {
mini_map_visible_ = false; mini_map_visible_ = false;
// Navegar a la room (usa changeRoomWithEditor vía GameControl) reenter_ = true;
if (GameControl::exit_editor) { GameControl::exit_editor(); } if (GameControl::exit_editor) { GameControl::exit_editor(); }
if (GameControl::change_room && GameControl::change_room(room_name)) { if (GameControl::change_room && GameControl::change_room(room_name)) {
if (GameControl::enter_editor) { GameControl::enter_editor(); } if (GameControl::enter_editor) { GameControl::enter_editor(); }
@@ -175,14 +175,19 @@ void MapEditor::enter(std::shared_ptr<Room> room, std::shared_ptr<Player> player
yaml_backup_ = yaml_; // Copia profunda para revert yaml_backup_ = yaml_; // Copia profunda para revert
} }
// Guardar estado de invencibilidad y forzarla if (!reenter_) {
// Solo guardar estado previo en el primer enter (no en re-enter tras cambio de room)
invincible_before_editor_ = Options::cheats.invincible; invincible_before_editor_ = Options::cheats.invincible;
render_info_before_editor_ = RenderInfo::get()->isActive();
}
reenter_ = false;
// Forzar invencibilidad
Options::cheats.invincible = Options::Cheat::State::ENABLED; Options::cheats.invincible = Options::Cheat::State::ENABLED;
player_->setColor(); player_->setColor();
// Guardar estado de render_info y aplicar el setting del editor // Aplicar el setting de render_info del editor
render_info_before_editor_ = RenderInfo::get()->isActive(); if (settings_.show_render_info != RenderInfo::get()->isActive()) {
if (settings_.show_render_info != render_info_before_editor_) {
RenderInfo::get()->toggle(); RenderInfo::get()->toggle();
} }
@@ -209,14 +214,15 @@ void MapEditor::exit() {
active_ = false; active_ = false;
// Restaurar invencibilidad if (!reenter_) {
// Solo restaurar en el exit final (no en cambio de room)
Options::cheats.invincible = invincible_before_editor_; Options::cheats.invincible = invincible_before_editor_;
player_->setColor(); player_->setColor();
// Restaurar render_info
if (RenderInfo::get()->isActive() != render_info_before_editor_) { if (RenderInfo::get()->isActive() != render_info_before_editor_) {
RenderInfo::get()->toggle(); RenderInfo::get()->toggle();
} }
}
// Restaurar prompt de la consola y limpiar estado // Restaurar prompt de la consola y limpiar estado
selected_enemy_ = -1; selected_enemy_ = -1;

View File

@@ -49,6 +49,7 @@ class MapEditor {
auto showGrid(bool show) -> std::string; auto showGrid(bool show) -> std::string;
[[nodiscard]] auto isGridEnabled() const -> bool { return settings_.grid; } [[nodiscard]] auto isGridEnabled() const -> bool { return settings_.grid; }
void toggleMiniMap(); void toggleMiniMap();
void setReenter(bool value) { reenter_ = value; }
auto setMiniMapBg(const std::string& color) -> std::string; auto setMiniMapBg(const std::string& color) -> std::string;
auto setMiniMapConn(const std::string& color) -> std::string; auto setMiniMapConn(const std::string& color) -> std::string;
@@ -150,6 +151,7 @@ class MapEditor {
// Estado previo (para restaurar al salir) // Estado previo (para restaurar al salir)
Options::Cheat::State invincible_before_editor_{Options::Cheat::State::DISABLED}; Options::Cheat::State invincible_before_editor_{Options::Cheat::State::DISABLED};
bool render_info_before_editor_{false}; bool render_info_before_editor_{false};
bool reenter_{false}; // true cuando es un re-enter tras cambio de room (no tocar render_info)
}; };
#endif // _DEBUG #endif // _DEBUG

View File

@@ -570,6 +570,7 @@ static auto changeRoomWithEditor(const std::string& room_file) -> std::string {
// Si el editor está activo, salir primero (guarda y recarga la room actual) // Si el editor está activo, salir primero (guarda y recarga la room actual)
if (EDITOR_WAS_ACTIVE && GameControl::exit_editor) { if (EDITOR_WAS_ACTIVE && GameControl::exit_editor) {
MapEditor::get()->setReenter(true);
GameControl::exit_editor(); GameControl::exit_editor();
} }