| 393 | } |
| 394 | |
| 395 | void SceneTreeEditor::_update_node(Node *p_node, TreeItem *p_item, bool p_part_of_subscene) { |
| 396 | // Reset item properties that are not explicitly set in the default case. |
| 397 | p_item->clear_buttons(); |
| 398 | p_item->remove_meta(SNAME("custom_color")); |
| 399 | p_item->clear_custom_color(0); |
| 400 | p_item->set_selectable(0, true); |
| 401 | |
| 402 | p_item->set_text(0, p_node->get_name()); |
| 403 | p_item->set_text_overrun_behavior(0, TextServer::OVERRUN_NO_TRIMMING); |
| 404 | if (can_rename && !p_part_of_subscene) { |
| 405 | p_item->set_editable(0, true); |
| 406 | } |
| 407 | |
| 408 | if (can_rename) { |
| 409 | bool collapsed = p_node->is_displayed_folded(); |
| 410 | if (collapsed) { |
| 411 | p_item->set_collapsed(true); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(p_node, "Node"); |
| 416 | p_item->set_icon(0, icon); |
| 417 | p_item->set_metadata(0, p_node->get_path()); |
| 418 | |
| 419 | if (!p_node->is_connected("child_order_changed", callable_mp(this, &SceneTreeEditor::_node_child_order_changed))) { |
| 420 | p_node->connect("child_order_changed", callable_mp(this, &SceneTreeEditor::_node_child_order_changed).bind(p_node)); |
| 421 | } |
| 422 | |
| 423 | if (!p_node->is_connected("editor_state_changed", callable_mp(this, &SceneTreeEditor::_node_editor_state_changed))) { |
| 424 | p_node->connect("editor_state_changed", callable_mp(this, &SceneTreeEditor::_node_editor_state_changed).bind(p_node)); |
| 425 | } |
| 426 | |
| 427 | if (connecting_signal || (can_open_instance && is_scene_tree_dock)) { |
| 428 | if (!p_node->is_connected(CoreStringName(script_changed), callable_mp(this, &SceneTreeEditor::_node_script_changed))) { |
| 429 | p_node->connect(CoreStringName(script_changed), callable_mp(this, &SceneTreeEditor::_node_script_changed).bind(p_node)); |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | if (connecting_signal) { |
| 434 | // Add script icons for all scripted nodes. |
| 435 | Ref<Script> scr = p_node->get_script(); |
| 436 | if (scr.is_valid()) { |
| 437 | p_item->add_button(0, get_editor_theme_icon(SNAME("Script")), BUTTON_SCRIPT); |
| 438 | if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == scr) { |
| 439 | // Disable button on custom scripts (pure visual cue). |
| 440 | p_item->set_button_disabled(0, p_item->get_button_count(0) - 1, true); |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | if (connect_to_script_mode) { |
| 446 | Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); |
| 447 | |
| 448 | Ref<Script> scr = p_node->get_script(); |
| 449 | bool has_custom_script = scr.is_valid() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) == scr; |
| 450 | if (scr.is_null() || has_custom_script) { |
| 451 | _set_item_custom_color(p_item, get_theme_color(SNAME("font_disabled_color"), EditorStringName(Editor))); |
| 452 | p_item->set_selectable(0, false); |
nothing calls this directly
no test coverage detected