2018-05-13 03:34:35 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* visual_script_property_selector.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/*************************************************************************/
|
2020-01-01 10:16:22 +00:00
|
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
2018-05-13 03:34:35 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
#include "visual_script_property_selector.h"
|
|
|
|
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/os/keyboard.h"
|
2018-09-02 21:40:51 +00:00
|
|
|
#include "editor/editor_node.h"
|
2019-10-09 14:11:04 +00:00
|
|
|
#include "editor/editor_scale.h"
|
2018-05-13 03:34:35 +00:00
|
|
|
#include "modules/visual_script/visual_script.h"
|
|
|
|
#include "modules/visual_script/visual_script_builtin_funcs.h"
|
|
|
|
#include "modules/visual_script/visual_script_flow_control.h"
|
|
|
|
#include "modules/visual_script/visual_script_func_nodes.h"
|
|
|
|
#include "modules/visual_script/visual_script_nodes.h"
|
|
|
|
#include "scene/main/node.h"
|
2020-03-04 01:51:12 +00:00
|
|
|
#include "scene/main/window.h"
|
2018-05-13 03:34:35 +00:00
|
|
|
|
|
|
|
void VisualScriptPropertySelector::_text_changed(const String &p_newtext) {
|
|
|
|
_update_search();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptPropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) {
|
|
|
|
Ref<InputEventKey> k = p_ie;
|
|
|
|
|
|
|
|
if (k.is_valid()) {
|
2018-04-05 17:59:35 +00:00
|
|
|
switch (k->get_keycode()) {
|
2018-05-13 03:34:35 +00:00
|
|
|
case KEY_UP:
|
|
|
|
case KEY_DOWN:
|
|
|
|
case KEY_PAGEUP:
|
|
|
|
case KEY_PAGEDOWN: {
|
|
|
|
search_options->call("_gui_input", k);
|
|
|
|
search_box->accept_event();
|
|
|
|
|
|
|
|
TreeItem *root = search_options->get_root();
|
2020-05-14 14:41:43 +00:00
|
|
|
if (!root->get_children()) {
|
2018-05-13 03:34:35 +00:00
|
|
|
break;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
|
|
|
|
TreeItem *current = search_options->get_selected();
|
|
|
|
|
|
|
|
TreeItem *item = search_options->get_next_selected(root);
|
|
|
|
while (item) {
|
|
|
|
item->deselect(0);
|
|
|
|
item = search_options->get_next_selected(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
current->select(0);
|
|
|
|
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptPropertySelector::_update_search() {
|
|
|
|
set_title(TTR("Search VisualScript"));
|
|
|
|
|
|
|
|
search_options->clear();
|
|
|
|
help_bit->set_text("");
|
|
|
|
|
|
|
|
TreeItem *root = search_options->create_item();
|
|
|
|
bool found = false;
|
2019-04-26 12:40:35 +00:00
|
|
|
StringName base = base_type;
|
|
|
|
List<StringName> base_list;
|
|
|
|
while (base) {
|
|
|
|
base_list.push_back(base);
|
|
|
|
base = ClassDB::get_parent_class_nocheck(base);
|
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
|
2019-04-26 12:40:35 +00:00
|
|
|
for (List<StringName>::Element *E = base_list.front(); E; E = E->next()) {
|
|
|
|
List<MethodInfo> methods;
|
2018-05-13 03:34:35 +00:00
|
|
|
List<PropertyInfo> props;
|
2020-04-01 23:20:12 +00:00
|
|
|
TreeItem *category = nullptr;
|
2019-06-11 18:43:37 +00:00
|
|
|
Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
|
2020-03-12 12:37:40 +00:00
|
|
|
vbc->get_theme_icon("Variant", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("bool", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("int", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("float", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("String", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Vector2", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Rect2", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Vector3", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Transform2D", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Plane", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Quat", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("AABB", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Basis", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Transform", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Color", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Path", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("RID", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Object", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Dictionary", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("Array", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("PackedByteArray", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("PackedInt32Array", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("PackedFloat32Array", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("PackedInt64Array", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("PackedFloat64Array", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("PackedStringArray", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("PackedVector2Array", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("PackedVector3Array", "EditorIcons"),
|
|
|
|
vbc->get_theme_icon("PackedColorArray", "EditorIcons")
|
2018-05-13 03:34:35 +00:00
|
|
|
};
|
2019-04-26 12:40:35 +00:00
|
|
|
{
|
|
|
|
String b = String(E->get());
|
|
|
|
category = search_options->create_item(root);
|
2019-08-07 10:54:30 +00:00
|
|
|
if (category) {
|
|
|
|
category->set_text(0, b.replace_first("*", ""));
|
|
|
|
category->set_selectable(0, false);
|
2019-06-11 18:43:37 +00:00
|
|
|
Ref<Texture2D> icon;
|
2019-08-07 10:54:30 +00:00
|
|
|
String rep = b.replace("*", "");
|
|
|
|
icon = EditorNode::get_singleton()->get_class_icon(rep);
|
|
|
|
category->set_icon(0, icon);
|
|
|
|
}
|
2019-04-26 12:40:35 +00:00
|
|
|
}
|
|
|
|
if (properties || seq_connect) {
|
|
|
|
if (instance) {
|
|
|
|
instance->get_property_list(&props, true);
|
|
|
|
} else {
|
|
|
|
Object *obj = ObjectDB::get_instance(script);
|
|
|
|
if (Object::cast_to<Script>(obj)) {
|
|
|
|
Object::cast_to<Script>(obj)->get_script_property_list(&props);
|
2018-05-13 03:34:35 +00:00
|
|
|
} else {
|
2019-04-26 12:40:35 +00:00
|
|
|
ClassDB::get_property_list(E->get(), &props, true);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-26 12:40:35 +00:00
|
|
|
for (List<PropertyInfo>::Element *F = props.front(); F; F = F->next()) {
|
2020-05-14 14:41:43 +00:00
|
|
|
if (!(F->get().usage & PROPERTY_USAGE_EDITOR) && !(F->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) {
|
2019-04-26 12:40:35 +00:00
|
|
|
continue;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2019-04-26 12:40:35 +00:00
|
|
|
|
2020-05-14 14:41:43 +00:00
|
|
|
if (type_filter.size() && type_filter.find(F->get().type) == -1) {
|
2019-04-26 12:40:35 +00:00
|
|
|
continue;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2019-04-26 12:40:35 +00:00
|
|
|
|
|
|
|
// capitalize() also converts underscore to space, we'll match again both possible styles
|
|
|
|
String get_text_raw = String(vformat(TTR("Get %s"), F->get().name));
|
|
|
|
String get_text = get_text_raw.capitalize();
|
|
|
|
String set_text_raw = String(vformat(TTR("Set %s"), F->get().name));
|
|
|
|
String set_text = set_text_raw.capitalize();
|
|
|
|
String input = search_box->get_text().capitalize();
|
|
|
|
|
|
|
|
if (input == String() || get_text_raw.findn(input) != -1 || get_text.findn(input) != -1) {
|
|
|
|
TreeItem *item = search_options->create_item(category ? category : root);
|
|
|
|
item->set_text(0, get_text);
|
|
|
|
item->set_metadata(0, F->get().name);
|
|
|
|
item->set_icon(0, type_icons[F->get().type]);
|
|
|
|
item->set_metadata(1, "get");
|
2020-05-14 09:00:19 +00:00
|
|
|
item->set_collapsed(true);
|
2019-04-26 12:40:35 +00:00
|
|
|
item->set_selectable(0, true);
|
|
|
|
item->set_selectable(1, false);
|
|
|
|
item->set_selectable(2, false);
|
|
|
|
item->set_metadata(2, connecting);
|
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
|
2019-04-26 12:40:35 +00:00
|
|
|
if (input == String() || set_text_raw.findn(input) != -1 || set_text.findn(input) != -1) {
|
|
|
|
TreeItem *item = search_options->create_item(category ? category : root);
|
|
|
|
item->set_text(0, set_text);
|
|
|
|
item->set_metadata(0, F->get().name);
|
|
|
|
item->set_icon(0, type_icons[F->get().type]);
|
|
|
|
item->set_metadata(1, "set");
|
|
|
|
item->set_selectable(0, true);
|
|
|
|
item->set_selectable(1, false);
|
|
|
|
item->set_selectable(2, false);
|
|
|
|
item->set_metadata(2, connecting);
|
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-26 12:40:35 +00:00
|
|
|
{
|
|
|
|
if (type != Variant::NIL) {
|
|
|
|
Variant v;
|
2020-02-19 19:27:19 +00:00
|
|
|
Callable::CallError ce;
|
2020-04-01 23:20:12 +00:00
|
|
|
v = Variant::construct(type, nullptr, 0, ce);
|
2019-04-26 12:40:35 +00:00
|
|
|
v.get_method_list(&methods);
|
|
|
|
} else {
|
|
|
|
Object *obj = ObjectDB::get_instance(script);
|
|
|
|
if (Object::cast_to<Script>(obj)) {
|
|
|
|
Object::cast_to<Script>(obj)->get_script_method_list(&methods);
|
|
|
|
}
|
2019-09-13 19:14:12 +00:00
|
|
|
|
|
|
|
ClassDB::get_method_list(E->get(), &methods, true, true);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-26 12:40:35 +00:00
|
|
|
for (List<MethodInfo>::Element *M = methods.front(); M; M = M->next()) {
|
|
|
|
String name = M->get().name.get_slice(":", 0);
|
2020-05-14 14:41:43 +00:00
|
|
|
if (name.begins_with("_") && !(M->get().flags & METHOD_FLAG_VIRTUAL)) {
|
2019-04-26 12:40:35 +00:00
|
|
|
continue;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
|
2020-05-14 14:41:43 +00:00
|
|
|
if (virtuals_only && !(M->get().flags & METHOD_FLAG_VIRTUAL)) {
|
2019-04-26 12:40:35 +00:00
|
|
|
continue;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
|
2020-05-14 14:41:43 +00:00
|
|
|
if (!virtuals_only && (M->get().flags & METHOD_FLAG_VIRTUAL)) {
|
2019-04-26 12:40:35 +00:00
|
|
|
continue;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-09-30 04:33:21 +00:00
|
|
|
|
2019-04-26 12:40:35 +00:00
|
|
|
MethodInfo mi = M->get();
|
|
|
|
String desc_arguments;
|
|
|
|
if (mi.arguments.size() > 0) {
|
|
|
|
desc_arguments = "(";
|
|
|
|
for (int i = 0; i < mi.arguments.size(); i++) {
|
|
|
|
if (i > 0) {
|
|
|
|
desc_arguments += ", ";
|
|
|
|
}
|
|
|
|
if (mi.arguments[i].type == Variant::NIL) {
|
|
|
|
desc_arguments += "var";
|
|
|
|
} else if (mi.arguments[i].name.find(":") != -1) {
|
|
|
|
desc_arguments += mi.arguments[i].name.get_slice(":", 1);
|
|
|
|
mi.arguments[i].name = mi.arguments[i].name.get_slice(":", 0);
|
|
|
|
} else {
|
|
|
|
desc_arguments += Variant::get_type_name(mi.arguments[i].type);
|
|
|
|
}
|
2018-09-30 04:33:21 +00:00
|
|
|
}
|
2019-04-26 12:40:35 +00:00
|
|
|
desc_arguments += ")";
|
2018-09-30 04:33:21 +00:00
|
|
|
}
|
2019-04-26 12:40:35 +00:00
|
|
|
String desc_raw = mi.name + desc_arguments;
|
|
|
|
String desc = desc_raw.capitalize().replace("( ", "(");
|
2018-05-13 03:34:35 +00:00
|
|
|
|
2019-04-26 12:40:35 +00:00
|
|
|
if (search_box->get_text() != String() &&
|
|
|
|
name.findn(search_box->get_text()) == -1 &&
|
|
|
|
desc.findn(search_box->get_text()) == -1 &&
|
|
|
|
desc_raw.findn(search_box->get_text()) == -1) {
|
|
|
|
continue;
|
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
|
2019-04-26 12:40:35 +00:00
|
|
|
TreeItem *item = search_options->create_item(category ? category : root);
|
|
|
|
item->set_text(0, desc);
|
2020-03-12 12:37:40 +00:00
|
|
|
item->set_icon(0, vbc->get_theme_icon("MemberMethod", "EditorIcons"));
|
2019-04-26 12:40:35 +00:00
|
|
|
item->set_metadata(0, name);
|
|
|
|
item->set_selectable(0, true);
|
2018-05-13 03:34:35 +00:00
|
|
|
|
2019-04-26 12:40:35 +00:00
|
|
|
item->set_metadata(1, "method");
|
2020-05-14 09:00:19 +00:00
|
|
|
item->set_collapsed(true);
|
2019-04-26 12:40:35 +00:00
|
|
|
item->set_selectable(1, false);
|
2018-05-13 03:34:35 +00:00
|
|
|
|
2019-04-26 12:40:35 +00:00
|
|
|
item->set_selectable(2, false);
|
|
|
|
item->set_metadata(2, connecting);
|
|
|
|
}
|
2018-07-25 18:49:41 +00:00
|
|
|
|
2020-04-01 23:20:12 +00:00
|
|
|
if (category && category->get_children() == nullptr) {
|
2018-05-13 03:34:35 +00:00
|
|
|
memdelete(category); //old category was unused
|
|
|
|
}
|
|
|
|
}
|
2019-04-26 12:21:28 +00:00
|
|
|
if (properties) {
|
|
|
|
if (!seq_connect && !visual_script_generic) {
|
|
|
|
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);
|
2019-09-29 11:55:09 +00:00
|
|
|
get_visual_node_names("functions/deconstruct/" + Variant::get_type_name(type), Set<String>(), found, root, search_box);
|
2019-04-26 12:21:28 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
if (type == Variant::BOOL) {
|
|
|
|
get_visual_node_names("operators/logic/", Set<String>(), found, root, search_box);
|
|
|
|
}
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
if (type == Variant::BOOL || type == Variant::INT || type == Variant::FLOAT || type == Variant::VECTOR2 || type == Variant::VECTOR3) {
|
2019-04-26 12:21:28 +00:00
|
|
|
get_visual_node_names("operators/math/", Set<String>(), found, root, search_box);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq_connect && !visual_script_generic) {
|
|
|
|
String text = search_box->get_text();
|
|
|
|
create_visualscript_item(String("VisualScriptCondition"), root, text, String("Condition"));
|
|
|
|
create_visualscript_item(String("VisualScriptSwitch"), root, text, String("Switch"));
|
|
|
|
create_visualscript_item(String("VisualScriptSequence"), root, text, String("Sequence"));
|
|
|
|
create_visualscript_item(String("VisualScriptIterator"), root, text, String("Iterator"));
|
|
|
|
create_visualscript_item(String("VisualScriptWhile"), root, text, String("While"));
|
|
|
|
create_visualscript_item(String("VisualScriptReturn"), root, text, String("Return"));
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-04-26 12:40:35 +00:00
|
|
|
if ((properties || seq_connect) && visual_script_generic) {
|
2019-04-26 12:21:28 +00:00
|
|
|
get_visual_node_names("", Set<String>(), found, root, search_box);
|
|
|
|
}
|
|
|
|
|
2018-05-13 03:34:35 +00:00
|
|
|
TreeItem *selected_item = search_options->search_item_text(search_box->get_text());
|
2020-04-01 23:20:12 +00:00
|
|
|
if (!found && selected_item != nullptr) {
|
2018-05-13 03:34:35 +00:00
|
|
|
selected_item->select(0);
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
|
2020-04-01 23:20:12 +00:00
|
|
|
get_ok()->set_disabled(root->get_children() == nullptr);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptPropertySelector::create_visualscript_item(const String &name, TreeItem *const root, const String &search_input, const String &text) {
|
|
|
|
if (search_input == String() || text.findn(search_input) != -1) {
|
|
|
|
TreeItem *item = search_options->create_item(root);
|
|
|
|
item->set_text(0, text);
|
2020-03-12 12:37:40 +00:00
|
|
|
item->set_icon(0, vbc->get_theme_icon("VisualScript", "EditorIcons"));
|
2018-05-13 03:34:35 +00:00
|
|
|
item->set_metadata(0, name);
|
|
|
|
item->set_metadata(1, "action");
|
|
|
|
item->set_selectable(0, true);
|
2020-05-14 09:00:19 +00:00
|
|
|
item->set_collapsed(true);
|
2018-05-13 03:34:35 +00:00
|
|
|
item->set_selectable(1, false);
|
2018-07-25 18:49:41 +00:00
|
|
|
item->set_selectable(2, false);
|
|
|
|
item->set_metadata(2, connecting);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-29 11:55:09 +00:00
|
|
|
void VisualScriptPropertySelector::get_visual_node_names(const String &root_filter, const Set<String> &p_modifiers, bool &found, TreeItem *const root, LineEdit *const search_box) {
|
2018-05-13 03:34:35 +00:00
|
|
|
Map<String, TreeItem *> path_cache;
|
|
|
|
|
|
|
|
List<String> fnodes;
|
|
|
|
VisualScriptLanguage::singleton->get_registered_node_names(&fnodes);
|
|
|
|
|
|
|
|
for (List<String>::Element *E = fnodes.front(); E; E = E->next()) {
|
|
|
|
if (!E->get().begins_with(root_filter)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Vector<String> path = E->get().split("/");
|
2019-09-29 11:55:09 +00:00
|
|
|
|
|
|
|
// 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;
|
2018-05-13 03:34:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-09-29 11:55:09 +00:00
|
|
|
if (!in_filter) {
|
2018-05-13 03:34:35 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-02-23 08:28:54 +00:00
|
|
|
bool in_modifier = p_modifiers.empty();
|
2019-09-29 11:55:09 +00:00
|
|
|
for (Set<String>::Element *F = p_modifiers.front(); F && in_modifier; F = F->next()) {
|
2020-05-14 14:41:43 +00:00
|
|
|
if (E->get().findn(F->get()) != -1) {
|
2019-09-29 11:55:09 +00:00
|
|
|
in_modifier = true;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2019-09-13 19:14:12 +00:00
|
|
|
}
|
2019-09-29 11:55:09 +00:00
|
|
|
if (!in_modifier) {
|
2018-05-13 03:34:35 +00:00
|
|
|
continue;
|
|
|
|
}
|
2019-09-29 11:55:09 +00:00
|
|
|
|
2018-05-13 03:34:35 +00:00
|
|
|
TreeItem *item = search_options->create_item(root);
|
2019-09-13 19:14:12 +00:00
|
|
|
Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(E->get());
|
|
|
|
Ref<VisualScriptOperator> vnode_operator = vnode;
|
2018-05-13 03:34:35 +00:00
|
|
|
String type_name;
|
2019-09-13 19:14:12 +00:00
|
|
|
if (vnode_operator.is_valid()) {
|
2018-05-13 03:34:35 +00:00
|
|
|
String type;
|
|
|
|
if (path.size() >= 2) {
|
|
|
|
type = path[1];
|
|
|
|
}
|
|
|
|
type_name = type.capitalize() + " ";
|
|
|
|
}
|
2019-09-13 19:14:12 +00:00
|
|
|
Ref<VisualScriptFunctionCall> vnode_function_call = vnode;
|
|
|
|
if (vnode_function_call.is_valid()) {
|
2018-05-13 03:34:35 +00:00
|
|
|
String basic_type = Variant::get_type_name(vnode_function_call->get_basic_type());
|
|
|
|
type_name = basic_type.capitalize() + " ";
|
|
|
|
}
|
2019-09-13 19:14:12 +00:00
|
|
|
Ref<VisualScriptConstructor> vnode_constructor = vnode;
|
|
|
|
if (vnode_constructor.is_valid()) {
|
|
|
|
type_name = "Construct ";
|
|
|
|
}
|
2019-09-29 11:55:09 +00:00
|
|
|
Ref<VisualScriptDeconstruct> vnode_deconstruct = vnode;
|
|
|
|
if (vnode_deconstruct.is_valid()) {
|
|
|
|
type_name = "Deconstruct ";
|
|
|
|
}
|
2019-09-13 19:14:12 +00:00
|
|
|
Vector<String> desc = path[path.size() - 1].replace("(", " ").replace(")", " ").replace(",", " ").split(" ");
|
2019-02-21 19:57:39 +00:00
|
|
|
for (int i = 0; i < desc.size(); i++) {
|
2018-09-30 04:33:21 +00:00
|
|
|
desc.write[i] = desc[i].capitalize();
|
|
|
|
if (desc[i].ends_with(",")) {
|
|
|
|
desc.write[i] = desc[i].replace(",", ", ");
|
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
2018-09-30 04:33:21 +00:00
|
|
|
|
|
|
|
item->set_text(0, type_name + String("").join(desc));
|
2020-03-12 12:37:40 +00:00
|
|
|
item->set_icon(0, vbc->get_theme_icon("VisualScript", "EditorIcons"));
|
2018-05-13 03:34:35 +00:00
|
|
|
item->set_selectable(0, true);
|
|
|
|
item->set_metadata(0, E->get());
|
|
|
|
item->set_selectable(0, true);
|
|
|
|
item->set_metadata(1, "visualscript");
|
|
|
|
item->set_selectable(1, false);
|
2018-07-25 18:49:41 +00:00
|
|
|
item->set_selectable(2, false);
|
|
|
|
item->set_metadata(2, connecting);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptPropertySelector::_confirmed() {
|
|
|
|
TreeItem *ti = search_options->get_selected();
|
2020-05-14 14:41:43 +00:00
|
|
|
if (!ti) {
|
2018-05-13 03:34:35 +00:00
|
|
|
return;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-07-25 18:49:41 +00:00
|
|
|
emit_signal("selected", ti->get_metadata(0), ti->get_metadata(1), ti->get_metadata(2));
|
2020-03-06 17:00:16 +00:00
|
|
|
set_visible(false);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptPropertySelector::_item_selected() {
|
|
|
|
help_bit->set_text("");
|
|
|
|
|
|
|
|
TreeItem *item = search_options->get_selected();
|
2020-05-14 14:41:43 +00:00
|
|
|
if (!item) {
|
2018-05-13 03:34:35 +00:00
|
|
|
return;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
String name = item->get_metadata(0);
|
|
|
|
|
|
|
|
String class_type;
|
2019-07-20 06:09:57 +00:00
|
|
|
if (type != Variant::NIL) {
|
2018-05-13 03:34:35 +00:00
|
|
|
class_type = Variant::get_type_name(type);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
class_type = base_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
DocData *dd = EditorHelp::get_doc_data();
|
|
|
|
String text;
|
|
|
|
|
|
|
|
String at_class = class_type;
|
|
|
|
|
|
|
|
while (at_class != String()) {
|
|
|
|
Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(at_class);
|
|
|
|
if (E) {
|
|
|
|
for (int i = 0; i < E->get().properties.size(); i++) {
|
|
|
|
if (E->get().properties[i].name == name) {
|
2020-05-28 10:02:12 +00:00
|
|
|
text = DTR(E->get().properties[i].description);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
at_class = ClassDB::get_parent_class_nocheck(at_class);
|
|
|
|
}
|
|
|
|
at_class = class_type;
|
|
|
|
|
|
|
|
while (at_class != String()) {
|
2019-04-26 12:40:35 +00:00
|
|
|
Map<String, DocData::ClassDoc>::Element *C = dd->class_list.find(at_class);
|
|
|
|
if (C) {
|
|
|
|
for (int i = 0; i < C->get().methods.size(); i++) {
|
|
|
|
if (C->get().methods[i].name == name) {
|
2020-05-28 10:02:12 +00:00
|
|
|
text = DTR(C->get().methods[i].description);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
at_class = ClassDB::get_parent_class_nocheck(at_class);
|
|
|
|
}
|
2019-04-26 12:40:35 +00:00
|
|
|
Map<String, DocData::ClassDoc>::Element *T = dd->class_list.find(class_type);
|
|
|
|
if (T) {
|
|
|
|
for (int i = 0; i < T->get().methods.size(); i++) {
|
2018-05-13 03:34:35 +00:00
|
|
|
Vector<String> functions = name.rsplit("/", false, 1);
|
2019-04-26 12:40:35 +00:00
|
|
|
if (T->get().methods[i].name == functions[functions.size() - 1]) {
|
2020-05-28 10:02:12 +00:00
|
|
|
text = DTR(T->get().methods[i].description);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
List<String> *names = memnew(List<String>);
|
|
|
|
VisualScriptLanguage::singleton->get_registered_node_names(names);
|
2020-04-01 23:20:12 +00:00
|
|
|
if (names->find(name) != nullptr) {
|
2018-05-13 03:34:35 +00:00
|
|
|
Ref<VisualScriptOperator> operator_node = VisualScriptLanguage::singleton->create_node_from_name(name);
|
|
|
|
if (operator_node.is_valid()) {
|
2019-02-12 20:10:08 +00:00
|
|
|
Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(operator_node->get_class_name());
|
|
|
|
if (F) {
|
2018-05-13 03:34:35 +00:00
|
|
|
text = Variant::get_operator_name(operator_node->get_operator());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ref<VisualScriptTypeCast> typecast_node = VisualScriptLanguage::singleton->create_node_from_name(name);
|
|
|
|
if (typecast_node.is_valid()) {
|
2019-02-12 20:10:08 +00:00
|
|
|
Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(typecast_node->get_class_name());
|
|
|
|
if (F) {
|
2020-05-28 10:02:12 +00:00
|
|
|
text = DTR(F->get().description);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref<VisualScriptBuiltinFunc> builtin_node = VisualScriptLanguage::singleton->create_node_from_name(name);
|
|
|
|
if (builtin_node.is_valid()) {
|
2019-02-12 20:10:08 +00:00
|
|
|
Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(builtin_node->get_class_name());
|
|
|
|
if (F) {
|
|
|
|
for (int i = 0; i < F->get().constants.size(); i++) {
|
|
|
|
if (F->get().constants[i].value.to_int() == int(builtin_node->get_func())) {
|
2020-05-28 10:02:12 +00:00
|
|
|
text = DTR(F->get().constants[i].description);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memdelete(names);
|
|
|
|
|
2020-05-14 14:41:43 +00:00
|
|
|
if (text == String()) {
|
2018-05-13 03:34:35 +00:00
|
|
|
return;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
|
|
|
|
help_bit->set_text(text);
|
|
|
|
}
|
|
|
|
|
2020-02-27 21:49:16 +00:00
|
|
|
void VisualScriptPropertySelector::_hide_requested() {
|
2020-03-06 17:00:16 +00:00
|
|
|
_cancel_pressed(); // From AcceptDialog.
|
2020-02-27 21:49:16 +00:00
|
|
|
}
|
|
|
|
|
2018-05-13 03:34:35 +00:00
|
|
|
void VisualScriptPropertySelector::_notification(int p_what) {
|
|
|
|
if (p_what == NOTIFICATION_ENTER_TREE) {
|
2020-02-21 17:28:45 +00:00
|
|
|
connect("confirmed", callable_mp(this, &VisualScriptPropertySelector::_confirmed));
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-13 19:14:12 +00:00
|
|
|
void VisualScriptPropertySelector::select_method_from_base_type(const String &p_base, const String &p_current, const bool p_virtuals_only, const bool p_connecting, bool clear_text) {
|
2018-05-13 03:34:35 +00:00
|
|
|
base_type = p_base;
|
|
|
|
selected = p_current;
|
|
|
|
type = Variant::NIL;
|
|
|
|
properties = false;
|
2020-04-01 23:20:12 +00:00
|
|
|
instance = nullptr;
|
2018-05-13 03:34:35 +00:00
|
|
|
virtuals_only = p_virtuals_only;
|
|
|
|
|
|
|
|
show_window(.5f);
|
2020-05-14 14:41:43 +00:00
|
|
|
if (clear_text) {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->set_text("");
|
2020-05-14 14:41:43 +00:00
|
|
|
} else {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->select_all();
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
search_box->grab_focus();
|
2018-07-25 18:49:41 +00:00
|
|
|
connecting = p_connecting;
|
|
|
|
|
2018-05-13 03:34:35 +00:00
|
|
|
_update_search();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptPropertySelector::set_type_filter(const Vector<Variant::Type> &p_type_filter) {
|
|
|
|
type_filter = p_type_filter;
|
|
|
|
}
|
|
|
|
|
2019-09-13 19:14:12 +00:00
|
|
|
void VisualScriptPropertySelector::select_from_base_type(const String &p_base, const String &p_current, bool p_virtuals_only, bool p_seq_connect, const bool p_connecting, bool clear_text) {
|
2018-05-13 03:34:35 +00:00
|
|
|
base_type = p_base;
|
|
|
|
selected = p_current;
|
|
|
|
type = Variant::NIL;
|
|
|
|
properties = true;
|
2018-09-30 17:05:16 +00:00
|
|
|
visual_script_generic = false;
|
2020-04-01 23:20:12 +00:00
|
|
|
instance = nullptr;
|
2018-05-13 03:34:35 +00:00
|
|
|
virtuals_only = p_virtuals_only;
|
|
|
|
|
|
|
|
show_window(.5f);
|
2020-05-14 14:41:43 +00:00
|
|
|
if (clear_text) {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->set_text("");
|
2020-05-14 14:41:43 +00:00
|
|
|
} else {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->select_all();
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
search_box->grab_focus();
|
|
|
|
seq_connect = p_seq_connect;
|
2018-07-25 18:49:41 +00:00
|
|
|
connecting = p_connecting;
|
2018-05-13 03:34:35 +00:00
|
|
|
|
|
|
|
_update_search();
|
|
|
|
}
|
|
|
|
|
2019-09-13 19:14:12 +00:00
|
|
|
void VisualScriptPropertySelector::select_from_script(const Ref<Script> &p_script, const String &p_current, const bool p_connecting, bool clear_text) {
|
2018-05-13 03:34:35 +00:00
|
|
|
ERR_FAIL_COND(p_script.is_null());
|
|
|
|
|
|
|
|
base_type = p_script->get_instance_base_type();
|
|
|
|
selected = p_current;
|
|
|
|
type = Variant::NIL;
|
|
|
|
script = p_script->get_instance_id();
|
|
|
|
properties = true;
|
2018-09-30 17:05:16 +00:00
|
|
|
visual_script_generic = false;
|
2020-04-01 23:20:12 +00:00
|
|
|
instance = nullptr;
|
2018-05-13 03:34:35 +00:00
|
|
|
virtuals_only = false;
|
|
|
|
|
|
|
|
show_window(.5f);
|
2020-05-14 14:41:43 +00:00
|
|
|
if (clear_text) {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->set_text("");
|
2020-05-14 14:41:43 +00:00
|
|
|
} else {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->select_all();
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
search_box->grab_focus();
|
|
|
|
seq_connect = false;
|
2018-07-25 18:49:41 +00:00
|
|
|
connecting = p_connecting;
|
2018-05-13 03:34:35 +00:00
|
|
|
|
|
|
|
_update_search();
|
|
|
|
}
|
|
|
|
|
2019-09-13 19:14:12 +00:00
|
|
|
void VisualScriptPropertySelector::select_from_basic_type(Variant::Type p_type, const String &p_current, const bool p_connecting, bool clear_text) {
|
2018-05-13 03:34:35 +00:00
|
|
|
ERR_FAIL_COND(p_type == Variant::NIL);
|
|
|
|
base_type = "";
|
|
|
|
selected = p_current;
|
|
|
|
type = p_type;
|
|
|
|
properties = true;
|
2018-09-30 17:05:16 +00:00
|
|
|
visual_script_generic = false;
|
2020-04-01 23:20:12 +00:00
|
|
|
instance = nullptr;
|
2018-05-13 03:34:35 +00:00
|
|
|
virtuals_only = false;
|
|
|
|
|
|
|
|
show_window(.5f);
|
2020-05-14 14:41:43 +00:00
|
|
|
if (clear_text) {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->set_text("");
|
2020-05-14 14:41:43 +00:00
|
|
|
} else {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->select_all();
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
search_box->grab_focus();
|
|
|
|
seq_connect = false;
|
2018-07-25 18:49:41 +00:00
|
|
|
connecting = p_connecting;
|
2018-05-13 03:34:35 +00:00
|
|
|
|
|
|
|
_update_search();
|
|
|
|
}
|
|
|
|
|
2019-09-13 19:14:12 +00:00
|
|
|
void VisualScriptPropertySelector::select_from_action(const String &p_type, const String &p_current, const bool p_connecting, bool clear_text) {
|
2018-05-13 03:34:35 +00:00
|
|
|
base_type = p_type;
|
|
|
|
selected = p_current;
|
|
|
|
type = Variant::NIL;
|
|
|
|
properties = false;
|
2018-09-30 17:05:16 +00:00
|
|
|
visual_script_generic = false;
|
2020-04-01 23:20:12 +00:00
|
|
|
instance = nullptr;
|
2018-05-13 03:34:35 +00:00
|
|
|
virtuals_only = false;
|
|
|
|
|
|
|
|
show_window(.5f);
|
2020-05-14 14:41:43 +00:00
|
|
|
if (clear_text) {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->set_text("");
|
2020-05-14 14:41:43 +00:00
|
|
|
} else {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->select_all();
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
search_box->grab_focus();
|
|
|
|
seq_connect = true;
|
2018-07-25 18:49:41 +00:00
|
|
|
connecting = p_connecting;
|
|
|
|
|
2018-05-13 03:34:35 +00:00
|
|
|
_update_search();
|
|
|
|
}
|
|
|
|
|
2019-09-13 19:14:12 +00:00
|
|
|
void VisualScriptPropertySelector::select_from_instance(Object *p_instance, const String &p_current, const bool p_connecting, const String &p_basetype, bool clear_text) {
|
|
|
|
base_type = p_basetype;
|
2018-05-13 03:34:35 +00:00
|
|
|
selected = p_current;
|
|
|
|
type = Variant::NIL;
|
|
|
|
properties = true;
|
2018-09-30 17:05:16 +00:00
|
|
|
visual_script_generic = false;
|
2018-05-13 03:34:35 +00:00
|
|
|
instance = p_instance;
|
|
|
|
virtuals_only = false;
|
|
|
|
|
|
|
|
show_window(.5f);
|
2020-05-14 14:41:43 +00:00
|
|
|
if (clear_text) {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->set_text("");
|
2020-05-14 14:41:43 +00:00
|
|
|
} else {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->select_all();
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
search_box->grab_focus();
|
|
|
|
seq_connect = false;
|
2018-07-25 18:49:41 +00:00
|
|
|
connecting = p_connecting;
|
2018-05-13 03:34:35 +00:00
|
|
|
|
|
|
|
_update_search();
|
|
|
|
}
|
|
|
|
|
2019-09-13 19:14:12 +00:00
|
|
|
void VisualScriptPropertySelector::select_from_visual_script(const String &p_base, const bool p_connecting, bool clear_text) {
|
2018-05-13 03:34:35 +00:00
|
|
|
base_type = p_base;
|
|
|
|
selected = "";
|
|
|
|
type = Variant::NIL;
|
|
|
|
properties = true;
|
|
|
|
visual_script_generic = true;
|
2020-04-01 23:20:12 +00:00
|
|
|
instance = nullptr;
|
2018-05-13 03:34:35 +00:00
|
|
|
virtuals_only = false;
|
|
|
|
show_window(.5f);
|
2020-05-14 14:41:43 +00:00
|
|
|
if (clear_text) {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->set_text("");
|
2020-05-14 14:41:43 +00:00
|
|
|
} else {
|
2019-09-13 19:14:12 +00:00
|
|
|
search_box->select_all();
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2018-05-13 03:34:35 +00:00
|
|
|
search_box->grab_focus();
|
2018-07-25 18:49:41 +00:00
|
|
|
connecting = p_connecting;
|
2018-05-13 03:34:35 +00:00
|
|
|
|
|
|
|
_update_search();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptPropertySelector::show_window(float p_screen_ratio) {
|
2020-03-06 17:00:16 +00:00
|
|
|
popup_centered_ratio(p_screen_ratio);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptPropertySelector::_bind_methods() {
|
2018-07-25 18:49:41 +00:00
|
|
|
ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::STRING, "category"), PropertyInfo(Variant::BOOL, "connecting")));
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VisualScriptPropertySelector::VisualScriptPropertySelector() {
|
2020-03-06 17:00:16 +00:00
|
|
|
vbc = memnew(VBoxContainer);
|
2018-05-13 03:34:35 +00:00
|
|
|
add_child(vbc);
|
|
|
|
//set_child_rect(vbc);
|
|
|
|
search_box = memnew(LineEdit);
|
|
|
|
vbc->add_margin_child(TTR("Search:"), search_box);
|
2020-02-21 17:28:45 +00:00
|
|
|
search_box->connect("text_changed", callable_mp(this, &VisualScriptPropertySelector::_text_changed));
|
|
|
|
search_box->connect("gui_input", callable_mp(this, &VisualScriptPropertySelector::_sbox_input));
|
2018-05-13 03:34:35 +00:00
|
|
|
search_options = memnew(Tree);
|
|
|
|
vbc->add_margin_child(TTR("Matches:"), search_options, true);
|
|
|
|
get_ok()->set_text(TTR("Open"));
|
|
|
|
get_ok()->set_disabled(true);
|
|
|
|
register_text_enter(search_box);
|
|
|
|
set_hide_on_ok(false);
|
2020-02-21 17:28:45 +00:00
|
|
|
search_options->connect("item_activated", callable_mp(this, &VisualScriptPropertySelector::_confirmed));
|
|
|
|
search_options->connect("cell_selected", callable_mp(this, &VisualScriptPropertySelector::_item_selected));
|
2018-05-13 03:34:35 +00:00
|
|
|
search_options->set_hide_root(true);
|
|
|
|
search_options->set_hide_folding(true);
|
|
|
|
virtuals_only = false;
|
2018-09-26 09:22:59 +00:00
|
|
|
seq_connect = false;
|
2018-05-13 03:34:35 +00:00
|
|
|
help_bit = memnew(EditorHelpBit);
|
|
|
|
vbc->add_margin_child(TTR("Description:"), help_bit);
|
2020-02-27 21:49:16 +00:00
|
|
|
help_bit->connect("request_hide", callable_mp(this, &VisualScriptPropertySelector::_hide_requested));
|
2018-07-25 18:49:41 +00:00
|
|
|
search_options->set_columns(3);
|
2018-05-13 03:34:35 +00:00
|
|
|
search_options->set_column_expand(1, false);
|
2018-07-25 18:49:41 +00:00
|
|
|
search_options->set_column_expand(2, false);
|
2018-05-13 03:34:35 +00:00
|
|
|
}
|