Merge pull request #96569 from AThousandShips/fix_tree_button

[Editor] Prevent duplicate `Open in Editor` buttons in scene tree dock
This commit is contained in:
Rémi Verschelde 2024-09-05 17:44:19 +02:00
commit ddef729fb2
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -516,10 +516,14 @@ void SceneTreeEditor::_update_node_tooltip(Node *p_node, TreeItem *p_item) {
String tooltip = p_node->get_name();
if (p_node == get_scene_node() && p_node->get_scene_inherited_state().is_valid()) {
p_item->add_button(0, get_editor_theme_icon(SNAME("InstanceOptions")), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
if (p_item->get_button_by_id(0, BUTTON_SUBSCENE) == -1) {
p_item->add_button(0, get_editor_theme_icon(SNAME("InstanceOptions")), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
}
tooltip += String("\n" + TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path());
} else if (p_node != get_scene_node() && !p_node->get_scene_file_path().is_empty() && can_open_instance) {
p_item->add_button(0, get_editor_theme_icon(SNAME("InstanceOptions")), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
if (p_item->get_button_by_id(0, BUTTON_SUBSCENE) == -1) {
p_item->add_button(0, get_editor_theme_icon(SNAME("InstanceOptions")), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
}
tooltip += String("\n" + TTR("Instance:") + " " + p_node->get_scene_file_path());
}