From 6b7829b5ffa5edb36c31251ead39e13fc0d8a1a6 Mon Sep 17 00:00:00 2001 From: kobewi Date: Sat, 12 Aug 2023 00:26:16 +0200 Subject: [PATCH] Fix TileSet not disappearing on deselecting TileMap --- editor/plugins/tiles/tiles_editor_plugin.cpp | 16 ++++++++++++++++ editor/plugins/tiles/tiles_editor_plugin.h | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index 121b70a74fe..2220b977594 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -362,6 +362,13 @@ void TileMapEditorPlugin::edit(Object *p_object) { tile_set_plugin_singleton->make_visible(true); edited_tileset = tile_map->get_tileset()->get_instance_id(); } + } else if (edited_tileset.is_valid()) { + // Hide the TileSet editor, unless another TileSet is being edited. + if (tile_set_plugin_singleton->get_edited_tileset() == edited_tileset) { + tile_set_plugin_singleton->edit(nullptr); + tile_set_plugin_singleton->make_visible(false); + } + edited_tileset = ObjectID(); } } @@ -419,6 +426,11 @@ TileMapEditorPlugin::~TileMapEditorPlugin() { void TileSetEditorPlugin::edit(Object *p_object) { editor->edit(Ref(p_object)); + if (p_object) { + edited_tileset = p_object->get_instance_id(); + } else { + edited_tileset = ObjectID(); + } } bool TileSetEditorPlugin::handles(Object *p_object) const { @@ -439,6 +451,10 @@ void TileSetEditorPlugin::make_visible(bool p_visible) { } } +ObjectID TileSetEditorPlugin::get_edited_tileset() const { + return edited_tileset; +} + TileSetEditorPlugin::TileSetEditorPlugin() { DEV_ASSERT(tile_map_plugin_singleton); tile_set_plugin_singleton = this; diff --git a/editor/plugins/tiles/tiles_editor_plugin.h b/editor/plugins/tiles/tiles_editor_plugin.h index f8e944af818..045737b6ed4 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.h +++ b/editor/plugins/tiles/tiles_editor_plugin.h @@ -118,7 +118,7 @@ class TileMapEditorPlugin : public EditorPlugin { TileMap *tile_map = nullptr; bool tile_map_changed_needs_update = false; - ObjectID edited_tileset; + ObjectID edited_tileset; // The TileSet associated with the TileMap. void _tile_map_changed(); void _update_tile_map(); @@ -147,11 +147,15 @@ class TileSetEditorPlugin : public EditorPlugin { TileSetEditor *editor = nullptr; Button *button = nullptr; + ObjectID edited_tileset; + public: virtual void edit(Object *p_object) override; virtual bool handles(Object *p_object) const override; virtual void make_visible(bool p_visible) override; + ObjectID get_edited_tileset() const; + TileSetEditorPlugin(); ~TileSetEditorPlugin(); };