diff options
Diffstat (limited to 'editor/property_editor.cpp')
| -rw-r--r-- | editor/property_editor.cpp | 82 |
1 files changed, 69 insertions, 13 deletions
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 820711759..30d46933b 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "property_editor.h" #include "array_property_edit.h" +#include "dictionary_property_edit.h" #include "editor_file_system.h" #include "editor_help.h" #include "editor_import_export.h" @@ -2885,7 +2886,7 @@ void PropertyEditor::update_tree() { if (type == "") type = "Object"; - ObjectID id = obj->get(p.name); + ObjectID id = _get_curent_remote_object_id(p.name); if (id != 0) { item->set_text(1, type + " ID: " + itos(id)); item->add_button(1, get_icon("EditResource", "EditorIcons")); @@ -2993,10 +2994,10 @@ void PropertyEditor::update_tree() { } break; case Variant::DICTIONARY: { - item->set_cell_mode(1, TreeItem::CELL_MODE_STRING); - item->set_editable(1, false); - item->set_text(1, obj->get(p.name).operator String()); - + item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); + item->add_button(1, get_icon("EditResource", "EditorIcons")); + Dictionary d = obj->get(p.name); + item->set_text(1, "Dictionary{" + itos(d.size()) + "}"); } break; case Variant::INT_ARRAY: { @@ -3208,8 +3209,16 @@ void PropertyEditor::update_tree() { type = p.hint_string; if (obj->get(p.name).get_type() == Variant::NIL || obj->get(p.name).operator RefPtr().is_null()) { - item->set_text(1, "<null>"); - item->set_icon(1, Ref<Texture>()); + + if (Object *_o = obj->get(p.name)) { + if (_o->is_type("ScriptEditorDebuggerInspectedObject")) + item->set_text(1, _o->call("get_title")); + else + item->set_text(1, String(_o->get_type_name()) + " ID: " + itos(obj->get_instance_ID())); + } else { + item->set_text(1, "<null>"); + item->set_icon(1, Ref<Texture>()); + } } else { RES res = obj->get(p.name).operator RefPtr(); @@ -3331,6 +3340,35 @@ void PropertyEditor::_draw_transparency(Object *t, const Rect2 &p_rect) { tree->draw_rect(area, color); } +ObjectID PropertyEditor::_get_curent_remote_object_id(const StringName &p_name) { + + ObjectID id = 0; + if (obj) { + id = obj->get(p_name); + if (id == 0) { + + Object *debugObj = NULL; + + if (obj->is_type("ScriptEditorDebuggerVariables")) { + if (Object *oo = obj->call("get_var_value", p_name)) { + if (oo->is_type("ScriptEditorDebuggerInspectedObject")) + debugObj = oo; + } + } else if (obj->is_type("ScriptEditorDebuggerInspectedObject")) { + if (Object *oo = obj->call("get_variant", p_name)) { + if (oo->is_type("ScriptEditorDebuggerInspectedObject")) + debugObj = oo; + } + } + if (debugObj) { + id = debugObj->call("get_remote_object_id"); + } + } + } + + return id; +} + void PropertyEditor::_item_selected() { TreeItem *item = tree->get_selected(); @@ -3573,12 +3611,16 @@ void PropertyEditor::edit(Object *p_object) { if (obj == p_object) return; + + obj = p_object; + if (obj) { obj->remove_change_receptor(this); - } - obj = p_object; + if (obj->is_type("ScriptEditorDebuggerInspectedObject")) + set_enable_capitalize_paths(false); + } evaluator->edit(p_object); @@ -3687,15 +3729,24 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { } else if (t == Variant::OBJECT) { - RES r = obj->get(n); - if (r.is_valid()) { + Variant var = obj->get(n); + RES r = var; + if (r.is_valid()) { emit_signal("resource_selected", r, n); + } else if (Object *o = var) { + // Remote object clicked form property editor cell + if (o->is_type("ScriptEditorDebuggerInspectedObject")) { + ObjectID id = o->call("get_remote_object_id"); + emit_signal("object_id_selected", id); + print_line(String("OBJ ID SELECTED: ") + itos(id)); + } } } else if (t == Variant::INT && h == PROPERTY_HINT_OBJECT_ID) { - emit_signal("object_id_selected", obj->get(n)); - print_line("OBJ ID SELECTED"); + ObjectID id = _get_curent_remote_object_id(n); + emit_signal("object_id_selected", id); + print_line(String("OBJ ID SELECTED: ") + itos(id)); } else if (t == Variant::ARRAY || t == Variant::INT_ARRAY || t == Variant::REAL_ARRAY || t == Variant::STRING_ARRAY || t == Variant::VECTOR2_ARRAY || t == Variant::VECTOR3_ARRAY || t == Variant::COLOR_ARRAY || t == Variant::RAW_ARRAY) { @@ -3710,6 +3761,11 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { ape->edit(obj, n, Variant::Type(t)); EditorNode::get_singleton()->push_item(ape.ptr()); + } else if (t == Variant::DICTIONARY) { + + Ref<DictionaryPropertyEdit> dpe = memnew(DictionaryPropertyEdit); + dpe->edit(obj, n); + EditorNode::get_singleton()->push_item(dpe.ptr()); } } } |
