summaryrefslogtreecommitdiff
path: root/editor/editor_properties.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r--editor/editor_properties.cpp103
1 files changed, 92 insertions, 11 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 812e461a14..9902d8d3e7 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -31,7 +31,20 @@
#include "editor_properties.h"
#include "editor/editor_resource_preview.h"
#include "editor_node.h"
+#include "editor_properties_array_dict.h"
#include "scene/main/viewport.h"
+
+///////////////////// NULL /////////////////////////
+
+void EditorPropertyNil::update_property() {
+}
+
+EditorPropertyNil::EditorPropertyNil() {
+ Label *label = memnew(Label);
+ label->set_text("[null]");
+ add_child(label);
+}
+
///////////////////// TEXT /////////////////////////
void EditorPropertyText::_text_changed(const String &p_string) {
if (updating)
@@ -487,7 +500,7 @@ public:
virtual String get_tooltip(const Point2 &p_pos) const {
for (int i = 0; i < flag_rects.size(); i++) {
- if (flag_rects[i].has_point(p_pos) && i < names.size()) {
+ if (i < names.size() && flag_rects[i].has_point(p_pos)) {
return names[i];
}
}
@@ -1010,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);
}
@@ -1509,13 +1522,16 @@ EditorPropertyColor::EditorPropertyColor() {
void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {
- emit_signal("property_changed", get_edited_property(), p_path);
+ Node *base_node = Object::cast_to<Node>(get_edited_object());
+ emit_signal("property_changed", get_edited_property(), base_node->get_path().rel_path_to(p_path));
update_property();
}
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");
}
@@ -1570,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) {
@@ -1765,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"));
@@ -1972,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());
@@ -1995,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()) {
@@ -2007,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
@@ -2228,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);
@@ -2273,6 +2321,10 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
switch (p_type) {
// atomic types
+ case Variant::NIL: {
+ EditorPropertyNil *editor = memnew(EditorPropertyNil);
+ add_property_editor(p_path, editor);
+ } break;
case Variant::BOOL: {
EditorPropertyCheck *editor = memnew(EditorPropertyCheck);
add_property_editor(p_path, editor);
@@ -2617,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);
@@ -2631,24 +2688,48 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} break;
case Variant::DICTIONARY: {
+ EditorPropertyDictionary *editor = memnew(EditorPropertyDictionary);
+ add_property_editor(p_path, editor);
} break;
case Variant::ARRAY: {
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::ARRAY);
+ add_property_editor(p_path, editor);
} break;
-
- // arrays
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: {}
}