From 8b2e5f5993f139cd200ce022f63469bbc1e97fbe Mon Sep 17 00:00:00 2001 From: kitsdream <79633060+kitsdream@users.noreply.github.com> Date: Thu, 7 Sep 2023 13:45:28 +0800 Subject: [PATCH 1/2] Optimize the code and fix the problem of the search box being stuck. Optimize the code and fix the problem of the search box being stuck. Revert "Optimize the code and fix the problem of the search box being stuck." This reverts commit 210561eebdd0638e3e67f00a2d0ec72596ee4e52. Revert "Revert "Optimize the code and fix the problem of the search box being stuck."" This reverts commit 0f714b5fd3503cdc7d06f692ce267b712510b4a0. Revert "Revert "Revert "Optimize the code and fix the problem of the search box being stuck.""" This reverts commit ef9e0ff596b6773c86e9d245e73d71386c4ab350. From ded87a25ffa08ab23cb3a6a983a9c50b3ebd92e5 Mon Sep 17 00:00:00 2001 From: kitsdream <15752004@qq.com> Date: Mon, 25 Sep 2023 00:17:59 +0800 Subject: [PATCH 2/2] Fix the display of the tree diagram and optimize performance Fix the display of the tree diagram and optimize performance. --- editor/visual_script_editor.cpp | 26 +- editor/visual_script_property_selector.cpp | 563 +++++++++++++-------- 2 files changed, 356 insertions(+), 233 deletions(-) diff --git a/editor/visual_script_editor.cpp b/editor/visual_script_editor.cpp index 0417c96..a5e6d9b 100644 --- a/editor/visual_script_editor.cpp +++ b/editor/visual_script_editor.cpp @@ -751,11 +751,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) { GraphNode *gnode = memnew(GraphNode); gnode->set_title(node->get_caption()); gnode->set_position_offset(pos * EDSCALE); - if (error_line == E) { - gnode->set_overlay(GraphNode::OVERLAY_POSITION); - } else if (node->is_breakpoint()) { - gnode->set_overlay(GraphNode::OVERLAY_BREAKPOINT); - } gnode->set_meta("__vnode", node); gnode->set_name(itos(E)); @@ -764,14 +759,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->connect("close_request", callable_mp(this, &VisualScriptEditor::_remove_node).bind(E), CONNECT_DEFERRED); - - { - Ref v = node; - if (!v.is_valid()) { - gnode->set_show_close_button(true); - } - } - bool has_gnode_text = false; Ref nd_list = node; @@ -2116,7 +2103,7 @@ void VisualScriptEditor::_on_nodes_delete() { for (int i = 0; i < graph->get_child_count(); i++) { GraphNode *gn = Object::cast_to(graph->get_child(i)); if (gn) { - if (gn->is_selected() && gn->is_close_button_visible()) { + if (gn->is_selected()) { to_erase.push_back(gn->get_name().operator String().to_int()); } } @@ -2168,7 +2155,7 @@ void VisualScriptEditor::_on_nodes_duplicate() { for (int i = 0; i < graph->get_child_count(); i++) { GraphNode *gn = Object::cast_to(graph->get_child(i)); if (gn) { - if (gn->is_selected() && gn->is_close_button_visible()) { + if (gn->is_selected()) { int id = gn->get_name().operator String().to_int(); to_duplicate.insert(id); } @@ -3663,7 +3650,12 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, Ref vnode; Ref vnode_old; - bool port_node_exists = script->has_node(port_action_node); + + bool port_node_exists; + if (script->get_node(port_action_node).is_valid()) { + port_node_exists = script->has_node(port_action_node); + } + if (port_node_exists && p_connecting) { vnode_old = script->get_node(port_action_node); } @@ -4379,7 +4371,7 @@ void VisualScriptEditor::_notification(int p_what) { func_input_scroll->add_theme_style_override( "bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - Ref tm = EditorNode::get_singleton()-> get_editor_theme(); + Ref tm = EditorNode::get_singleton()->get_editor_theme(); bool dark_theme = tm->get_constant("dark_theme", "Editor"); diff --git a/editor/visual_script_property_selector.cpp b/editor/visual_script_property_selector.cpp index 4dc2445..909dce8 100644 --- a/editor/visual_script_property_selector.cpp +++ b/editor/visual_script_property_selector.cpp @@ -46,21 +46,34 @@ #include "scene/main/window.h" void VisualScriptPropertySelector::_update_icons() { - search_box->set_right_icon(results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + search_box->set_right_icon( + results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); - search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + search_box->add_theme_icon_override( + "right_icon", + results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - search_visual_script_nodes->set_icon(results_tree->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons"))); - search_classes->set_icon(results_tree->get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))); - search_methods->set_icon(results_tree->get_theme_icon(SNAME("MemberMethod"), SNAME("EditorIcons"))); - search_operators->set_icon(results_tree->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - search_signals->set_icon(results_tree->get_theme_icon(SNAME("MemberSignal"), SNAME("EditorIcons"))); - search_constants->set_icon(results_tree->get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); - search_properties->set_icon(results_tree->get_theme_icon(SNAME("MemberProperty"), SNAME("EditorIcons"))); - search_theme_items->set_icon(results_tree->get_theme_icon(SNAME("MemberTheme"), SNAME("EditorIcons"))); + search_visual_script_nodes->set_icon(results_tree->get_theme_icon( + SNAME("VisualScript"), SNAME("EditorIcons"))); + search_classes->set_icon( + results_tree->get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))); + search_methods->set_icon(results_tree->get_theme_icon(SNAME("MemberMethod"), + SNAME("EditorIcons"))); + search_operators->set_icon( + results_tree->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + search_signals->set_icon(results_tree->get_theme_icon(SNAME("MemberSignal"), + SNAME("EditorIcons"))); + search_constants->set_icon(results_tree->get_theme_icon( + SNAME("MemberConstant"), SNAME("EditorIcons"))); + search_properties->set_icon(results_tree->get_theme_icon( + SNAME("MemberProperty"), SNAME("EditorIcons"))); + search_theme_items->set_icon( + results_tree->get_theme_icon(SNAME("MemberTheme"), SNAME("EditorIcons"))); - case_sensitive_button->set_icon(results_tree->get_theme_icon(SNAME("MatchCase"), SNAME("EditorIcons"))); - hierarchy_button->set_icon(results_tree->get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); + case_sensitive_button->set_icon( + results_tree->get_theme_icon(SNAME("MatchCase"), SNAME("EditorIcons"))); + hierarchy_button->set_icon( + results_tree->get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); } void VisualScriptPropertySelector::_sbox_input(const Ref &p_ie) { @@ -107,12 +120,14 @@ void VisualScriptPropertySelector::_confirmed() { if (!ti) { return; } - emit_signal(SNAME("selected"), ti->get_metadata(0), ti->get_metadata(1), connecting); + emit_signal(SNAME("selected"), ti->get_metadata(0), ti->get_metadata(1), + connecting); set_visible(false); } void VisualScriptPropertySelector::_item_selected() { - help_bit->set_text(results_tree->get_selected()->get_meta("description", "No description available")); + help_bit->set_text(results_tree->get_selected()->get_meta( + "description", "No description available")); } void VisualScriptPropertySelector::_hide_requested() { @@ -154,15 +169,14 @@ void VisualScriptPropertySelector::select_method_from_base_type(const String &p_ type = Variant::NIL; connecting = p_connecting; - if (clear_text) { - if (p_virtuals_only) { - search_box->set_text("._"); // show all _methods - search_box->set_caret_column(2); - } else { - search_box->set_text("."); // show all methods. - search_box->set_caret_column(1); - } + if (clear_text && !p_virtuals_only) { + search_box->set_text("."); // show all methods. + search_box->set_caret_column(1); + } else { + search_box->set_text("._"); // show all _methods + search_box->set_caret_column(2); } + search_box->select_all(); search_visual_script_nodes->set_pressed(false); search_classes->set_pressed(false); @@ -193,7 +207,7 @@ void VisualScriptPropertySelector::select_from_visual_script(const Ref