diff options
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r-- | editor/editor_properties.cpp | 61 |
1 files changed, 54 insertions, 7 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index c6d3a43f4e..9902d8d3e7 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -1023,8 +1023,8 @@ void EditorPropertyRect2::_value_changed(double val) { Rect2 r2; r2.position.x = spin[0]->get_value(); - r2.position.x = spin[1]->get_value(); - r2.size.y = spin[2]->get_value(); + r2.position.y = spin[1]->get_value(); + r2.size.x = spin[2]->get_value(); r2.size.y = spin[3]->get_value(); emit_signal("property_changed", get_edited_property(), r2); } @@ -1530,6 +1530,8 @@ void EditorPropertyNodePath::_node_selected(const NodePath &p_path) { void EditorPropertyNodePath::_node_assign() { if (!scene_tree) { scene_tree = memnew(SceneTreeDialog); + scene_tree->get_scene_tree()->set_show_enabled_subscene(true); + scene_tree->get_scene_tree()->set_valid_types(valid_types); add_child(scene_tree); scene_tree->connect("selected", this, "_node_selected"); } @@ -1584,9 +1586,10 @@ void EditorPropertyNodePath::update_property() { assign->set_icon(icon); } -void EditorPropertyNodePath::setup(const NodePath &p_base_hint) { +void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringName> p_valid_types) { base_hint = p_base_hint; + valid_types = p_valid_types; } void EditorPropertyNodePath::_notification(int p_what) { @@ -1779,6 +1782,7 @@ void EditorPropertyResource::_menu_option(int p_which) { if (!scene_tree) { scene_tree = memnew(SceneTreeDialog); + scene_tree->get_scene_tree()->set_show_enabled_subscene(true); add_child(scene_tree); scene_tree->connect("selected", this, "_viewport_selected"); scene_tree->set_title(TTR("Pick a Viewport")); @@ -1986,6 +1990,13 @@ void EditorPropertyResource::_sub_inspector_object_id_selected(int p_id) { emit_signal("object_id_selected", get_edited_property(), p_id); } +void EditorPropertyResource::_open_editor_pressed() { + RES res = get_edited_object()->get(get_edited_property()); + if (res.is_valid()) { + EditorNode::get_singleton()->edit_item(res.ptr()); + } +} + void EditorPropertyResource::update_property() { RES res = get_edited_object()->get(get_edited_property()); @@ -2009,9 +2020,29 @@ void EditorPropertyResource::update_property() { sub_inspector->set_read_only(is_read_only()); sub_inspector->set_use_folding(is_using_folding()); - add_child(sub_inspector); - set_bottom_editor(sub_inspector); + sub_inspector_vbox = memnew(VBoxContainer); + add_child(sub_inspector_vbox); + set_bottom_editor(sub_inspector_vbox); + + sub_inspector_vbox->add_child(sub_inspector); assign->set_pressed(true); + + bool use_editor = false; + for (int i = 0; i < EditorNode::get_singleton()->get_editor_data().get_editor_plugin_count(); i++) { + EditorPlugin *ep = EditorNode::get_singleton()->get_editor_data().get_editor_plugin(i); + if (ep->handles(res.ptr())) { + use_editor = true; + } + } + + if (use_editor) { + Button *open_in_editor = memnew(Button); + open_in_editor->set_text(TTR("Open Editor")); + open_in_editor->set_icon(get_icon("Edit", "EditorIcons")); + sub_inspector_vbox->add_child(open_in_editor); + open_in_editor->connect("pressed", this, "_open_editor_pressed"); + open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER); + } } if (res.ptr() != sub_inspector->get_edited_object()) { @@ -2021,8 +2052,9 @@ void EditorPropertyResource::update_property() { } else { if (sub_inspector) { set_bottom_editor(NULL); - memdelete(sub_inspector); + memdelete(sub_inspector_vbox); sub_inspector = NULL; + sub_inspector_vbox = NULL; } } #endif @@ -2242,11 +2274,13 @@ void EditorPropertyResource::_bind_methods() { ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &EditorPropertyResource::can_drop_data_fw); ClassDB::bind_method(D_METHOD("drop_data_fw"), &EditorPropertyResource::drop_data_fw); ClassDB::bind_method(D_METHOD("_button_draw"), &EditorPropertyResource::_button_draw); + ClassDB::bind_method(D_METHOD("_open_editor_pressed"), &EditorPropertyResource::_open_editor_pressed); } EditorPropertyResource::EditorPropertyResource() { sub_inspector = NULL; + sub_inspector_vbox = NULL; use_sub_inspector = !bool(EDITOR_GET("interface/inspector/open_resources_in_new_inspector")); HBoxContainer *hbc = memnew(HBoxContainer); add_child(hbc); @@ -2635,7 +2669,12 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ EditorPropertyNodePath *editor = memnew(EditorPropertyNodePath); if (p_hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && p_hint_text != String()) { - editor->setup(p_hint_text); + editor->setup(p_hint_text, Vector<StringName>()); + } + if (p_hint == PROPERTY_HINT_NODE_PATH_VALID_TYPES && p_hint_text != String()) { + Vector<String> types = p_hint_text.split(",", false); + Vector<StringName> sn = Variant(types); //convert via variant + editor->setup(NodePath(), sn); } add_property_editor(p_path, editor); @@ -2654,34 +2693,42 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ } break; case Variant::ARRAY: { EditorPropertyArray *editor = memnew(EditorPropertyArray); + editor->setup(Variant::ARRAY); add_property_editor(p_path, editor); } break; case Variant::POOL_BYTE_ARRAY: { EditorPropertyArray *editor = memnew(EditorPropertyArray); + editor->setup(Variant::POOL_BYTE_ARRAY); add_property_editor(p_path, editor); } break; // 20 case Variant::POOL_INT_ARRAY: { EditorPropertyArray *editor = memnew(EditorPropertyArray); + editor->setup(Variant::POOL_INT_ARRAY); add_property_editor(p_path, editor); } break; case Variant::POOL_REAL_ARRAY: { EditorPropertyArray *editor = memnew(EditorPropertyArray); + editor->setup(Variant::POOL_REAL_ARRAY); add_property_editor(p_path, editor); } break; case Variant::POOL_STRING_ARRAY: { EditorPropertyArray *editor = memnew(EditorPropertyArray); + editor->setup(Variant::POOL_STRING_ARRAY); add_property_editor(p_path, editor); } break; case Variant::POOL_VECTOR2_ARRAY: { EditorPropertyArray *editor = memnew(EditorPropertyArray); + editor->setup(Variant::POOL_VECTOR2_ARRAY); add_property_editor(p_path, editor); } break; case Variant::POOL_VECTOR3_ARRAY: { EditorPropertyArray *editor = memnew(EditorPropertyArray); + editor->setup(Variant::POOL_VECTOR3_ARRAY); add_property_editor(p_path, editor); } break; // 25 case Variant::POOL_COLOR_ARRAY: { EditorPropertyArray *editor = memnew(EditorPropertyArray); + editor->setup(Variant::POOL_COLOR_ARRAY); add_property_editor(p_path, editor); } break; default: {} |