Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TileSet not disappearing on deselecting TileMap #80529

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions editor/plugins/tiles/tiles_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -419,6 +426,11 @@ TileMapEditorPlugin::~TileMapEditorPlugin() {

void TileSetEditorPlugin::edit(Object *p_object) {
editor->edit(Ref<TileSet>(p_object));
if (p_object) {
edited_tileset = p_object->get_instance_id();
} else {
edited_tileset = ObjectID();
}
}

bool TileSetEditorPlugin::handles(Object *p_object) const {
Expand All @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion editor/plugins/tiles/tiles_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
};
Expand Down