/*************************************************************************/ /* visual_script_property_selector.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* 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" #include "core/os/keyboard.h" #include "editor/doc_tools.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" #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" #include "scene/main/window.h" void VisualScriptPropertySelector::_text_changed(const String &p_newtext) { _update_search(); } void VisualScriptPropertySelector::_sbox_input(const Ref &p_ie) { Ref k = p_ie; if (k.is_valid()) { switch (k->get_keycode()) { 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(); if (!root->get_first_child()) { break; } 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; StringName base = base_type; List base_list; while (base) { base_list.push_back(base); base = ClassDB::get_parent_class_nocheck(base); } for (List::Element *E = base_list.front(); E; E = E->next()) { List methods; List props; TreeItem *category = nullptr; Ref type_icons[Variant::VARIANT_MAX] = { 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("Quaternion", "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") }; { String b = String(E->get()); category = search_options->create_item(root); if (category) { category->set_text(0, b.replace_first("*", "")); category->set_selectable(0, false); Ref icon; String rep = b.replace("*", ""); icon = EditorNode::get_singleton()->get_class_icon(rep); category->set_icon(0, icon); } } if (properties || seq_connect) { if (instance) { instance->get_property_list(&props, true); } else { Object *obj = ObjectDB::get_instance(script); if (Object::cast_to