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.cpp76
1 files changed, 58 insertions, 18 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 61b434a240..0e6c9162ce 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -43,6 +43,7 @@
#include "scene/main/window.h"
#include "scene/resources/font.h"
#include "scene/resources/mesh.h"
+#include "scene/resources/packed_scene.h"
///////////////////// Nil /////////////////////////
@@ -3017,6 +3018,23 @@ void EditorPropertyNodePath::_set_read_only(bool p_read_only) {
clear->set_disabled(p_read_only);
};
+String EditorPropertyNodePath::_get_meta_pointer_property() const {
+ ERR_FAIL_COND_V(!pointer_mode, String());
+ return SceneState::get_meta_pointer_property(get_edited_property());
+}
+
+Variant EditorPropertyNodePath::_get_cache_value(const StringName &p_prop, bool &r_valid) const {
+ if (p_prop == get_edited_property()) {
+ r_valid = true;
+ return const_cast<EditorPropertyNodePath *>(this)->get_edited_object()->get(_get_meta_pointer_property(), &r_valid);
+ }
+ return Variant();
+}
+
+StringName EditorPropertyNodePath::_get_revert_property() const {
+ return _get_meta_pointer_property();
+}
+
void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {
NodePath path = p_path;
Node *base_node = nullptr;
@@ -3048,7 +3066,11 @@ void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {
if (base_node) { // for AnimationTrackKeyEdit
path = base_node->get_path().rel_path_to(p_path);
}
- emit_changed(get_edited_property(), path);
+ if (pointer_mode && base_node) {
+ emit_changed(_get_meta_pointer_property(), path);
+ } else {
+ emit_changed(get_edited_property(), path);
+ }
update_property();
}
@@ -3064,7 +3086,11 @@ void EditorPropertyNodePath::_node_assign() {
}
void EditorPropertyNodePath::_node_clear() {
- emit_changed(get_edited_property(), NodePath());
+ if (pointer_mode) {
+ emit_changed(_get_meta_pointer_property(), NodePath());
+ } else {
+ emit_changed(get_edited_property(), NodePath());
+ }
update_property();
}
@@ -3092,7 +3118,12 @@ bool EditorPropertyNodePath::is_drop_valid(const Dictionary &p_drag_data) const
}
void EditorPropertyNodePath::update_property() {
- NodePath p = get_edited_object()->get(get_edited_property());
+ NodePath p;
+ if (pointer_mode) {
+ p = get_edited_object()->get(_get_meta_pointer_property());
+ } else {
+ p = get_edited_object()->get(get_edited_property());
+ }
assign->set_tooltip(p);
if (p == NodePath()) {
@@ -3131,7 +3162,8 @@ void EditorPropertyNodePath::update_property() {
assign->set_icon(EditorNode::get_singleton()->get_object_icon(target_node, "Node"));
}
-void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringName> p_valid_types, bool p_use_path_from_scene_root) {
+void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringName> p_valid_types, bool p_use_path_from_scene_root, bool p_pointer_mode) {
+ pointer_mode = p_pointer_mode;
base_hint = p_base_hint;
valid_types = p_valid_types;
use_path_from_scene_root = p_use_path_from_scene_root;
@@ -3601,7 +3633,7 @@ static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const Stri
hint.greater = true;
} else if (slice == "or_lesser") {
hint.lesser = true;
- } else if (slice == "noslider") {
+ } else if (slice == "no_slider") {
hint.hide_slider = true;
} else if (slice == "exp") {
hint.exp_range = true;
@@ -3927,23 +3959,31 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
return editor;
} break;
case Variant::OBJECT: {
- EditorPropertyResource *editor = memnew(EditorPropertyResource);
- editor->setup(p_object, p_path, p_hint == PROPERTY_HINT_RESOURCE_TYPE ? p_hint_text : "Resource");
-
- if (p_hint == PROPERTY_HINT_RESOURCE_TYPE) {
- String open_in_new = EDITOR_GET("interface/inspector/resources_to_open_in_new_inspector");
- for (int i = 0; i < open_in_new.get_slice_count(","); i++) {
- String type = open_in_new.get_slicec(',', i).strip_edges();
- for (int j = 0; j < p_hint_text.get_slice_count(","); j++) {
- String inherits = p_hint_text.get_slicec(',', j);
- if (ClassDB::is_parent_class(inherits, type)) {
- editor->set_use_sub_inspector(false);
+ if (p_hint == PROPERTY_HINT_NODE_TYPE) {
+ EditorPropertyNodePath *editor = memnew(EditorPropertyNodePath);
+ Vector<String> types = p_hint_text.split(",", false);
+ Vector<StringName> sn = Variant(types); //convert via variant
+ editor->setup(NodePath(), sn, false, true);
+ return editor;
+ } else {
+ EditorPropertyResource *editor = memnew(EditorPropertyResource);
+ editor->setup(p_object, p_path, p_hint == PROPERTY_HINT_RESOURCE_TYPE ? p_hint_text : "Resource");
+
+ if (p_hint == PROPERTY_HINT_RESOURCE_TYPE) {
+ String open_in_new = EDITOR_GET("interface/inspector/resources_to_open_in_new_inspector");
+ for (int i = 0; i < open_in_new.get_slice_count(","); i++) {
+ String type = open_in_new.get_slicec(',', i).strip_edges();
+ for (int j = 0; j < p_hint_text.get_slice_count(","); j++) {
+ String inherits = p_hint_text.get_slicec(',', j);
+ if (ClassDB::is_parent_class(inherits, type)) {
+ editor->set_use_sub_inspector(false);
+ }
}
}
}
- }
- return editor;
+ return editor;
+ }
} break;
case Variant::DICTIONARY: {