summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/visual_script/visual_script_editor.cpp7
-rw-r--r--modules/visual_script/visual_script_nodes.cpp19
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp38
3 files changed, 48 insertions, 16 deletions
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 0399dbc87c..d6ab7a2ff8 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -1353,6 +1353,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
selected = ti->get_text(0);
function_name_edit->set_position(Input::get_singleton()->get_mouse_position() - Vector2(60, -10));
function_name_edit->popup();
+ function_name_box->set_text(selected);
+ function_name_box->select_all();
}
}
@@ -1757,8 +1759,7 @@ void VisualScriptEditor::_members_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> btn = p_event;
if (btn.is_valid() && btn->is_doubleclick()) {
TreeItem *ti = members->get_selected();
- ERR_FAIL_COND(!ti);
- if (ti->get_parent() == members->get_root()->get_children()) // to check if it's a function
+ if (ti && ti->get_parent() == members->get_root()->get_children()) // to check if it's a function
_center_on_node(ti->get_metadata(0), script->get_function_node_id(ti->get_metadata(0)));
}
}
@@ -4541,6 +4542,8 @@ void VisualScriptEditor::_member_option(int p_option) {
} else if (p_option == MEMBER_EDIT) {
selected = members->get_selected()->get_text(0);
function_name_edit->popup();
+ function_name_box->set_text(selected);
+ function_name_box->select_all();
}
} break;
case MEMBER_VARIABLE: {
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index dbcd3c19f8..957127fe61 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -4075,6 +4075,14 @@ VisualScriptDeconstruct::VisualScriptDeconstruct() {
type = Variant::NIL;
}
+template <Variant::Type T>
+static Ref<VisualScriptNode> create_node_deconst_typed(const String &p_name) {
+ Ref<VisualScriptDeconstruct> node;
+ node.instance();
+ node->set_deconstruct_type(T);
+ return node;
+}
+
void register_visual_script_nodes() {
VisualScriptLanguage::singleton->add_register_func("data/set_variable", create_node_generic<VisualScriptVariableSet>);
@@ -4132,7 +4140,16 @@ void register_visual_script_nodes() {
VisualScriptLanguage::singleton->add_register_func("operators/logic/in", create_op_node<Variant::OP_IN>);
VisualScriptLanguage::singleton->add_register_func("operators/logic/select", create_node_generic<VisualScriptSelect>);
- VisualScriptLanguage::singleton->add_register_func("functions/deconstruct", create_node_generic<VisualScriptDeconstruct>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::VECTOR2), create_node_deconst_typed<Variant::Type::VECTOR2>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::VECTOR3), create_node_deconst_typed<Variant::Type::VECTOR3>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::COLOR), create_node_deconst_typed<Variant::Type::COLOR>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::RECT2), create_node_deconst_typed<Variant::Type::RECT2>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::TRANSFORM2D), create_node_deconst_typed<Variant::Type::TRANSFORM2D>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::PLANE), create_node_deconst_typed<Variant::Type::PLANE>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::QUAT), create_node_deconst_typed<Variant::Type::QUAT>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::AABB), create_node_deconst_typed<Variant::Type::AABB>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::BASIS), create_node_deconst_typed<Variant::Type::BASIS>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::TRANSFORM), create_node_deconst_typed<Variant::Type::TRANSFORM>);
VisualScriptLanguage::singleton->add_register_func("functions/compose_array", create_node_generic<VisualScriptComposeArray>);
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index 0366801a11..42d4c5e209 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -271,6 +271,7 @@ void VisualScriptPropertySelector::_update_search() {
get_visual_node_names("flow_control/type_cast", Set<String>(), found, root, search_box);
get_visual_node_names("functions/built_in/print", Set<String>(), found, root, search_box);
get_visual_node_names("functions/by_type/" + Variant::get_type_name(type), Set<String>(), found, root, search_box);
+ get_visual_node_names("functions/deconstruct/" + Variant::get_type_name(type), Set<String>(), found, root, search_box);
get_visual_node_names("operators/compare/", Set<String>(), found, root, search_box);
if (type == Variant::INT) {
get_visual_node_names("operators/bitwise/", Set<String>(), found, root, search_box);
@@ -324,7 +325,7 @@ void VisualScriptPropertySelector::create_visualscript_item(const String &name,
}
}
-void VisualScriptPropertySelector::get_visual_node_names(const String &root_filter, const Set<String> &filter, bool &found, TreeItem *const root, LineEdit *const search_box) {
+void VisualScriptPropertySelector::get_visual_node_names(const String &root_filter, const Set<String> &p_modifiers, bool &found, TreeItem *const root, LineEdit *const search_box) {
Map<String, TreeItem *> path_cache;
List<String> fnodes;
@@ -335,27 +336,34 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
continue;
}
Vector<String> path = E->get().split("/");
- bool is_filter = false;
- for (Set<String>::Element *F = filter.front(); F; F = F->next()) {
- if (path.size() >= 2 && path[1].findn(F->get()) != -1) {
- is_filter = true;
+
+ // check if the name has the filter
+ bool in_filter = false;
+ Vector<String> tx_filters = search_box->get_text().split(" ");
+ for (int i = 0; i < tx_filters.size(); i++) {
+ if (tx_filters[i] == "") {
+ in_filter = true;
+ } else {
+ in_filter = false;
+ }
+ if (E->get().findn(tx_filters[i]) != -1) {
+ in_filter = true;
break;
}
}
- if (is_filter) {
+ if (!in_filter) {
continue;
}
- Vector<String> tx_filters = search_box->get_text().split(" ");
- for (int i = 0; i < tx_filters.size(); i++) {
- if (tx_filters[i] != String() && E->get().findn(tx_filters[i]) == -1) {
- is_filter = true;
- break;
- }
+ bool in_modifier = false | p_modifiers.empty();
+ for (Set<String>::Element *F = p_modifiers.front(); F && in_modifier; F = F->next()) {
+ if (E->get().findn(F->get()) != -1)
+ in_modifier = true;
}
- if (is_filter) {
+ if (!in_modifier) {
continue;
}
+
TreeItem *item = search_options->create_item(root);
Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(E->get());
Ref<VisualScriptOperator> vnode_operator = vnode;
@@ -376,6 +384,10 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
if (vnode_constructor.is_valid()) {
type_name = "Construct ";
}
+ Ref<VisualScriptDeconstruct> vnode_deconstruct = vnode;
+ if (vnode_deconstruct.is_valid()) {
+ type_name = "Deconstruct ";
+ }
Vector<String> desc = path[path.size() - 1].replace("(", " ").replace(")", " ").replace(",", " ").split(" ");
for (int i = 0; i < desc.size(); i++) {
desc.write[i] = desc[i].capitalize();