Clean up & strengthen code
This commit is contained in:
parent
0b3b11a383
commit
6e8c22d598
|
@ -122,7 +122,7 @@ bool BlackboardPlan::_get(const StringName &p_name, Variant &r_ret) const {
|
||||||
if (!edited_node) {
|
if (!edited_node) {
|
||||||
edited_node = SCENE_TREE()->get_edited_scene_root();
|
edited_node = SCENE_TREE()->get_edited_scene_root();
|
||||||
}
|
}
|
||||||
Node *bound_node = edited_node->get_node_or_null(binding);
|
Node *bound_node = edited_node ? edited_node->get_node_or_null(binding) : nullptr;
|
||||||
|
|
||||||
String shortened_path;
|
String shortened_path;
|
||||||
if (bound_node) {
|
if (bound_node) {
|
||||||
|
|
|
@ -48,12 +48,15 @@ Node *_get_base_node(Object *p_edited_object, SceneTree *p_scene_tree) {
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
Node *EditorPropertyPropertyPath::_get_selected_node() {
|
Node *EditorPropertyPropertyPath::_get_selected_node() {
|
||||||
|
ERR_FAIL_NULL_V(get_edited_object(), nullptr);
|
||||||
|
|
||||||
NodePath path = get_edited_object()->get(get_edited_property());
|
NodePath path = get_edited_object()->get(get_edited_property());
|
||||||
if (path.is_empty()) {
|
if (path.is_empty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *base_node = _get_base_node(get_edited_object(), get_tree());
|
Node *base_node = _get_base_node(get_edited_object(), get_tree());
|
||||||
|
ERR_FAIL_NULL_V(base_node, nullptr);
|
||||||
Node *selected_node = base_node->get_node_or_null(path);
|
Node *selected_node = base_node->get_node_or_null(path);
|
||||||
return selected_node;
|
return selected_node;
|
||||||
}
|
}
|
||||||
|
@ -96,9 +99,9 @@ void EditorPropertyPropertyPath::_property_selected(const NodePath &p_property_p
|
||||||
}
|
}
|
||||||
Node *base_node = _get_base_node(get_edited_object(), get_tree());
|
Node *base_node = _get_base_node(get_edited_object(), get_tree());
|
||||||
ERR_FAIL_NULL(base_node);
|
ERR_FAIL_NULL(base_node);
|
||||||
Node *chosen_node = get_tree()->get_edited_scene_root()->get_node_or_null(p_node_path);
|
Node *selected_node = get_tree()->get_edited_scene_root()->get_node_or_null(p_node_path);
|
||||||
ERR_FAIL_NULL(chosen_node);
|
ERR_FAIL_NULL(selected_node);
|
||||||
NodePath path = String(base_node->get_path_to(chosen_node)) + String(p_property_path);
|
NodePath path = String(base_node->get_path_to(selected_node)) + String(p_property_path);
|
||||||
|
|
||||||
emit_changed(get_edited_property(), path);
|
emit_changed(get_edited_property(), path);
|
||||||
update_property();
|
update_property();
|
||||||
|
@ -217,6 +220,7 @@ bool EditorInspectorPluginPropertyPath::_parse_property(Object *p_object, const
|
||||||
|
|
||||||
EditorPropertyPropertyPath *ed = memnew(EditorPropertyPropertyPath);
|
EditorPropertyPropertyPath *ed = memnew(EditorPropertyPropertyPath);
|
||||||
|
|
||||||
|
// Convert the hint text to an array of valid types.
|
||||||
PackedInt32Array valid_types;
|
PackedInt32Array valid_types;
|
||||||
PackedStringArray type_specifiers = p_hint_text.split(",");
|
PackedStringArray type_specifiers = p_hint_text.split(",");
|
||||||
for (const String &t : type_specifiers) {
|
for (const String &t : type_specifiers) {
|
||||||
|
|
Loading…
Reference in New Issue