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 editor visiblity and selection context #58361

Merged
merged 1 commit into from
Jul 28, 2022
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
12 changes: 10 additions & 2 deletions editor/plugins/tiles/tiles_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ void TilesEditorPlugin::_update_editors() {
// Update the viewport.
CanvasItemEditor::get_singleton()->update_viewport();

// Make sure the tile set editor is visible if we have one assigned.
tileset_editor_button->set_visible(is_visible && tile_set.is_valid());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I understand why this is needed. Wasn't this already working?
Reading what is in make_visible() it seems like this is already done.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groud Sorry, I completely forgot about this, but I remember it now because I'm doing another pass over all the editor plugins at the moment. With regards to this visibility check, it needs both checks to be successful otherwise the tileset button will still be visible even when you aren't highlighting a tileset node.


// Update visibility of bottom panel buttons.
if (tileset_editor_button->is_pressed() && !tile_set.is_valid()) {
if (tile_map) {
Expand All @@ -184,12 +187,14 @@ void TilesEditorPlugin::_notification(int p_what) {
}

void TilesEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
is_visible = p_visible;

if (is_visible) {
// Disable and hide invalid editors.
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
tileset_editor_button->set_visible(tile_set.is_valid());
tilemap_editor_button->set_visible(tile_map);
if (tile_map) {
if (tile_map && !is_editing_tile_set) {
EditorNode::get_singleton()->make_bottom_panel_item_visible(tilemap_editor);
} else {
EditorNode::get_singleton()->make_bottom_panel_item_visible(tileset_editor);
Expand Down Expand Up @@ -348,6 +353,8 @@ void TilesEditorPlugin::edit(Object *p_object) {

// Update edited objects.
tile_set = Ref<TileSet>();
is_editing_tile_set = false;

if (p_object) {
if (p_object->is_class("TileMap")) {
tile_map_id = p_object->get_instance_id();
Expand All @@ -362,6 +369,7 @@ void TilesEditorPlugin::edit(Object *p_object) {
tile_map_id = ObjectID();
}
}
is_editing_tile_set = true;
EditorNode::get_singleton()->make_bottom_panel_item_visible(tileset_editor);
}
}
Expand Down
3 changes: 3 additions & 0 deletions editor/plugins/tiles/tiles_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ class TilesEditorPlugin : public EditorPlugin {
};

private:
bool is_visible = false;

bool tile_map_changed_needs_update = false;
ObjectID tile_map_id;
Ref<TileSet> tile_set;
bool is_editing_tile_set = false;

Button *tilemap_editor_button;
TileMapEditor *tilemap_editor;
Expand Down