feat: updated engine version to 4.4-rc1

This commit is contained in:
Sara 2025-02-23 14:38:14 +01:00
parent ee00efde1f
commit 21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions

View file

@ -47,15 +47,14 @@
#include "editor/property_selector.h"
#include "editor/scene_tree_dock.h"
#include "editor/themes/editor_scale.h"
#include "editor/themes/editor_theme_manager.h"
#include "scene/2d/gpu_particles_2d.h"
#include "scene/3d/fog_volume.h"
#include "scene/3d/gpu_particles_3d.h"
#include "scene/gui/color_picker.h"
#include "scene/gui/grid_container.h"
#include "scene/main/window.h"
#include "scene/resources/font.h"
#include "scene/resources/mesh.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/visual_shader_nodes.h"
///////////////////// Nil /////////////////////////
@ -81,7 +80,6 @@ void EditorPropertyText::_text_submitted(const String &p_string) {
}
if (text->has_focus()) {
text->release_focus();
_text_changed(p_string);
}
}
@ -91,6 +89,10 @@ void EditorPropertyText::_text_changed(const String &p_string) {
return;
}
// Set tooltip so that the full text is displayed in a tooltip if hovered.
// This is useful when using a narrow inspector, as the text can be trimmed otherwise.
text->set_tooltip_text(get_tooltip_string(text->get_text()));
if (string_name) {
emit_changed(get_edited_property(), StringName(p_string));
} else {
@ -104,6 +106,7 @@ void EditorPropertyText::update_property() {
if (text->get_text() != s) {
int caret = text->get_caret_column();
text->set_text(s);
text->set_tooltip_text(get_tooltip_string(s));
text->set_caret_column(caret);
}
text->set_editable(!is_read_only());
@ -129,9 +132,6 @@ void EditorPropertyText::set_placeholder(const String &p_string) {
text->set_placeholder(p_string);
}
void EditorPropertyText::_bind_methods() {
}
EditorPropertyText::EditorPropertyText() {
HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
@ -141,7 +141,7 @@ EditorPropertyText::EditorPropertyText() {
add_focusable(text);
text->set_h_size_flags(SIZE_EXPAND_FILL);
text->connect(SceneStringName(text_changed), callable_mp(this, &EditorPropertyText::_text_changed));
text->connect("text_submitted", callable_mp(this, &EditorPropertyText::_text_submitted));
text->connect(SceneStringName(text_submitted), callable_mp(this, &EditorPropertyText::_text_submitted));
}
///////////////////// MULTILINE TEXT /////////////////////////
@ -153,10 +153,14 @@ void EditorPropertyMultilineText::_set_read_only(bool p_read_only) {
void EditorPropertyMultilineText::_big_text_changed() {
text->set_text(big_text->get_text());
// Set tooltip so that the full text is displayed in a tooltip if hovered.
// This is useful when using a narrow inspector, as the text can be trimmed otherwise.
text->set_tooltip_text(get_tooltip_string(big_text->get_text()));
emit_changed(get_edited_property(), big_text->get_text(), "", true);
}
void EditorPropertyMultilineText::_text_changed() {
text->set_tooltip_text(get_tooltip_string(text->get_text()));
emit_changed(get_edited_property(), text->get_text(), "", true);
}
@ -185,6 +189,7 @@ void EditorPropertyMultilineText::update_property() {
String t = get_edited_property_value();
if (text->get_text() != t) {
text->set_text(t);
text->set_tooltip_text(get_tooltip_string(t));
if (big_text && big_text->is_visible_in_tree()) {
big_text->set_text(t);
}
@ -196,7 +201,7 @@ void EditorPropertyMultilineText::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: {
Ref<Texture2D> df = get_editor_theme_icon(SNAME("DistractionFree"));
open_big_text->set_icon(df);
open_big_text->set_button_icon(df);
Ref<Font> font;
int font_size;
@ -219,9 +224,6 @@ void EditorPropertyMultilineText::_notification(int p_what) {
}
}
void EditorPropertyMultilineText::_bind_methods() {
}
EditorPropertyMultilineText::EditorPropertyMultilineText(bool p_expression) {
HBoxContainer *hb = memnew(HBoxContainer);
hb->add_theme_constant_override("separation", 0);
@ -319,6 +321,9 @@ void EditorPropertyTextEnum::update_property() {
}
} else {
option_button->select(default_option);
if (default_option < 0) {
option_button->set_text(current_value);
}
}
}
@ -343,16 +348,13 @@ void EditorPropertyTextEnum::setup(const Vector<String> &p_options, bool p_strin
}
}
void EditorPropertyTextEnum::_bind_methods() {
}
void EditorPropertyTextEnum::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
edit_button->set_icon(get_editor_theme_icon(SNAME("Edit")));
accept_button->set_icon(get_editor_theme_icon(SNAME("ImportCheck")));
cancel_button->set_icon(get_editor_theme_icon(SNAME("ImportFail")));
edit_button->set_button_icon(get_editor_theme_icon(SNAME("Edit")));
accept_button->set_button_icon(get_editor_theme_icon(SNAME("ImportCheck")));
cancel_button->set_button_icon(get_editor_theme_icon(SNAME("ImportFail")));
} break;
}
}
@ -387,7 +389,7 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() {
custom_value_edit = memnew(LineEdit);
custom_value_edit->set_h_size_flags(SIZE_EXPAND_FILL);
edit_custom_layout->add_child(custom_value_edit);
custom_value_edit->connect("text_submitted", callable_mp(this, &EditorPropertyTextEnum::_custom_value_submitted));
custom_value_edit->connect(SceneStringName(text_submitted), callable_mp(this, &EditorPropertyTextEnum::_custom_value_submitted));
accept_button = memnew(Button);
accept_button->set_flat(true);
@ -438,7 +440,7 @@ void EditorPropertyLocale::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
locale_edit->set_icon(get_editor_theme_icon(SNAME("Translation")));
locale_edit->set_button_icon(get_editor_theme_icon(SNAME("Translation")));
} break;
}
}
@ -447,15 +449,12 @@ void EditorPropertyLocale::_locale_focus_exited() {
_locale_selected(locale->get_text());
}
void EditorPropertyLocale::_bind_methods() {
}
EditorPropertyLocale::EditorPropertyLocale() {
HBoxContainer *locale_hb = memnew(HBoxContainer);
add_child(locale_hb);
locale = memnew(LineEdit);
locale_hb->add_child(locale);
locale->connect("text_submitted", callable_mp(this, &EditorPropertyLocale::_locale_selected));
locale->connect(SceneStringName(text_submitted), callable_mp(this, &EditorPropertyLocale::_locale_selected));
locale->connect(SceneStringName(focus_exited), callable_mp(this, &EditorPropertyLocale::_locale_focus_exited));
locale->set_h_size_flags(SIZE_EXPAND_FILL);
@ -475,10 +474,28 @@ void EditorPropertyPath::_set_read_only(bool p_read_only) {
}
void EditorPropertyPath::_path_selected(const String &p_path) {
emit_changed(get_edited_property(), p_path);
String full_path = p_path;
if (!global) {
const ResourceUID::ID id = ResourceLoader::get_resource_uid(full_path);
if (id != ResourceUID::INVALID_ID) {
full_path = ResourceUID::get_singleton()->id_to_text(id);
}
}
emit_changed(get_edited_property(), full_path);
update_property();
}
String EditorPropertyPath::_get_path_text() {
String full_path = get_edited_property_value();
if (full_path.begins_with("uid://")) {
full_path = ResourceUID::uid_to_path(full_path);
}
return full_path;
}
void EditorPropertyPath::_path_pressed() {
if (!dialog) {
dialog = memnew(EditorFileDialog);
@ -487,7 +504,7 @@ void EditorPropertyPath::_path_pressed() {
add_child(dialog);
}
String full_path = get_edited_property_value();
String full_path = _get_path_text();
dialog->clear_filters();
@ -515,7 +532,7 @@ void EditorPropertyPath::_path_pressed() {
}
void EditorPropertyPath::update_property() {
String full_path = get_edited_property_value();
String full_path = _get_path_text();
path->set_text(full_path);
path->set_tooltip_text(full_path);
}
@ -535,9 +552,9 @@ void EditorPropertyPath::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
if (folder) {
path_edit->set_icon(get_editor_theme_icon(SNAME("FolderBrowse")));
path_edit->set_button_icon(get_editor_theme_icon(SNAME("FolderBrowse")));
} else {
path_edit->set_icon(get_editor_theme_icon(SNAME("FileBrowse")));
path_edit->set_button_icon(get_editor_theme_icon(SNAME("FileBrowse")));
}
} break;
}
@ -560,8 +577,7 @@ void EditorPropertyPath::_drop_data_fw(const Point2 &p_point, const Variant &p_d
return;
}
emit_changed(get_edited_property(), filesPaths[0]);
update_property();
_path_selected(filesPaths[0]);
}
bool EditorPropertyPath::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
@ -586,9 +602,6 @@ bool EditorPropertyPath::_can_drop_data_fw(const Point2 &p_point, const Variant
return false;
}
void EditorPropertyPath::_bind_methods() {
}
EditorPropertyPath::EditorPropertyPath() {
HBoxContainer *path_hb = memnew(HBoxContainer);
add_child(path_hb);
@ -596,7 +609,7 @@ EditorPropertyPath::EditorPropertyPath() {
SET_DRAG_FORWARDING_CDU(path, EditorPropertyPath);
path->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
path_hb->add_child(path);
path->connect("text_submitted", callable_mp(this, &EditorPropertyPath::_path_selected));
path->connect(SceneStringName(text_submitted), callable_mp(this, &EditorPropertyPath::_path_selected));
path->connect(SceneStringName(focus_exited), callable_mp(this, &EditorPropertyPath::_path_focus_exited));
path->set_h_size_flags(SIZE_EXPAND_FILL);
@ -637,9 +650,6 @@ void EditorPropertyClassName::_dialog_created() {
update_property();
}
void EditorPropertyClassName::_bind_methods() {
}
EditorPropertyClassName::EditorPropertyClassName() {
property = memnew(Button);
property->set_clip_text(true);
@ -669,9 +679,6 @@ void EditorPropertyCheck::update_property() {
checkbox->set_disabled(is_read_only());
}
void EditorPropertyCheck::_bind_methods() {
}
EditorPropertyCheck::EditorPropertyCheck() {
checkbox = memnew(CheckBox);
checkbox->set_text(TTR("On"));
@ -695,6 +702,7 @@ void EditorPropertyEnum::update_property() {
Variant current = get_edited_property_value();
if (current.get_type() == Variant::NIL) {
options->select(-1);
options->set_text("<null>");
return;
}
@ -705,29 +713,33 @@ void EditorPropertyEnum::update_property() {
return;
}
}
options->select(-1);
options->set_text(itos(which));
}
void EditorPropertyEnum::setup(const Vector<String> &p_options) {
options->clear();
HashMap<int64_t, Vector<String>> items;
int64_t current_val = 0;
for (int i = 0; i < p_options.size(); i++) {
Vector<String> text_split = p_options[i].split(":");
for (const String &option : p_options) {
Vector<String> text_split = option.split(":");
if (text_split.size() != 1) {
current_val = text_split[1].to_int();
}
options->add_item(text_split[0]);
options->set_item_metadata(i, current_val);
items[current_val].push_back(text_split[0]);
current_val += 1;
}
for (const KeyValue<int64_t, Vector<String>> &K : items) {
options->add_item(String(", ").join(K.value));
options->set_item_metadata(-1, K.key);
}
}
void EditorPropertyEnum::set_option_button_clip(bool p_enable) {
options->set_clip_text(p_enable);
}
void EditorPropertyEnum::_bind_methods() {
}
EditorPropertyEnum::EditorPropertyEnum() {
options = memnew(OptionButton);
options->set_clip_text(true);
@ -804,9 +816,6 @@ void EditorPropertyFlags::setup(const Vector<String> &p_options) {
}
}
void EditorPropertyFlags::_bind_methods() {
}
EditorPropertyFlags::EditorPropertyFlags() {
vbox = memnew(VBoxContainer);
add_child(vbox);
@ -832,7 +841,7 @@ void EditorPropertyLayersGrid::_rename_operation_confirm() {
if (new_name.length() == 0) {
EditorNode::get_singleton()->show_warning(TTR("No name provided."));
return;
} else if (new_name.contains("/") || new_name.contains("\\") || new_name.contains(":")) {
} else if (new_name.contains_char('/') || new_name.contains_char('\\') || new_name.contains_char(':')) {
EditorNode::get_singleton()->show_warning(TTR("Name contains invalid characters."));
return;
}
@ -1280,9 +1289,6 @@ void EditorPropertyLayers::_refresh_names() {
setup(layer_type);
}
void EditorPropertyLayers::_bind_methods() {
}
EditorPropertyLayers::EditorPropertyLayers() {
HBoxContainer *hb = memnew(HBoxContainer);
hb->set_clip_contents(true);
@ -1330,9 +1336,6 @@ void EditorPropertyInteger::update_property() {
#endif
}
void EditorPropertyInteger::_bind_methods() {
}
void EditorPropertyInteger::setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_hide_slider, bool p_allow_greater, bool p_allow_lesser, const String &p_suffix) {
spin->set_min(p_min);
spin->set_max(p_max);
@ -1346,6 +1349,7 @@ void EditorPropertyInteger::setup(int64_t p_min, int64_t p_max, int64_t p_step,
EditorPropertyInteger::EditorPropertyInteger() {
spin = memnew(EditorSpinSlider);
spin->set_flat(true);
spin->set_editing_integer(true);
add_child(spin);
add_focusable(spin);
spin->connect(SceneStringName(value_changed), callable_mp(this, &EditorPropertyInteger::_value_changed));
@ -1372,12 +1376,12 @@ void EditorPropertyObjectID::update_property() {
edit->set_text(type + " ID: " + uitos(id));
edit->set_tooltip_text(type + " ID: " + uitos(id));
edit->set_disabled(false);
edit->set_icon(EditorNode::get_singleton()->get_class_icon(type));
edit->set_button_icon(EditorNode::get_singleton()->get_class_icon(type));
} else {
edit->set_text(TTR("<empty>"));
edit->set_tooltip_text("");
edit->set_disabled(true);
edit->set_icon(Ref<Texture2D>());
edit->set_button_icon(Ref<Texture2D>());
}
}
@ -1385,9 +1389,6 @@ void EditorPropertyObjectID::setup(const String &p_base_type) {
base_type = p_base_type;
}
void EditorPropertyObjectID::_bind_methods() {
}
EditorPropertyObjectID::EditorPropertyObjectID() {
edit = memnew(Button);
add_child(edit);
@ -1410,10 +1411,7 @@ void EditorPropertySignal::update_property() {
edit->set_text("Signal: " + signal.get_name());
edit->set_disabled(false);
edit->set_icon(get_editor_theme_icon(SNAME("Signals")));
}
void EditorPropertySignal::_bind_methods() {
edit->set_button_icon(get_editor_theme_icon(SNAME("Signals")));
}
EditorPropertySignal::EditorPropertySignal() {
@ -1432,10 +1430,7 @@ void EditorPropertyCallable::update_property() {
edit->set_text("Callable");
edit->set_disabled(true);
edit->set_icon(get_editor_theme_icon(SNAME("Callable")));
}
void EditorPropertyCallable::_bind_methods() {
edit->set_button_icon(get_editor_theme_icon(SNAME("Callable")));
}
EditorPropertyCallable::EditorPropertyCallable() {
@ -1465,9 +1460,6 @@ void EditorPropertyFloat::update_property() {
spin->set_value_no_signal(val);
}
void EditorPropertyFloat::_bind_methods() {
}
void EditorPropertyFloat::setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix, bool p_radians_as_degrees) {
radians_as_degrees = p_radians_as_degrees;
spin->set_min(p_min);
@ -1675,9 +1667,6 @@ void EditorPropertyEasing::_notification(int p_what) {
}
}
void EditorPropertyEasing::_bind_methods() {
}
EditorPropertyEasing::EditorPropertyEasing() {
easing_draw = memnew(Control);
easing_draw->connect(SceneStringName(draw), callable_mp(this, &EditorPropertyEasing::_draw_easing));
@ -1740,9 +1729,6 @@ void EditorPropertyRect2::_notification(int p_what) {
}
}
void EditorPropertyRect2::_bind_methods() {
}
void EditorPropertyRect2::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 4; i++) {
spin[i]->set_min(p_min);
@ -1837,9 +1823,6 @@ void EditorPropertyRect2i::_notification(int p_what) {
}
}
void EditorPropertyRect2i::_bind_methods() {
}
void EditorPropertyRect2i::setup(int p_min, int p_max, const String &p_suffix) {
for (int i = 0; i < 4; i++) {
spin[i]->set_min(p_min);
@ -1848,6 +1831,7 @@ void EditorPropertyRect2i::setup(int p_min, int p_max, const String &p_suffix) {
spin[i]->set_allow_greater(true);
spin[i]->set_allow_lesser(true);
spin[i]->set_suffix(p_suffix);
spin[i]->set_editing_integer(true);
}
}
@ -1933,9 +1917,6 @@ void EditorPropertyPlane::_notification(int p_what) {
}
}
void EditorPropertyPlane::_bind_methods() {
}
void EditorPropertyPlane::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 4; i++) {
spin[i]->set_min(p_min);
@ -2077,17 +2058,14 @@ void EditorPropertyQuaternion::_notification(int p_what) {
for (int i = 0; i < 3; i++) {
euler[i]->add_theme_color_override("label_color", colors[i]);
}
edit_button->set_icon(get_editor_theme_icon(SNAME("Edit")));
edit_button->set_button_icon(get_editor_theme_icon(SNAME("Edit")));
euler_label->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("property_color"), SNAME("EditorProperty")));
warning->set_icon(get_editor_theme_icon(SNAME("NodeWarning")));
warning->set_button_icon(get_editor_theme_icon(SNAME("NodeWarning")));
warning->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
} break;
}
}
void EditorPropertyQuaternion::_bind_methods() {
}
void EditorPropertyQuaternion::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix, bool p_hide_editor) {
for (int i = 0; i < 4; i++) {
spin[i]->set_min(p_min);
@ -2232,9 +2210,6 @@ void EditorPropertyAABB::_notification(int p_what) {
}
}
void EditorPropertyAABB::_bind_methods() {
}
void EditorPropertyAABB::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 6; i++) {
spin[i]->set_min(p_min);
@ -2313,9 +2288,6 @@ void EditorPropertyTransform2D::_notification(int p_what) {
}
}
void EditorPropertyTransform2D::_bind_methods() {
}
void EditorPropertyTransform2D::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 6; i++) {
spin[i]->set_min(p_min);
@ -2398,9 +2370,6 @@ void EditorPropertyBasis::_notification(int p_what) {
}
}
void EditorPropertyBasis::_bind_methods() {
}
void EditorPropertyBasis::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 9; i++) {
spin[i]->set_min(p_min);
@ -2490,9 +2459,6 @@ void EditorPropertyTransform3D::_notification(int p_what) {
}
}
void EditorPropertyTransform3D::_bind_methods() {
}
void EditorPropertyTransform3D::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 12; i++) {
spin[i]->set_min(p_min);
@ -2590,9 +2556,6 @@ void EditorPropertyProjection::_notification(int p_what) {
}
}
void EditorPropertyProjection::_bind_methods() {
}
void EditorPropertyProjection::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
for (int i = 0; i < 16; i++) {
spin[i]->set_min(p_min);
@ -2644,6 +2607,17 @@ void EditorPropertyColor::_color_changed(const Color &p_color) {
get_edited_object()->set(get_edited_property(), p_color);
}
void EditorPropertyColor::_picker_created() {
picker->get_popup()->connect("about_to_popup", callable_mp(this, &EditorPropertyColor::_popup_opening));
picker->connect("popup_closed", callable_mp(this, &EditorPropertyColor::_popup_closed), CONNECT_DEFERRED);
}
void EditorPropertyColor::_popup_opening() {
EditorNode::get_singleton()->setup_color_picker(picker->get_picker());
last_color = picker->get_pick_color();
was_checked = !is_checkable() || is_checked();
}
void EditorPropertyColor::_popup_closed() {
get_edited_object()->set(get_edited_property(), was_checked ? Variant(last_color) : Variant());
if (!picker->get_pick_color().is_equal_approx(last_color)) {
@ -2651,11 +2625,6 @@ void EditorPropertyColor::_popup_closed() {
}
}
void EditorPropertyColor::_picker_opening() {
last_color = picker->get_pick_color();
was_checked = !is_checkable() || is_checked();
}
void EditorPropertyColor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
@ -2699,9 +2668,7 @@ EditorPropertyColor::EditorPropertyColor() {
add_child(picker);
picker->set_flat(true);
picker->connect("color_changed", callable_mp(this, &EditorPropertyColor::_color_changed));
picker->connect("popup_closed", callable_mp(this, &EditorPropertyColor::_popup_closed));
picker->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker).bind(picker->get_picker()));
picker->get_popup()->connect("about_to_popup", callable_mp(this, &EditorPropertyColor::_picker_opening));
picker->connect("picker_created", callable_mp(this, &EditorPropertyColor::_picker_created), CONNECT_ONE_SHOT);
}
////////////// NODE PATH //////////////////////
@ -2709,7 +2676,7 @@ EditorPropertyColor::EditorPropertyColor() {
void EditorPropertyNodePath::_set_read_only(bool p_read_only) {
assign->set_disabled(p_read_only);
menu->set_disabled(p_read_only);
};
}
Variant EditorPropertyNodePath::_get_cache_value(const StringName &p_prop, bool &r_valid) const {
if (p_prop == get_edited_property()) {
@ -2719,7 +2686,7 @@ Variant EditorPropertyNodePath::_get_cache_value(const StringName &p_prop, bool
return Variant();
}
void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {
void EditorPropertyNodePath::_node_selected(const NodePath &p_path, bool p_absolute) {
NodePath path = p_path;
Node *base_node = get_base_node();
@ -2729,7 +2696,7 @@ void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {
path = get_tree()->get_edited_scene_root()->get_path_to(to_node);
}
if (base_node) { // for AnimationTrackKeyEdit
if (p_absolute && base_node) { // for AnimationTrackKeyEdit
path = base_node->get_path().rel_path_to(p_path);
}
@ -2751,7 +2718,7 @@ void EditorPropertyNodePath::_node_assign() {
scene_tree->get_scene_tree()->set_show_enabled_subscene(true);
scene_tree->set_valid_types(valid_types);
add_child(scene_tree);
scene_tree->connect("selected", callable_mp(this, &EditorPropertyNodePath::_node_selected));
scene_tree->connect("selected", callable_mp(this, &EditorPropertyNodePath::_node_selected).bind(true));
}
Variant val = get_edited_property_value();
@ -2778,7 +2745,11 @@ void EditorPropertyNodePath::_update_menu() {
void EditorPropertyNodePath::_menu_option(int p_idx) {
switch (p_idx) {
case ACTION_CLEAR: {
emit_changed(get_edited_property(), NodePath());
if (editing_node) {
emit_changed(get_edited_property(), Variant());
} else {
emit_changed(get_edited_property(), NodePath());
}
update_property();
} break;
@ -2815,7 +2786,7 @@ void EditorPropertyNodePath::_accept_text() {
void EditorPropertyNodePath::_text_submitted(const String &p_text) {
NodePath np = p_text;
emit_changed(get_edited_property(), np);
_node_selected(np, false);
edit->hide();
assign->show();
menu->show();
@ -2896,7 +2867,7 @@ void EditorPropertyNodePath::update_property() {
assign->set_tooltip_text(p);
if (p.is_empty()) {
assign->set_icon(Ref<Texture2D>());
assign->set_button_icon(Ref<Texture2D>());
assign->set_text(TTR("Assign..."));
assign->set_flat(false);
return;
@ -2904,7 +2875,7 @@ void EditorPropertyNodePath::update_property() {
assign->set_flat(true);
if (!base_node || !base_node->has_node(p)) {
assign->set_icon(Ref<Texture2D>());
assign->set_button_icon(Ref<Texture2D>());
assign->set_text(p);
return;
}
@ -2912,14 +2883,14 @@ void EditorPropertyNodePath::update_property() {
const Node *target_node = base_node->get_node(p);
ERR_FAIL_NULL(target_node);
if (String(target_node->get_name()).contains("@")) {
assign->set_icon(Ref<Texture2D>());
if (String(target_node->get_name()).contains_char('@')) {
assign->set_button_icon(Ref<Texture2D>());
assign->set_text(p);
return;
}
assign->set_text(target_node->get_name());
assign->set_icon(EditorNode::get_singleton()->get_object_icon(target_node, "Node"));
assign->set_button_icon(EditorNode::get_singleton()->get_object_icon(target_node, "Node"));
}
void EditorPropertyNodePath::setup(const Vector<StringName> &p_valid_types, bool p_use_path_from_scene_root, bool p_editing_node) {
@ -2932,7 +2903,7 @@ void EditorPropertyNodePath::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
menu->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl")));
menu->set_button_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl")));
menu->get_popup()->set_item_icon(ACTION_CLEAR, get_editor_theme_icon(SNAME("Clear")));
menu->get_popup()->set_item_icon(ACTION_COPY, get_editor_theme_icon(SNAME("ActionCopy")));
menu->get_popup()->set_item_icon(ACTION_EDIT, get_editor_theme_icon(SNAME("Edit")));
@ -2996,7 +2967,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() {
edit->set_h_size_flags(SIZE_EXPAND_FILL);
edit->hide();
edit->connect(SceneStringName(focus_exited), callable_mp(this, &EditorPropertyNodePath::_accept_text));
edit->connect(SNAME("text_submitted"), callable_mp(this, &EditorPropertyNodePath::_text_submitted));
edit->connect(SceneStringName(text_submitted), callable_mp(this, &EditorPropertyNodePath::_text_submitted));
hbc->add_child(edit);
}
@ -3246,6 +3217,10 @@ void EditorPropertyResource::_update_preferred_shader() {
}
}
bool EditorPropertyResource::_should_stop_editing() const {
return !resource_picker->is_toggle_pressed();
}
void EditorPropertyResource::_viewport_selected(const NodePath &p_path) {
Node *to_node = get_node(p_path);
if (!Object::cast_to<Viewport>(to_node)) {
@ -3284,6 +3259,7 @@ void EditorPropertyResource::setup(Object *p_object, const String &p_path, const
}
resource_picker->set_base_type(p_base_type);
resource_picker->set_resource_owner(p_object);
resource_picker->set_editable(true);
resource_picker->set_h_size_flags(SIZE_EXPAND_FILL);
add_child(resource_picker);
@ -3313,7 +3289,10 @@ void EditorPropertyResource::update_property() {
sub_inspector->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
sub_inspector->set_use_doc_hints(true);
sub_inspector->set_sub_inspector(true);
EditorInspector *parent_inspector = get_parent_inspector();
ERR_FAIL_NULL(parent_inspector);
sub_inspector->set_root_inspector(parent_inspector->get_root_inspector());
sub_inspector->set_property_name_style(InspectorDock::get_singleton()->get_property_name_style());
sub_inspector->connect("property_keyed", callable_mp(this, &EditorPropertyResource::_sub_inspector_property_keyed));
@ -3323,6 +3302,11 @@ void EditorPropertyResource::update_property() {
sub_inspector->set_read_only(is_read_only());
sub_inspector->set_use_folding(is_using_folding());
sub_inspector->set_draw_focus_border(false);
sub_inspector->set_use_filter(use_filter);
sub_inspector->register_text_enter(parent_inspector->search_box);
sub_inspector->set_mouse_filter(MOUSE_FILTER_STOP);
add_child(sub_inspector);
set_bottom_editor(sub_inspector);
@ -3349,16 +3333,14 @@ void EditorPropertyResource::update_property() {
_update_property_bg();
}
} else {
if (sub_inspector) {
set_bottom_editor(nullptr);
memdelete(sub_inspector);
sub_inspector = nullptr;
} else if (sub_inspector) {
set_bottom_editor(nullptr);
memdelete(sub_inspector);
sub_inspector = nullptr;
if (opened_editor) {
EditorNode::get_singleton()->hide_unused_editors();
opened_editor = false;
}
if (opened_editor) {
EditorNode::get_singleton()->hide_unused_editors();
opened_editor = false;
}
}
}
@ -3388,6 +3370,13 @@ void EditorPropertyResource::set_use_sub_inspector(bool p_enable) {
use_sub_inspector = p_enable;
}
void EditorPropertyResource::set_use_filter(bool p_use) {
use_filter = p_use;
if (sub_inspector) {
update_property();
}
}
void EditorPropertyResource::fold_resource() {
bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property());
if (unfolded) {
@ -3417,13 +3406,18 @@ void EditorPropertyResource::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_EXIT_TREE: {
const EditorInspector *ei = get_parent_inspector();
if (ei && !ei->is_main_editor_inspector()) {
const EditorInspector *main_ei = InspectorDock::get_inspector_singleton();
if (ei && main_ei && ei != main_ei && !main_ei->is_ancestor_of(ei)) {
fold_resource();
}
} break;
}
}
void EditorPropertyResource::_bind_methods() {
ClassDB::bind_method(D_METHOD("_should_stop_editing"), &EditorPropertyResource::_should_stop_editing);
}
EditorPropertyResource::EditorPropertyResource() {
use_sub_inspector = bool(EDITOR_GET("interface/inspector/open_resources_in_current_inspector"));
has_borders = true;
@ -3676,7 +3670,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
case Variant::VECTOR2I: {
EditorPropertyVector2i *editor = memnew(EditorPropertyVector2i(p_wide));
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
editor->setup(hint.min, hint.max, 1, false, p_hint == PROPERTY_HINT_LINK, hint.suffix);
editor->setup(hint.min, hint.max, 1, false, p_hint == PROPERTY_HINT_LINK, hint.suffix, false, true);
return editor;
} break;
@ -3703,7 +3697,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
case Variant::VECTOR3I: {
EditorPropertyVector3i *editor = memnew(EditorPropertyVector3i(p_wide));
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
editor->setup(hint.min, hint.max, 1, false, p_hint == PROPERTY_HINT_LINK, hint.suffix);
editor->setup(hint.min, hint.max, 1, false, p_hint == PROPERTY_HINT_LINK, hint.suffix, false, true);
return editor;
} break;
@ -3717,7 +3711,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
case Variant::VECTOR4I: {
EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i);
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
editor->setup(hint.min, hint.max, 1, false, p_hint == PROPERTY_HINT_LINK, hint.suffix);
editor->setup(hint.min, hint.max, 1, false, p_hint == PROPERTY_HINT_LINK, hint.suffix, false, true);
return editor;
} break;
@ -3846,7 +3840,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
return editor;
} else {
EditorPropertyDictionary *editor = memnew(EditorPropertyDictionary);
editor->setup(p_hint);
editor->setup(p_hint, p_hint_text);
return editor;
}
} break;