summaryrefslogtreecommitdiff
path: root/editor/editor_properties.cpp
diff options
context:
space:
mode:
authorK. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>2018-07-18 21:58:40 -0700
committerK. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>2018-07-25 12:54:35 -0700
commit23744d8064bea76dc386a5e1e4a77fa7f14a0675 (patch)
tree9f9963fe9be56e7c1bd8a1cd671f1226f115d18f /editor/editor_properties.cpp
parent41a0ecb59b244ee01ece644107f02c64d2a5b64a (diff)
Add editor property type so that inspector can search for objects. This is a regression.
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r--editor/editor_properties.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 0b49b5a801..4ff1fb2984 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -258,6 +258,51 @@ EditorPropertyPath::EditorPropertyPath() {
global = false;
}
+///////////////////// CLASS NAME /////////////////////////
+
+void EditorPropertyClassName::setup(const String &p_base_type, const String &p_selected_type) {
+
+ base_type = p_base_type;
+ dialog->set_base_type(base_type);
+ selected_type = p_selected_type;
+ property->set_text(selected_type);
+}
+
+void EditorPropertyClassName::update_property() {
+
+ String s = get_edited_object()->get(get_edited_property());
+ property->set_text(s);
+ selected_type = s;
+}
+
+void EditorPropertyClassName::_property_selected() {
+ dialog->popup_create(true);
+}
+
+void EditorPropertyClassName::_dialog_created() {
+ selected_type = dialog->get_selected_type();
+ emit_signal("property_changed", get_edited_property(), selected_type);
+ update_property();
+}
+
+void EditorPropertyClassName::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_dialog_created"), &EditorPropertyClassName::_dialog_created);
+ ClassDB::bind_method(D_METHOD("_property_selected"), &EditorPropertyClassName::_property_selected);
+}
+
+EditorPropertyClassName::EditorPropertyClassName() {
+ property = memnew(Button);
+ property->set_clip_text(true);
+ add_child(property);
+ add_focusable(property);
+ property->set_text(selected_type);
+ property->connect("pressed", this, "_property_selected");
+ dialog = memnew(CreateDialog);
+ dialog->set_base_type(base_type);
+ dialog->connect("create", this, "_dialog_created");
+ add_child(dialog);
+}
+
///////////////////// MEMBER /////////////////////////
void EditorPropertyMember::_property_selected(const String &p_selected) {
@@ -2607,6 +2652,10 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} else if (p_hint == PROPERTY_HINT_MULTILINE_TEXT) {
EditorPropertyMultilineText *editor = memnew(EditorPropertyMultilineText);
add_property_editor(p_path, editor);
+ } else if (p_hint == PROPERTY_HINT_TYPE_STRING) {
+ EditorPropertyClassName *editor = memnew(EditorPropertyClassName);
+ editor->setup("Object", p_hint_text);
+ add_property_editor(p_path, editor);
} else if (p_hint == PROPERTY_HINT_DIR || p_hint == PROPERTY_HINT_FILE || p_hint == PROPERTY_HINT_GLOBAL_DIR || p_hint == PROPERTY_HINT_GLOBAL_FILE) {
Vector<String> extensions = p_hint_text.split(",");