fix: bug que feia que en el editor, al canviar d'habitació el renderInfo tornara a eixir
This commit is contained in:
@@ -122,7 +122,7 @@ void MapEditor::toggleMiniMap() {
|
||||
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_visible_ = false;
|
||||
// Navegar a la room (usa changeRoomWithEditor vía GameControl)
|
||||
reenter_ = true;
|
||||
if (GameControl::exit_editor) { GameControl::exit_editor(); }
|
||||
if (GameControl::change_room && GameControl::change_room(room_name)) {
|
||||
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
|
||||
}
|
||||
|
||||
// Guardar estado de invencibilidad y forzarla
|
||||
invincible_before_editor_ = Options::cheats.invincible;
|
||||
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;
|
||||
player_->setColor();
|
||||
|
||||
// Guardar estado de render_info y aplicar el setting del editor
|
||||
render_info_before_editor_ = RenderInfo::get()->isActive();
|
||||
if (settings_.show_render_info != render_info_before_editor_) {
|
||||
// Aplicar el setting de render_info del editor
|
||||
if (settings_.show_render_info != RenderInfo::get()->isActive()) {
|
||||
RenderInfo::get()->toggle();
|
||||
}
|
||||
|
||||
@@ -209,13 +214,14 @@ void MapEditor::exit() {
|
||||
|
||||
active_ = false;
|
||||
|
||||
// Restaurar invencibilidad
|
||||
Options::cheats.invincible = invincible_before_editor_;
|
||||
player_->setColor();
|
||||
if (!reenter_) {
|
||||
// Solo restaurar en el exit final (no en cambio de room)
|
||||
Options::cheats.invincible = invincible_before_editor_;
|
||||
player_->setColor();
|
||||
|
||||
// Restaurar render_info
|
||||
if (RenderInfo::get()->isActive() != render_info_before_editor_) {
|
||||
RenderInfo::get()->toggle();
|
||||
if (RenderInfo::get()->isActive() != render_info_before_editor_) {
|
||||
RenderInfo::get()->toggle();
|
||||
}
|
||||
}
|
||||
|
||||
// Restaurar prompt de la consola y limpiar estado
|
||||
|
||||
@@ -49,6 +49,7 @@ class MapEditor {
|
||||
auto showGrid(bool show) -> std::string;
|
||||
[[nodiscard]] auto isGridEnabled() const -> bool { return settings_.grid; }
|
||||
void toggleMiniMap();
|
||||
void setReenter(bool value) { reenter_ = value; }
|
||||
auto setMiniMapBg(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)
|
||||
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)
|
||||
};
|
||||
|
||||
#endif // _DEBUG
|
||||
|
||||
@@ -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)
|
||||
if (EDITOR_WAS_ACTIVE && GameControl::exit_editor) {
|
||||
MapEditor::get()->setReenter(true);
|
||||
GameControl::exit_editor();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user