From ad8f208bdbcd9d3334c4d57d2e5554dfdb3a36d0 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 23 Aug 2016 19:29:07 -0300 Subject: Proper function/property selection in visual script editing for property. This one has an ordered list, built-in description, search, etc. --- tools/editor/property_editor.cpp | 138 +++++++++ tools/editor/property_editor.h | 4 + tools/editor/property_selector.cpp | 609 +++++++++++++++++++++++++++++++++++++ tools/editor/property_selector.h | 54 ++++ 4 files changed, 805 insertions(+) create mode 100644 tools/editor/property_selector.cpp create mode 100644 tools/editor/property_selector.h (limited to 'tools') diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 0518018e5..ad3dbeaf3 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -46,6 +46,7 @@ #include "scene/main/viewport.h" #include "editor_file_system.h" #include "create_dialog.h" +#include "property_selector.h" void CustomPropertyEditor::_notification(int p_what) { @@ -438,6 +439,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty } else if (hint==PROPERTY_HINT_TYPE_STRING) { + if (!create_dialog) { create_dialog = memnew( CreateDialog ); create_dialog->connect("create",this,"_create_dialog_callback"); @@ -452,6 +454,112 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty create_dialog->popup(false); hide(); + updating=false; + return false; + + + } else if (hint==PROPERTY_HINT_METHOD_OF_VARIANT_TYPE) { +#define MAKE_PROPSELECT if (!property_select) { property_select = memnew(PropertySelector); property_select->connect("selected",this,"_create_selected_property"); add_child(property_select); } hide(); + + MAKE_PROPSELECT; + + Variant::Type type=Variant::NIL; + for(int i=0;iselect_method_from_basic_type(type,v); + updating=false; + return false; + + } else if (hint==PROPERTY_HINT_METHOD_OF_BASE_TYPE) { + MAKE_PROPSELECT + + property_select->select_method_from_base_type(hint_text,v); + + updating=false; + return false; + + } else if (hint==PROPERTY_HINT_METHOD_OF_INSTANCE) { + + MAKE_PROPSELECT + + Object *instance = ObjectDB::get_instance(hint_text.to_int64()); + if (instance) + property_select->select_method_from_instance(instance,v); + updating=false; + return false; + + } else if (hint==PROPERTY_HINT_METHOD_OF_SCRIPT) { + MAKE_PROPSELECT + + Object *obj = ObjectDB::get_instance(hint_text.to_int64()); + if (obj && obj->cast_to