summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/doc_tools.cpp2
-rw-r--r--editor/editor_data.cpp15
-rw-r--r--editor/editor_data.h7
-rw-r--r--editor/editor_export.cpp2
-rw-r--r--editor/editor_help.cpp2
-rw-r--r--editor/editor_inspector.cpp1292
-rw-r--r--editor/editor_inspector.h131
-rw-r--r--editor/filesystem_dock.cpp15
-rw-r--r--editor/icons/AnimatableBody2D.svg1
-rw-r--r--editor/icons/AnimatableBody3D.svg1
-rw-r--r--editor/icons/Listener2D.svg1
-rw-r--r--editor/icons/PageFirst.svg47
-rw-r--r--editor/icons/PageLast.svg47
-rw-r--r--editor/icons/PageNext.svg42
-rw-r--r--editor/icons/PagePrevious.svg42
-rw-r--r--editor/import/resource_importer_texture.cpp2
-rw-r--r--editor/plugins/node_3d_editor_gizmos.cpp12
-rw-r--r--editor/plugins/packed_scene_translation_parser_plugin.cpp49
-rw-r--r--editor/plugins/packed_scene_translation_parser_plugin.h4
-rw-r--r--editor/plugins/script_text_editor.cpp1
-rw-r--r--editor/plugins/tiles/tile_data_editors.cpp7
-rw-r--r--editor/plugins/tiles/tile_map_editor.cpp80
-rw-r--r--editor/plugins/tiles/tile_map_editor.h2
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.cpp2
-rw-r--r--editor/plugins/tiles/tile_set_editor.cpp225
-rw-r--r--editor/plugins/tiles/tile_set_editor.h1
-rw-r--r--editor/pot_generator.cpp13
-rw-r--r--editor/project_settings_editor.cpp1
-rw-r--r--editor/scene_tree_dock.cpp5
-rw-r--r--editor/scene_tree_dock.h1
-rw-r--r--editor/scene_tree_editor.cpp8
31 files changed, 1726 insertions, 334 deletions
diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp
index fee2deddda..d04875f188 100644
--- a/editor/doc_tools.cpp
+++ b/editor/doc_tools.cpp
@@ -277,7 +277,7 @@ void DocTools::generate(bool p_basic_types) {
EO = EO->next();
}
- if (E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP || E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_INTERNAL) {
+ if (E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP || E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_INTERNAL || (E.type == Variant::NIL && E.usage & PROPERTY_USAGE_ARRAY)) {
continue;
}
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index c62e5b75b2..e40bbefef8 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -438,6 +438,21 @@ const Vector<Callable> EditorData::get_undo_redo_inspector_hook_callback() {
return undo_redo_callbacks;
}
+void EditorData::add_move_array_element_function(const StringName &p_class, Callable p_callable) {
+ move_element_functions.insert(p_class, p_callable);
+}
+
+void EditorData::remove_move_array_element_function(const StringName &p_class) {
+ move_element_functions.erase(p_class);
+}
+
+Callable EditorData::get_move_array_element_function(const StringName &p_class) const {
+ if (move_element_functions.has(p_class)) {
+ return move_element_functions[p_class];
+ }
+ return Callable();
+}
+
void EditorData::remove_editor_plugin(EditorPlugin *p_plugin) {
p_plugin->undo_redo = nullptr;
editor_plugins.erase(p_plugin);
diff --git a/editor/editor_data.h b/editor/editor_data.h
index df6ba9d0c9..9184ddcf39 100644
--- a/editor/editor_data.h
+++ b/editor/editor_data.h
@@ -133,6 +133,7 @@ private:
List<PropertyData> clipboard;
UndoRedo undo_redo;
Vector<Callable> undo_redo_callbacks;
+ Map<StringName, Callable> move_element_functions;
void _cleanup_history();
@@ -167,10 +168,14 @@ public:
EditorPlugin *get_editor_plugin(int p_idx);
UndoRedo &get_undo_redo();
- void add_undo_redo_inspector_hook_callback(Callable p_callable); // Callbacks should have 4 args: (Object* undo_redo, Object *modified_object, String property, Variant new_value)
+ void add_undo_redo_inspector_hook_callback(Callable p_callable); // Callbacks should have this signature: void (Object* undo_redo, Object *modified_object, String property, Variant new_value)
void remove_undo_redo_inspector_hook_callback(Callable p_callable);
const Vector<Callable> get_undo_redo_inspector_hook_callback();
+ void add_move_array_element_function(const StringName &p_class, Callable p_callable); // Function should have this signature: void (Object* undo_redo, Object *modified_object, String array_prefix, int element_index, int new_position)
+ void remove_move_array_element_function(const StringName &p_class);
+ Callable get_move_array_element_function(const StringName &p_class) const;
+
void save_editor_global_states();
void restore_editor_global_states();
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index 1240496028..10ed76673e 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -1948,7 +1948,7 @@ void EditorExportPlatformPC::set_debug_32(const String &p_file) {
void EditorExportPlatformPC::get_platform_features(List<String> *r_features) {
r_features->push_back("pc"); //all pcs support "pc"
r_features->push_back("s3tc"); //all pcs support "s3tc" compression
- r_features->push_back(get_os_name()); //OS name is a feature
+ r_features->push_back(get_os_name().to_lower()); //OS name is a feature
}
void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) {
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 24b6ba1a14..490c8f287f 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -1328,6 +1328,8 @@ void EditorHelp::_help_callback(const String &p_topic) {
} else if (what == "class_global") {
if (constant_line.has(name)) {
line = constant_line[name];
+ } else if (method_line.has(name)) {
+ line = method_line[name];
} else {
Map<String, Map<String, int>>::Element *iter = enum_values_line.front();
while (true) {
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 03d1521bab..d3841ad6c0 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -1184,147 +1184,144 @@ EditorInspectorCategory::EditorInspectorCategory() {
void EditorInspectorSection::_test_unfold() {
if (!vbox_added) {
add_child(vbox);
+ move_child(vbox, 0);
vbox_added = true;
}
}
void EditorInspectorSection::_notification(int p_what) {
- if (p_what == NOTIFICATION_SORT_CHILDREN) {
- Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
- int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
-
- Ref<Texture2D> arrow;
-
- if (foldable) {
- if (object->editor_is_section_unfolded(section)) {
- arrow = get_theme_icon(SNAME("arrow"), SNAME("Tree"));
- } else {
- if (is_layout_rtl()) {
- arrow = get_theme_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree"));
+ switch (p_what) {
+ case NOTIFICATION_THEME_CHANGED: {
+ minimum_size_changed();
+ } break;
+ case NOTIFICATION_SORT_CHILDREN: {
+ if (!vbox_added) {
+ return;
+ }
+ // Get the section header font.
+ Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
+ int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
+
+ // Get the right direction arrow texture, if the section is foldable.
+ Ref<Texture2D> arrow;
+ if (foldable) {
+ if (object->editor_is_section_unfolded(section)) {
+ arrow = get_theme_icon(SNAME("arrow"), SNAME("Tree"));
} else {
- arrow = get_theme_icon(SNAME("arrow_collapsed"), SNAME("Tree"));
+ if (is_layout_rtl()) {
+ arrow = get_theme_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree"));
+ } else {
+ arrow = get_theme_icon(SNAME("arrow_collapsed"), SNAME("Tree"));
+ }
}
}
- }
- Size2 size = get_size();
- Point2 offset;
- Rect2 rect;
- offset.y = font->get_height(font_size);
- if (arrow.is_valid()) {
- offset.y = MAX(offset.y, arrow->get_height());
- }
-
- offset.y += get_theme_constant(SNAME("vseparation"), SNAME("Tree"));
- if (is_layout_rtl()) {
- rect = Rect2(offset, size - offset - Vector2(get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")), 0));
- } else {
- offset.x += get_theme_constant(SNAME("inspector_margin"), SNAME("Editor"));
- rect = Rect2(offset, size - offset);
- }
-
- //set children
- for (int i = 0; i < get_child_count(); i++) {
- Control *c = Object::cast_to<Control>(get_child(i));
- if (!c) {
- continue;
- }
- if (c->is_set_as_top_level()) {
- continue;
- }
- if (!c->is_visible_in_tree()) {
- continue;
+ // Compute the height of the section header.
+ int header_height = font->get_height(font_size);
+ if (arrow.is_valid()) {
+ header_height = MAX(header_height, arrow->get_height());
}
+ header_height += get_theme_constant(SNAME("vseparation"), SNAME("Tree"));
- fit_child_in_rect(c, rect);
- }
-
- update(); //need to redraw text
- }
-
- if (p_what == NOTIFICATION_DRAW) {
- Ref<Texture2D> arrow;
- bool rtl = is_layout_rtl();
+ int inspector_margin = get_theme_constant(SNAME("inspector_margin"), SNAME("Editor"));
+ Size2 size = get_size() - Vector2(inspector_margin, 0);
+ Vector2 offset = Vector2(is_layout_rtl() ? 0 : inspector_margin, header_height);
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = Object::cast_to<Control>(get_child(i));
+ if (!c) {
+ continue;
+ }
+ if (c->is_set_as_top_level()) {
+ continue;
+ }
- if (foldable) {
- if (object->editor_is_section_unfolded(section)) {
- arrow = get_theme_icon(SNAME("arrow"), SNAME("Tree"));
- } else {
- if (is_layout_rtl()) {
- arrow = get_theme_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree"));
+ fit_child_in_rect(c, Rect2(offset, size));
+ }
+ } break;
+ case NOTIFICATION_DRAW: {
+ // Get the section header font.
+ Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
+ int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
+
+ // Get the right direction arrow texture, if the section is foldable.
+ Ref<Texture2D> arrow;
+ if (foldable) {
+ if (object->editor_is_section_unfolded(section)) {
+ arrow = get_theme_icon(SNAME("arrow"), SNAME("Tree"));
} else {
- arrow = get_theme_icon(SNAME("arrow_collapsed"), SNAME("Tree"));
+ if (is_layout_rtl()) {
+ arrow = get_theme_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree"));
+ } else {
+ arrow = get_theme_icon(SNAME("arrow_collapsed"), SNAME("Tree"));
+ }
}
}
- }
-
- Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
- int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
-
- int h = font->get_height(font_size);
- if (arrow.is_valid()) {
- h = MAX(h, arrow->get_height());
- }
- h += get_theme_constant(SNAME("vseparation"), SNAME("Tree"));
- Color c = bg_color;
- c.a *= 0.4;
- draw_rect(Rect2(Vector2(), Vector2(get_size().width, h)), c);
+ bool rtl = is_layout_rtl();
- const int arrow_margin = 2;
- const int arrow_width = arrow.is_valid() ? arrow->get_width() : 0;
- Color color = get_theme_color(SNAME("font_color"));
- float text_width = get_size().width - Math::round(arrow_width + arrow_margin * EDSCALE);
- draw_string(font, Point2(rtl ? 0 : Math::round(arrow_width + arrow_margin * EDSCALE), font->get_ascent(font_size) + (h - font->get_height(font_size)) / 2).floor(), label, rtl ? HALIGN_RIGHT : HALIGN_LEFT, text_width, font_size, color);
-
- if (arrow.is_valid()) {
- if (rtl) {
- draw_texture(arrow, Point2(get_size().width - arrow->get_width() - Math::round(arrow_margin * EDSCALE), (h - arrow->get_height()) / 2).floor());
- } else {
- draw_texture(arrow, Point2(Math::round(arrow_margin * EDSCALE), (h - arrow->get_height()) / 2).floor());
+ // Compute the height of the section header.
+ int header_height = font->get_height(font_size);
+ if (arrow.is_valid()) {
+ header_height = MAX(header_height, arrow->get_height());
}
- }
+ header_height += get_theme_constant(SNAME("vseparation"), SNAME("Tree"));
- if (dropping && !vbox->is_visible_in_tree()) {
- Color accent_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
- draw_rect(Rect2(Point2(), get_size()), accent_color, false);
- }
- }
+ Color c = bg_color;
+ c.a *= 0.4;
+ draw_rect(Rect2(Vector2(), Vector2(get_size().width, header_height)), c);
- if (p_what == NOTIFICATION_DRAG_BEGIN) {
- Dictionary dd = get_viewport()->gui_get_drag_data();
+ const int arrow_margin = 2;
+ const int arrow_width = arrow.is_valid() ? arrow->get_width() : 0;
+ Color color = get_theme_color(SNAME("font_color"));
+ float text_width = get_size().width - Math::round(arrow_width + arrow_margin * EDSCALE);
+ draw_string(font, Point2(rtl ? 0 : Math::round(arrow_width + arrow_margin * EDSCALE), font->get_ascent(font_size) + (header_height - font->get_height(font_size)) / 2).floor(), label, rtl ? HALIGN_RIGHT : HALIGN_LEFT, text_width, font_size, color);
- // Only allow dropping if the section contains properties which can take the dragged data.
- bool children_can_drop = false;
- for (int child_idx = 0; child_idx < vbox->get_child_count(); child_idx++) {
- Control *editor_property = Object::cast_to<Control>(vbox->get_child(child_idx));
+ if (arrow.is_valid()) {
+ if (rtl) {
+ draw_texture(arrow, Point2(get_size().width - arrow->get_width() - Math::round(arrow_margin * EDSCALE), (header_height - arrow->get_height()) / 2).floor());
+ } else {
+ draw_texture(arrow, Point2(Math::round(arrow_margin * EDSCALE), (header_height - arrow->get_height()) / 2).floor());
+ }
+ }
- // Test can_drop_data and can_drop_data_fw, since can_drop_data only works if set up with forwarding or if script attached.
- if (editor_property && (editor_property->can_drop_data(Point2(), dd) || editor_property->call("_can_drop_data_fw", Point2(), dd, this))) {
- children_can_drop = true;
- break;
+ if (dropping && !vbox->is_visible_in_tree()) {
+ Color accent_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ draw_rect(Rect2(Point2(), get_size()), accent_color, false);
}
- }
+ } break;
+ case NOTIFICATION_DRAG_BEGIN: {
+ Dictionary dd = get_viewport()->gui_get_drag_data();
- dropping = children_can_drop;
- update();
- }
+ // Only allow dropping if the section contains properties which can take the dragged data.
+ bool children_can_drop = false;
+ for (int child_idx = 0; child_idx < vbox->get_child_count(); child_idx++) {
+ Control *editor_property = Object::cast_to<Control>(vbox->get_child(child_idx));
- if (p_what == NOTIFICATION_DRAG_END) {
- dropping = false;
- update();
- }
+ // Test can_drop_data and can_drop_data_fw, since can_drop_data only works if set up with forwarding or if script attached.
+ if (editor_property && (editor_property->can_drop_data(Point2(), dd) || editor_property->call("_can_drop_data_fw", Point2(), dd, this))) {
+ children_can_drop = true;
+ break;
+ }
+ }
- if (p_what == NOTIFICATION_MOUSE_ENTER) {
- if (dropping) {
- dropping_unfold_timer->start();
- }
- }
+ dropping = children_can_drop;
+ update();
+ } break;
+ case NOTIFICATION_DRAG_END: {
+ dropping = false;
+ update();
+ } break;
+ case NOTIFICATION_MOUSE_ENTER: {
+ if (dropping) {
+ dropping_unfold_timer->start();
+ }
+ } break;
- if (p_what == NOTIFICATION_MOUSE_EXIT) {
- if (dropping) {
- dropping_unfold_timer->stop();
- }
+ case NOTIFICATION_MOUSE_EXIT: {
+ if (dropping) {
+ dropping_unfold_timer->stop();
+ }
+ } break;
}
}
@@ -1363,6 +1360,7 @@ void EditorInspectorSection::setup(const String &p_section, const String &p_labe
if (!foldable && !vbox_added) {
add_child(vbox);
+ move_child(vbox, 0);
vbox_added = true;
}
@@ -1422,7 +1420,7 @@ void EditorInspectorSection::fold() {
}
if (!vbox_added) {
- return; //kinda pointless
+ return;
}
object->editor_set_section_unfold(section, false);
@@ -1459,6 +1457,732 @@ EditorInspectorSection::~EditorInspectorSection() {
////////////////////////////////////////////////
////////////////////////////////////////////////
+int EditorInspectorArray::_get_array_count() {
+ if (mode == MODE_USE_MOVE_ARRAY_ELEMENT_FUNCTION) {
+ List<PropertyInfo> object_property_list;
+ object->get_property_list(&object_property_list);
+ return _extract_properties_as_array(object_property_list).size();
+ } else if (mode == MODE_USE_COUNT_PROPERTY) {
+ bool valid;
+ int count = object->get(count_property, &valid);
+ ERR_FAIL_COND_V_MSG(!valid, 0, vformat("%s is not a valid property to be used as array count.", count_property));
+ return count;
+ }
+ return 0;
+}
+
+void EditorInspectorArray::_add_button_pressed() {
+ _move_element(-1, -1);
+}
+
+void EditorInspectorArray::_first_page_button_pressed() {
+ emit_signal("page_change_request", 0);
+}
+
+void EditorInspectorArray::_prev_page_button_pressed() {
+ emit_signal("page_change_request", MAX(0, page - 1));
+}
+
+void EditorInspectorArray::_page_line_edit_text_submitted(String p_text) {
+ if (p_text.is_valid_int()) {
+ int new_page = p_text.to_int() - 1;
+ new_page = MIN(MAX(0, new_page), max_page);
+ page_line_edit->set_text(Variant(new_page));
+ emit_signal("page_change_request", new_page);
+ } else {
+ page_line_edit->set_text(Variant(page));
+ }
+}
+
+void EditorInspectorArray::_next_page_button_pressed() {
+ emit_signal("page_change_request", MIN(max_page, page + 1));
+}
+
+void EditorInspectorArray::_last_page_button_pressed() {
+ emit_signal("page_change_request", max_page);
+}
+
+void EditorInspectorArray::_rmb_popup_id_pressed(int p_id) {
+ switch (p_id) {
+ case OPTION_MOVE_UP:
+ if (popup_array_index_pressed > 0) {
+ _move_element(popup_array_index_pressed, popup_array_index_pressed - 1);
+ }
+ break;
+ case OPTION_MOVE_DOWN:
+ if (popup_array_index_pressed < count - 1) {
+ _move_element(popup_array_index_pressed, popup_array_index_pressed + 2);
+ }
+ break;
+ case OPTION_NEW_BEFORE:
+ _move_element(-1, popup_array_index_pressed);
+ break;
+ case OPTION_NEW_AFTER:
+ _move_element(-1, popup_array_index_pressed + 1);
+ break;
+ case OPTION_REMOVE:
+ _move_element(popup_array_index_pressed, -1);
+ break;
+ case OPTION_CLEAR_ARRAY:
+ _clear_array();
+ break;
+ case OPTION_RESIZE_ARRAY:
+ new_size = count;
+ new_size_line_edit->set_text(Variant(new_size));
+ resize_dialog->get_ok_button()->set_disabled(true);
+ resize_dialog->popup_centered();
+ new_size_line_edit->grab_focus();
+ new_size_line_edit->select_all();
+ break;
+ default:
+ break;
+ }
+}
+
+void EditorInspectorArray::_control_dropping_draw() {
+ int drop_position = _drop_position();
+
+ if (dropping && drop_position >= 0) {
+ Vector2 from;
+ Vector2 to;
+ if (drop_position < elements_vbox->get_child_count()) {
+ Transform2D xform = Object::cast_to<Control>(elements_vbox->get_child(drop_position))->get_transform();
+ from = xform.xform(Vector2());
+ to = xform.xform(Vector2(elements_vbox->get_size().x, 0));
+ } else {
+ Control *child = Object::cast_to<Control>(elements_vbox->get_child(drop_position - 1));
+ Transform2D xform = child->get_transform();
+ from = xform.xform(Vector2(0, child->get_size().y));
+ to = xform.xform(Vector2(elements_vbox->get_size().x, child->get_size().y));
+ }
+ Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ control_dropping->draw_line(from, to, color, 2);
+ }
+}
+
+void EditorInspectorArray::_vbox_visibility_changed() {
+ control_dropping->set_visible(vbox->is_visible_in_tree());
+}
+
+void EditorInspectorArray::_panel_draw(int p_index) {
+ ERR_FAIL_INDEX(p_index, (int)array_elements.size());
+
+ Ref<StyleBox> style = get_theme_stylebox("Focus", "EditorStyles");
+ if (!style.is_valid()) {
+ return;
+ }
+ if (array_elements[p_index].panel->has_focus()) {
+ array_elements[p_index].panel->draw_style_box(style, Rect2(Vector2(), array_elements[p_index].panel->get_size()));
+ }
+}
+
+void EditorInspectorArray::_panel_gui_input(Ref<InputEvent> p_event, int p_index) {
+ ERR_FAIL_INDEX(p_index, (int)array_elements.size());
+
+ Ref<InputEventKey> key_ref = p_event;
+ if (key_ref.is_valid()) {
+ const InputEventKey &key = **key_ref;
+
+ if (array_elements[p_index].panel->has_focus() && key.is_pressed() && key.get_keycode() == KEY_DELETE) {
+ _move_element(begin_array_index + p_index, -1);
+ array_elements[p_index].panel->accept_event();
+ }
+ }
+
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
+ popup_array_index_pressed = begin_array_index + p_index;
+ rmb_popup->set_item_disabled(OPTION_MOVE_UP, popup_array_index_pressed == 0);
+ rmb_popup->set_item_disabled(OPTION_MOVE_DOWN, popup_array_index_pressed == count - 1);
+ rmb_popup->set_position(mb->get_global_position());
+ rmb_popup->set_size(Vector2());
+ rmb_popup->popup();
+ }
+ }
+}
+
+void EditorInspectorArray::_move_element(int p_element_index, int p_to_pos) {
+ String action_name;
+ if (p_element_index < 0) {
+ action_name = vformat("Add element to property array with prefix %s.", array_element_prefix);
+ } else if (p_to_pos < 0) {
+ action_name = vformat("Remove element %d from property array with prefix %s.", p_element_index, array_element_prefix);
+ } else {
+ action_name = vformat("Move element %d to position %d in property array with prefix %s.", p_element_index, p_to_pos, array_element_prefix);
+ }
+ undo_redo->create_action(action_name);
+ if (mode == MODE_USE_MOVE_ARRAY_ELEMENT_FUNCTION) {
+ // Call the function.
+ Callable move_function = EditorNode::get_singleton()->get_editor_data().get_move_array_element_function(object->get_class_name());
+ if (move_function.is_valid()) {
+ Variant args[] = { (Object *)undo_redo, object, array_element_prefix, p_element_index, p_to_pos };
+ const Variant *args_p[] = { &args[0], &args[1], &args[2], &args[3], &args[4] };
+ Variant return_value;
+ Callable::CallError call_error;
+ move_function.call(args_p, 5, return_value, call_error);
+ } else {
+ WARN_PRINT(vformat("Could not find a function to move arrays elements for class %s. Register a move element function using EditorData::add_move_array_element_function", object->get_class_name()));
+ }
+ } else if (mode == MODE_USE_COUNT_PROPERTY) {
+ ERR_FAIL_COND(p_to_pos < -1 || p_to_pos > count);
+ List<PropertyInfo> object_property_list;
+ object->get_property_list(&object_property_list);
+
+ Array properties_as_array = _extract_properties_as_array(object_property_list);
+ properties_as_array.resize(count);
+
+ // For undoing things
+ undo_redo->add_undo_property(object, count_property, properties_as_array.size());
+ for (int i = 0; i < (int)properties_as_array.size(); i++) {
+ Dictionary d = Dictionary(properties_as_array[i]);
+ Array keys = d.keys();
+ for (int j = 0; j < keys.size(); j++) {
+ String key = keys[j];
+ undo_redo->add_undo_property(object, vformat(key, i), d[key]);
+ }
+ }
+
+ if (p_element_index < 0) {
+ // Add an element.
+ properties_as_array.insert(p_to_pos < 0 ? properties_as_array.size() : p_to_pos, Dictionary());
+ } else if (p_to_pos < 0) {
+ // Delete the element.
+ properties_as_array.remove(p_element_index);
+ } else {
+ // Move the element.
+ properties_as_array.insert(p_to_pos, properties_as_array[p_element_index].duplicate());
+ properties_as_array.remove(p_to_pos < p_element_index ? p_element_index + 1 : p_element_index);
+ }
+
+ // Change the array size then set the properties.
+ undo_redo->add_do_property(object, count_property, properties_as_array.size());
+ for (int i = 0; i < (int)properties_as_array.size(); i++) {
+ Dictionary d = properties_as_array[i];
+ Array keys = d.keys();
+ for (int j = 0; j < keys.size(); j++) {
+ String key = keys[j];
+ undo_redo->add_do_property(object, vformat(key, i), d[key]);
+ }
+ }
+ }
+ undo_redo->commit_action();
+
+ // Handle page change and update counts.
+ if (p_element_index < 0) {
+ int added_index = p_to_pos < 0 ? count : p_to_pos;
+ emit_signal("page_change_request", added_index / page_lenght);
+ count += 1;
+ } else if (p_to_pos < 0) {
+ count -= 1;
+ if (page == max_page && (MAX(0, count - 1) / page_lenght != max_page)) {
+ emit_signal("page_change_request", max_page - 1);
+ }
+ }
+ begin_array_index = page * page_lenght;
+ end_array_index = MIN(count, (page + 1) * page_lenght);
+ max_page = MAX(0, count - 1) / page_lenght;
+}
+
+void EditorInspectorArray::_clear_array() {
+ undo_redo->create_action(vformat("Clear property array with prefix %s.", array_element_prefix));
+ if (mode == MODE_USE_MOVE_ARRAY_ELEMENT_FUNCTION) {
+ for (int i = count - 1; i >= 0; i--) {
+ // Call the function.
+ Callable move_function = EditorNode::get_singleton()->get_editor_data().get_move_array_element_function(object->get_class_name());
+ if (move_function.is_valid()) {
+ Variant args[] = { (Object *)undo_redo, object, array_element_prefix, i, -1 };
+ const Variant *args_p[] = { &args[0], &args[1], &args[2], &args[3], &args[4] };
+ Variant return_value;
+ Callable::CallError call_error;
+ move_function.call(args_p, 5, return_value, call_error);
+ } else {
+ WARN_PRINT(vformat("Could not find a function to move arrays elements for class %s. Register a move element function using EditorData::add_move_array_element_function", object->get_class_name()));
+ }
+ }
+ } else if (mode == MODE_USE_COUNT_PROPERTY) {
+ List<PropertyInfo> object_property_list;
+ object->get_property_list(&object_property_list);
+
+ Array properties_as_array = _extract_properties_as_array(object_property_list);
+ properties_as_array.resize(count);
+
+ // For undoing things
+ undo_redo->add_undo_property(object, count_property, count);
+ for (int i = 0; i < (int)properties_as_array.size(); i++) {
+ Dictionary d = Dictionary(properties_as_array[i]);
+ Array keys = d.keys();
+ for (int j = 0; j < keys.size(); j++) {
+ String key = keys[j];
+ undo_redo->add_undo_property(object, vformat(key, i), d[key]);
+ }
+ }
+
+ // Change the array size then set the properties.
+ undo_redo->add_do_property(object, count_property, 0);
+ }
+ undo_redo->commit_action();
+
+ // Handle page change and update counts.
+ emit_signal("page_change_request", 0);
+ count = 0;
+ begin_array_index = 0;
+ end_array_index = 0;
+ max_page = 0;
+}
+
+void EditorInspectorArray::_resize_array(int p_size) {
+ ERR_FAIL_COND(p_size < 0);
+ if (p_size == count) {
+ return;
+ }
+
+ undo_redo->create_action(vformat("Resize property array with prefix %s.", array_element_prefix));
+ if (p_size > count) {
+ if (mode == MODE_USE_MOVE_ARRAY_ELEMENT_FUNCTION) {
+ for (int i = count; i < p_size; i++) {
+ // Call the function.
+ Callable move_function = EditorNode::get_singleton()->get_editor_data().get_move_array_element_function(object->get_class_name());
+ if (move_function.is_valid()) {
+ Variant args[] = { (Object *)undo_redo, object, array_element_prefix, -1, -1 };
+ const Variant *args_p[] = { &args[0], &args[1], &args[2], &args[3], &args[4] };
+ Variant return_value;
+ Callable::CallError call_error;
+ move_function.call(args_p, 5, return_value, call_error);
+ } else {
+ WARN_PRINT(vformat("Could not find a function to move arrays elements for class %s. Register a move element function using EditorData::add_move_array_element_function", object->get_class_name()));
+ }
+ }
+ } else if (mode == MODE_USE_COUNT_PROPERTY) {
+ undo_redo->add_undo_property(object, count_property, count);
+ undo_redo->add_do_property(object, count_property, p_size);
+ }
+ } else {
+ if (mode == MODE_USE_MOVE_ARRAY_ELEMENT_FUNCTION) {
+ for (int i = count - 1; i > p_size - 1; i--) {
+ // Call the function.
+ Callable move_function = EditorNode::get_singleton()->get_editor_data().get_move_array_element_function(object->get_class_name());
+ if (move_function.is_valid()) {
+ Variant args[] = { (Object *)undo_redo, object, array_element_prefix, i, -1 };
+ const Variant *args_p[] = { &args[0], &args[1], &args[2], &args[3], &args[4] };
+ Variant return_value;
+ Callable::CallError call_error;
+ move_function.call(args_p, 5, return_value, call_error);
+ } else {
+ WARN_PRINT(vformat("Could not find a function to move arrays elements for class %s. Register a move element function using EditorData::add_move_array_element_function", object->get_class_name()));
+ }
+ }
+ } else if (mode == MODE_USE_COUNT_PROPERTY) {
+ List<PropertyInfo> object_property_list;
+ object->get_property_list(&object_property_list);
+
+ Array properties_as_array = _extract_properties_as_array(object_property_list);
+ properties_as_array.resize(count);
+
+ // For undoing things
+ undo_redo->add_undo_property(object, count_property, count);
+ for (int i = count - 1; i > p_size - 1; i--) {
+ Dictionary d = Dictionary(properties_as_array[i]);
+ Array keys = d.keys();
+ for (int j = 0; j < keys.size(); j++) {
+ String key = keys[j];
+ undo_redo->add_undo_property(object, vformat(key, i), d[key]);
+ }
+ }
+
+ // Change the array size then set the properties.
+ undo_redo->add_do_property(object, count_property, p_size);
+ }
+ }
+ undo_redo->commit_action();
+
+ // Handle page change and update counts.
+ emit_signal("page_change_request", 0);
+ /*
+ count = 0;
+ begin_array_index = 0;
+ end_array_index = 0;
+ max_page = 0;
+ */
+}
+
+Array EditorInspectorArray::_extract_properties_as_array(const List<PropertyInfo> &p_list) {
+ Array output;
+
+ for (const PropertyInfo &pi : p_list) {
+ if (pi.name.begins_with(array_element_prefix)) {
+ String str = pi.name.trim_prefix(array_element_prefix);
+
+ int to_char_index = 0;
+ while (to_char_index < str.length()) {
+ if (str[to_char_index] < '0' || str[to_char_index] > '9') {
+ break;
+ }
+ to_char_index++;
+ }
+ if (to_char_index > 0) {
+ int array_index = str.left(to_char_index).to_int();
+ Error error = OK;
+ if (array_index >= output.size()) {
+ error = output.resize(array_index + 1);
+ }
+ if (error == OK) {
+ String format_string = String(array_element_prefix) + "%d" + str.substr(to_char_index);
+ Dictionary dict = output[array_index];
+ dict[format_string] = object->get(pi.name);
+ output[array_index] = dict;
+ } else {
+ WARN_PRINT(vformat("Array element %s has an index too high. Array allocaiton failed.", pi.name));
+ }
+ }
+ }
+ }
+ return output;
+}
+
+int EditorInspectorArray::_drop_position() const {
+ for (int i = 0; i < (int)array_elements.size(); i++) {
+ const ArrayElement &ae = array_elements[i];
+
+ Size2 size = ae.panel->get_size();
+ Vector2 mp = ae.panel->get_local_mouse_position();
+
+ if (Rect2(Vector2(), size).has_point(mp)) {
+ if (mp.y < size.y / 2) {
+ return i;
+ } else {
+ return i + 1;
+ }
+ }
+ }
+ return -1;
+}
+
+void EditorInspectorArray::_new_size_line_edit_text_changed(String p_text) {
+ bool valid = false;
+ ;
+ if (p_text.is_valid_int()) {
+ int val = p_text.to_int();
+ if (val > 0 && val != count) {
+ valid = true;
+ }
+ }
+ resize_dialog->get_ok_button()->set_disabled(!valid);
+}
+
+void EditorInspectorArray::_new_size_line_edit_text_submitted(String p_text) {
+ bool valid = false;
+ ;
+ if (p_text.is_valid_int()) {
+ int val = p_text.to_int();
+ if (val > 0 && val != count) {
+ new_size = val;
+ valid = true;
+ }
+ }
+ if (valid) {
+ resize_dialog->hide();
+ _resize_array(new_size);
+ } else {
+ new_size_line_edit->set_text(Variant(new_size));
+ }
+}
+
+void EditorInspectorArray::_resize_dialog_confirmed() {
+ _new_size_line_edit_text_submitted(new_size_line_edit->get_text());
+}
+
+void EditorInspectorArray::_setup() {
+ // Setup counts.
+ count = _get_array_count();
+ begin_array_index = page * page_lenght;
+ end_array_index = MIN(count, (page + 1) * page_lenght);
+ max_page = MAX(0, count - 1) / page_lenght;
+ array_elements.resize(MAX(0, end_array_index - begin_array_index));
+ if (page < 0 || page > max_page) {
+ WARN_PRINT(vformat("Invalid page number %d", page));
+ page = CLAMP(page, 0, max_page);
+ }
+
+ for (int i = 0; i < (int)array_elements.size(); i++) {
+ ArrayElement &ae = array_elements[i];
+
+ // Panel and its hbox.
+ ae.panel = memnew(PanelContainer);
+ ae.panel->set_focus_mode(FOCUS_ALL);
+ ae.panel->set_mouse_filter(MOUSE_FILTER_PASS);
+ ae.panel->set_drag_forwarding(this);
+ ae.panel->set_meta("index", begin_array_index + i);
+ ae.panel->set_tooltip(vformat(TTR("Element %d: %s%d*"), i, array_element_prefix, i));
+ ae.panel->connect("focus_entered", callable_mp((CanvasItem *)ae.panel, &PanelContainer::update));
+ ae.panel->connect("focus_exited", callable_mp((CanvasItem *)ae.panel, &PanelContainer::update));
+ ae.panel->connect("draw", callable_bind(callable_mp(this, &EditorInspectorArray::_panel_draw), i));
+ ae.panel->connect("gui_input", callable_bind(callable_mp(this, &EditorInspectorArray::_panel_gui_input), i));
+ ae.panel->add_theme_style_override(SNAME("panel"), i % 2 ? odd_style : even_style);
+ elements_vbox->add_child(ae.panel);
+
+ ae.margin = memnew(MarginContainer);
+ ae.margin->set_mouse_filter(MOUSE_FILTER_PASS);
+ if (is_inside_tree()) {
+ Size2 min_size = get_theme_stylebox("Focus", "EditorStyles")->get_minimum_size();
+ ae.margin->add_theme_constant_override("margin_left", min_size.x / 2);
+ ae.margin->add_theme_constant_override("margin_top", min_size.y / 2);
+ ae.margin->add_theme_constant_override("margin_right", min_size.x / 2);
+ ae.margin->add_theme_constant_override("margin_bottom", min_size.y / 2);
+ }
+ ae.panel->add_child(ae.margin);
+
+ ae.hbox = memnew(HBoxContainer);
+ ae.hbox->set_h_size_flags(SIZE_EXPAND_FILL);
+ ae.hbox->set_v_size_flags(SIZE_EXPAND_FILL);
+ ae.margin->add_child(ae.hbox);
+
+ // Move button.
+ ae.move_texture_rect = memnew(TextureRect);
+ ae.move_texture_rect->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
+ if (is_inside_tree()) {
+ ae.move_texture_rect->set_texture(get_theme_icon(SNAME("TripleBar"), SNAME("EditorIcons")));
+ }
+ ae.hbox->add_child(ae.move_texture_rect);
+
+ // Right vbox.
+ ae.vbox = memnew(VBoxContainer);
+ ae.vbox->set_h_size_flags(SIZE_EXPAND_FILL);
+ ae.vbox->set_v_size_flags(SIZE_EXPAND_FILL);
+ ae.hbox->add_child(ae.vbox);
+ }
+
+ // Hide/show the add button.
+ add_button->set_visible(page == max_page);
+
+ if (max_page == 0) {
+ hbox_pagination->hide();
+ } else {
+ // Update buttons.
+ first_page_button->set_disabled(page == 0);
+ prev_page_button->set_disabled(page == 0);
+ next_page_button->set_disabled(page == max_page);
+ last_page_button->set_disabled(page == max_page);
+
+ // Update page number and page count.
+ page_line_edit->set_text(vformat("%d", page + 1));
+ page_count_label->set_text(vformat("/ %d", max_page + 1));
+ }
+}
+
+Variant EditorInspectorArray::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
+ int index = p_from->get_meta("index");
+ Dictionary dict;
+ dict["type"] = "property_array_element";
+ dict["property_array_prefix"] = array_element_prefix;
+ dict["index"] = index;
+
+ return dict;
+}
+
+void EditorInspectorArray::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
+ Dictionary dict = p_data;
+
+ int to_drop = dict["index"];
+ int drop_position = _drop_position();
+ if (drop_position < 0) {
+ return;
+ }
+ _move_element(to_drop, begin_array_index + drop_position);
+}
+
+bool EditorInspectorArray::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
+ // First, update drawing.
+ control_dropping->update();
+
+ if (p_data.get_type() != Variant::DICTIONARY) {
+ return false;
+ }
+ Dictionary dict = p_data;
+ int drop_position = _drop_position();
+ if (!dict.has("type") || dict["type"] != "property_array_element" || String(dict["property_array_prefix"]) != array_element_prefix || drop_position < 0) {
+ return false;
+ }
+
+ // Check in dropping at the given index does indeed move the item.
+ int moved_array_index = (int)dict["index"];
+ int drop_array_index = begin_array_index + drop_position;
+
+ return drop_array_index != moved_array_index && drop_array_index - 1 != moved_array_index;
+}
+
+void EditorInspectorArray::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ Color color = get_theme_color(SNAME("dark_color_1"), SNAME("Editor"));
+ odd_style->set_bg_color(color.lightened(0.15));
+ even_style->set_bg_color(color.darkened(0.15));
+
+ for (int i = 0; i < (int)array_elements.size(); i++) {
+ ArrayElement &ae = array_elements[i];
+ ae.move_texture_rect->set_texture(get_theme_icon(SNAME("TripleBar"), SNAME("EditorIcons")));
+
+ Size2 min_size = get_theme_stylebox("Focus", "EditorStyles")->get_minimum_size();
+ ae.margin->add_theme_constant_override("margin_left", min_size.x / 2);
+ ae.margin->add_theme_constant_override("margin_top", min_size.y / 2);
+ ae.margin->add_theme_constant_override("margin_right", min_size.x / 2);
+ ae.margin->add_theme_constant_override("margin_bottom", min_size.y / 2);
+ }
+
+ add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ first_page_button->set_icon(get_theme_icon(SNAME("PageFirst"), SNAME("EditorIcons")));
+ prev_page_button->set_icon(get_theme_icon(SNAME("PagePrevious"), SNAME("EditorIcons")));
+ next_page_button->set_icon(get_theme_icon(SNAME("PageNext"), SNAME("EditorIcons")));
+ last_page_button->set_icon(get_theme_icon(SNAME("PageLast"), SNAME("EditorIcons")));
+ minimum_size_changed();
+ } break;
+ case NOTIFICATION_DRAG_BEGIN: {
+ Dictionary dict = get_viewport()->gui_get_drag_data();
+ if (dict.has("type") && dict["type"] == "property_array_element" && String(dict["property_array_prefix"]) == array_element_prefix) {
+ dropping = true;
+ control_dropping->update();
+ }
+ } break;
+ case NOTIFICATION_DRAG_END: {
+ if (dropping) {
+ dropping = false;
+ control_dropping->update();
+ }
+ } break;
+ }
+}
+
+void EditorInspectorArray::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_get_drag_data_fw"), &EditorInspectorArray::get_drag_data_fw);
+ ClassDB::bind_method(D_METHOD("_can_drop_data_fw"), &EditorInspectorArray::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("_drop_data_fw"), &EditorInspectorArray::drop_data_fw);
+
+ ADD_SIGNAL(MethodInfo("page_change_request"));
+}
+
+void EditorInspectorArray::set_undo_redo(UndoRedo *p_undo_redo) {
+ undo_redo = p_undo_redo;
+}
+
+void EditorInspectorArray::setup_with_move_element_function(Object *p_object, String p_label, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable) {
+ count_property = "";
+ mode = MODE_USE_MOVE_ARRAY_ELEMENT_FUNCTION;
+ array_element_prefix = p_array_element_prefix;
+ page = p_page;
+
+ EditorInspectorSection::setup(String(p_array_element_prefix) + "_array", p_label, p_object, p_bg_color, p_foldable);
+
+ _setup();
+}
+
+void EditorInspectorArray::setup_with_count_property(Object *p_object, String p_label, const StringName &p_count_property, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable) {
+ count_property = p_count_property;
+ mode = MODE_USE_COUNT_PROPERTY;
+ array_element_prefix = p_array_element_prefix;
+ page = p_page;
+
+ EditorInspectorSection::setup(String(count_property) + "_array", p_label, p_object, p_bg_color, p_foldable);
+
+ _setup();
+}
+
+VBoxContainer *EditorInspectorArray::get_vbox(int p_index) {
+ if (p_index >= begin_array_index && p_index < end_array_index) {
+ return array_elements[p_index - begin_array_index].vbox;
+ } else if (p_index < 0) {
+ return vbox;
+ } else {
+ return nullptr;
+ }
+}
+
+EditorInspectorArray::EditorInspectorArray() {
+ set_mouse_filter(Control::MOUSE_FILTER_STOP);
+
+ odd_style.instantiate();
+ even_style.instantiate();
+
+ rmb_popup = memnew(PopupMenu);
+ rmb_popup->add_item(TTR("Move Up"), OPTION_MOVE_UP);
+ rmb_popup->add_item(TTR("Move Down"), OPTION_MOVE_DOWN);
+ rmb_popup->add_separator();
+ rmb_popup->add_item(TTR("Insert New Before"), OPTION_NEW_BEFORE);
+ rmb_popup->add_item(TTR("Insert New After"), OPTION_NEW_AFTER);
+ rmb_popup->add_separator();
+ rmb_popup->add_item(TTR("Remove"), OPTION_REMOVE);
+ rmb_popup->add_separator();
+ rmb_popup->add_item(TTR("Clear Array"), OPTION_CLEAR_ARRAY);
+ rmb_popup->add_item(TTR("Resize Array..."), OPTION_RESIZE_ARRAY);
+ rmb_popup->connect("id_pressed", callable_mp(this, &EditorInspectorArray::_rmb_popup_id_pressed));
+ add_child(rmb_popup);
+
+ elements_vbox = memnew(VBoxContainer);
+ elements_vbox->add_theme_constant_override("separation", 0);
+ vbox->add_child(elements_vbox);
+
+ add_button = memnew(Button);
+ add_button->set_text(TTR("Add Element"));
+ add_button->set_text_align(Button::ALIGN_CENTER);
+ add_button->connect("pressed", callable_mp(this, &EditorInspectorArray::_add_button_pressed));
+ vbox->add_child(add_button);
+
+ hbox_pagination = memnew(HBoxContainer);
+ hbox_pagination->set_h_size_flags(SIZE_EXPAND_FILL);
+ hbox_pagination->set_alignment(HBoxContainer::ALIGN_CENTER);
+ vbox->add_child(hbox_pagination);
+
+ first_page_button = memnew(Button);
+ first_page_button->set_flat(true);
+ first_page_button->connect("pressed", callable_mp(this, &EditorInspectorArray::_first_page_button_pressed));
+ hbox_pagination->add_child(first_page_button);
+
+ prev_page_button = memnew(Button);
+ prev_page_button->set_flat(true);
+ prev_page_button->connect("pressed", callable_mp(this, &EditorInspectorArray::_prev_page_button_pressed));
+ hbox_pagination->add_child(prev_page_button);
+
+ page_line_edit = memnew(LineEdit);
+ page_line_edit->connect("text_submitted", callable_mp(this, &EditorInspectorArray::_page_line_edit_text_submitted));
+ page_line_edit->add_theme_constant_override("minimum_character_width", 2);
+ hbox_pagination->add_child(page_line_edit);
+
+ page_count_label = memnew(Label);
+ hbox_pagination->add_child(page_count_label);
+ next_page_button = memnew(Button);
+ next_page_button->set_flat(true);
+ next_page_button->connect("pressed", callable_mp(this, &EditorInspectorArray::_next_page_button_pressed));
+ hbox_pagination->add_child(next_page_button);
+
+ last_page_button = memnew(Button);
+ last_page_button->set_flat(true);
+ last_page_button->connect("pressed", callable_mp(this, &EditorInspectorArray::_last_page_button_pressed));
+ hbox_pagination->add_child(last_page_button);
+
+ control_dropping = memnew(Control);
+ control_dropping->connect("draw", callable_mp(this, &EditorInspectorArray::_control_dropping_draw));
+ control_dropping->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
+ add_child(control_dropping);
+
+ resize_dialog = memnew(AcceptDialog);
+ resize_dialog->set_title(TTRC("Resize Array"));
+ resize_dialog->add_cancel_button();
+ resize_dialog->connect("confirmed", callable_mp(this, &EditorInspectorArray::_resize_dialog_confirmed));
+ add_child(resize_dialog);
+
+ VBoxContainer *resize_dialog_vbox = memnew(VBoxContainer);
+ resize_dialog->add_child(resize_dialog_vbox);
+
+ new_size_line_edit = memnew(LineEdit);
+ new_size_line_edit->connect("text_changed", callable_mp(this, &EditorInspectorArray::_new_size_line_edit_text_changed));
+ new_size_line_edit->connect("text_submitted", callable_mp(this, &EditorInspectorArray::_new_size_line_edit_text_submitted));
+ resize_dialog_vbox->add_margin_child(TTRC("New Size:"), new_size_line_edit);
+
+ vbox->connect("visibility_changed", callable_mp(this, &EditorInspectorArray::_vbox_visibility_changed));
+}
+
+////////////////////////////////////////////////
+////////////////////////////////////////////////
Ref<EditorInspectorPlugin> EditorInspector::inspector_plugins[MAX_PLUGINS];
int EditorInspector::inspector_plugin_count = 0;
@@ -1644,18 +2368,17 @@ void EditorInspector::update_tree() {
valid_plugins.push_back(inspector_plugins[i]);
}
+ // Decide if properties should be drawn in red.
bool draw_red = false;
-
if (is_inside_tree()) {
Node *nod = Object::cast_to<Node>(object);
Node *es = EditorNode::get_singleton()->get_edited_scene();
if (nod && es != nod && nod->get_owner() != es) {
+ // Draw in red edited nodes that are not in the currently edited scene.
draw_red = true;
}
}
- // TreeItem *current_category = nullptr;
-
String filter = search_box ? search_box->get_text() : "";
String group;
String group_base;
@@ -1667,30 +2390,30 @@ void EditorInspector::update_tree() {
object->get_property_list(&plist, true);
_update_script_class_properties(*object, plist);
- HashMap<String, VBoxContainer *> item_path;
- Map<VBoxContainer *, EditorInspectorSection *> section_map;
-
- item_path[""] = main_vbox;
+ Map<VBoxContainer *, HashMap<String, VBoxContainer *>> vbox_per_path;
+ Map<String, EditorInspectorArray *> editor_inspector_array_per_prefix;
Color sscolor = get_theme_color(SNAME("prop_subsection"), SNAME("Editor"));
+ // Get the lists of editors to add the beginning.
for (Ref<EditorInspectorPlugin> &ped : valid_plugins) {
ped->parse_begin(object);
_parse_added_editors(main_vbox, ped);
}
- for (List<PropertyInfo>::Element *I = plist.front(); I; I = I->next()) {
- PropertyInfo &p = I->get();
-
- //make sure the property can be edited
+ // Get the lists of editors for properties.
+ for (List<PropertyInfo>::Element *E_property = plist.front(); E_property; E_property = E_property->next()) {
+ PropertyInfo &p = E_property->get();
if (p.usage & PROPERTY_USAGE_SUBGROUP) {
+ // Setup a property sub-group.
subgroup = p.name;
subgroup_base = p.hint_string;
continue;
} else if (p.usage & PROPERTY_USAGE_GROUP) {
+ // Setup a property group.
group = p.name;
group_base = p.hint_string;
subgroup = "";
@@ -1699,6 +2422,7 @@ void EditorInspector::update_tree() {
continue;
} else if (p.usage & PROPERTY_USAGE_CATEGORY) {
+ // Setup a property category.
group = "";
group_base = "";
subgroup = "";
@@ -1708,9 +2432,9 @@ void EditorInspector::update_tree() {
continue;
}
- List<PropertyInfo>::Element *N = I->next();
+ // Iterate over remaining properties. If no properties in category, skip the category.
+ List<PropertyInfo>::Element *N = E_property->next();
bool valid = true;
- //if no properties in category, skip
while (N) {
if (N->get().usage & PROPERTY_USAGE_EDITOR && (!restrict_to_basic || (N->get().usage & PROPERTY_USAGE_EDITOR_BASIC_SETTING))) {
break;
@@ -1722,28 +2446,32 @@ void EditorInspector::update_tree() {
N = N->next();
}
if (!valid) {
- continue; //empty, ignore
+ continue; // Empty, ignore it.
}
+ // Create an EditorInspectorCategory and add it to the inspector.
EditorInspectorCategory *category = memnew(EditorInspectorCategory);
main_vbox->add_child(category);
category_vbox = nullptr; //reset
String type = p.name;
+
+ // Set the category icon.
if (!ClassDB::class_exists(type) && !ScriptServer::is_global_class(type) && p.hint_string.length() && FileAccess::exists(p.hint_string)) {
- Ref<Script> s = ResourceLoader::load(p.hint_string, "Script");
+ // If we have a category inside a script, search for the first script with a valid icon.
+ Ref<Script> script = ResourceLoader::load(p.hint_string, "Script");
String base_type;
- if (s.is_valid()) {
- base_type = s->get_instance_base_type();
+ if (script.is_valid()) {
+ base_type = script->get_instance_base_type();
}
- while (s.is_valid()) {
- StringName name = EditorNode::get_editor_data().script_class_get_name(s->get_path());
+ while (script.is_valid()) {
+ StringName name = EditorNode::get_editor_data().script_class_get_name(script->get_path());
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name);
if (name != StringName() && icon_path.length()) {
category->icon = ResourceLoader::load(icon_path, "Texture");
break;
}
- s = s->get_base_script();
+ script = script->get_base_script();
}
if (category->icon.is_null() && has_theme_icon(base_type, SNAME("EditorIcons"))) {
category->icon = get_theme_icon(base_type, SNAME("EditorIcons"));
@@ -1754,9 +2482,12 @@ void EditorInspector::update_tree() {
category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object");
}
}
+
+ // Set the category label.
category->label = type;
if (use_doc_hints) {
+ // Sets the category tooltip to show documentation.
StringName type2 = p.name;
if (!class_descr_cache.has(type2)) {
String descr;
@@ -1771,6 +2502,7 @@ void EditorInspector::update_tree() {
category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2]));
}
+ // Add editors at the start of a category.
for (Ref<EditorInspectorPlugin> &ped : valid_plugins) {
ped->parse_category(object, p.name);
_parse_added_editors(main_vbox, ped);
@@ -1779,134 +2511,215 @@ void EditorInspector::update_tree() {
continue;
} else if (!(p.usage & PROPERTY_USAGE_EDITOR) || _is_property_disabled_by_feature_profile(p.name) || (restrict_to_basic && !(p.usage & PROPERTY_USAGE_EDITOR_BASIC_SETTING))) {
+ // Ignore properties that are not supposed to be in the inspector.
continue;
}
if (p.name == "script") {
- category_vbox = nullptr; // script should go into its own category
+ // Script should go into its own category.
+ category_vbox = nullptr;
}
if (p.usage & PROPERTY_USAGE_HIGH_END_GFX && RS::get_singleton()->is_low_end()) {
- continue; //do not show this property in low end gfx
+ // Do not show this property in low end gfx.
+ continue;
}
if (p.name == "script" && (hide_script || bool(object->call("_hide_script_from_inspector")))) {
+ // Hide script variables from inspector if required.
continue;
}
- String basename = p.name;
+ // Get the path for property.
+ String path = p.name;
- if (subgroup != "") {
- if (subgroup_base != "") {
- if (basename.begins_with(subgroup_base)) {
- basename = basename.replace_first(subgroup_base, "");
- } else if (subgroup_base.begins_with(basename)) {
- //keep it, this is used pretty often
- } else {
- subgroup = ""; //no longer using subgroup base, clear
+ // First check if we have an array that fits the prefix.
+ String array_prefix = "";
+ int array_index = -1;
+ for (Map<String, EditorInspectorArray *>::Element *E = editor_inspector_array_per_prefix.front(); E; E = E->next()) {
+ if (p.name.begins_with(E->key()) && E->key().length() > array_prefix.length()) {
+ array_prefix = E->key();
+ }
+ }
+
+ if (!array_prefix.is_empty()) {
+ // If we have an array element, find the according index in array.
+ String str = p.name.trim_prefix(array_prefix);
+ int to_char_index = 0;
+ while (to_char_index < str.length()) {
+ if (str[to_char_index] < '0' || str[to_char_index] > '9') {
+ break;
}
+ to_char_index++;
+ }
+ if (to_char_index > 0) {
+ array_index = str.left(to_char_index).to_int();
+ } else {
+ array_prefix = "";
}
}
- if (group != "") {
- if (group_base != "" && subgroup == "") {
- if (basename.begins_with(group_base)) {
- basename = basename.replace_first(group_base, "");
- } else if (group_base.begins_with(basename)) {
- //keep it, this is used pretty often
+
+ if (!array_prefix.is_empty()) {
+ path = path.trim_prefix(array_prefix);
+ int char_index = path.find("/");
+ if (char_index >= 0) {
+ path = path.right(-char_index - 1);
+ } else {
+ path = vformat(TTR("Element %s"), array_index);
+ }
+ } else {
+ // Check if we exit or not a subgroup. If there is a prefix, remove it from the property label string.
+ if (subgroup != "" && subgroup_base != "") {
+ if (path.begins_with(subgroup_base)) {
+ path = path.trim_prefix(subgroup_base);
+ } else if (subgroup_base.begins_with(path)) {
+ // Keep it, this is used pretty often.
+ } else {
+ subgroup = ""; // The prefix changed, we are no longer in the subgroup.
+ }
+ }
+
+ // Check if we exit or not a group. If there is a prefix, remove it from the property label string.
+ if (group != "" && group_base != "" && subgroup == "") {
+ if (path.begins_with(group_base)) {
+ path = path.trim_prefix(group_base);
+ } else if (group_base.begins_with(path)) {
+ // Keep it, this is used pretty often.
} else {
- group = ""; //no longer using group base, clear
+ group = ""; // The prefix changed, we are no longer in the group.
subgroup = "";
}
}
- }
- if (subgroup != "") {
- basename = subgroup + "/" + basename;
- }
- if (group != "") {
- basename = group + "/" + basename;
- }
- String name = (basename.find("/") != -1) ? basename.substr(basename.rfind("/") + 1) : basename;
+ // Add the group and subgroup to the path.
+ if (subgroup != "") {
+ path = subgroup + "/" + path;
+ }
+ if (group != "") {
+ path = group + "/" + path;
+ }
+ }
+ // Get the property label's string.
+ String property_label_string = (path.find("/") != -1) ? path.substr(path.rfind("/") + 1) : path;
if (capitalize_paths) {
- int dot = name.find(".");
+ // Capitalize paths.
+ int dot = property_label_string.find(".");
if (dot != -1) {
- String ov = name.substr(dot);
- name = name.substr(0, dot);
- name = name.capitalize();
- name += ov;
-
+ String ov = property_label_string.substr(dot);
+ property_label_string = property_label_string.substr(0, dot);
+ property_label_string = property_label_string.capitalize();
+ property_label_string += ov;
} else {
- name = name.capitalize();
+ property_label_string = property_label_string.capitalize();
}
}
- String path;
- {
- int idx = basename.rfind("/");
- if (idx > -1) {
- path = basename.left(idx);
- }
+ // Remove the property from the path.
+ int idx = path.rfind("/");
+ if (idx > -1) {
+ path = path.left(idx);
+ } else {
+ path = "";
}
+ // Ignore properties that do not fit the filter.
if (use_filter && filter != "") {
- String cat = path;
-
- if (capitalize_paths) {
- cat = cat.capitalize();
- }
-
- if (!filter.is_subsequence_ofi(cat) && !filter.is_subsequence_ofi(name) && property_prefix.to_lower().find(filter.to_lower()) == -1) {
+ if (!filter.is_subsequence_ofi(path) && !filter.is_subsequence_ofi(property_label_string) && property_prefix.to_lower().find(filter.to_lower()) == -1) {
continue;
}
}
+ // Recreate the category vbox if it was reset.
if (category_vbox == nullptr) {
category_vbox = memnew(VBoxContainer);
main_vbox->add_child(category_vbox);
}
- VBoxContainer *current_vbox = main_vbox;
+ // Find the correct section/vbox to add the property editor to.
+ VBoxContainer *root_vbox = array_prefix.is_empty() ? main_vbox : editor_inspector_array_per_prefix[array_prefix]->get_vbox(array_index);
+ if (!root_vbox) {
+ continue;
+ }
- {
- String acc_path = "";
- int level = 1;
- for (int i = 0; i < path.get_slice_count("/"); i++) {
- String path_name = path.get_slice("/", i);
- if (i > 0) {
- acc_path += "/";
- }
- acc_path += path_name;
- if (!item_path.has(acc_path)) {
- EditorInspectorSection *section = memnew(EditorInspectorSection);
- current_vbox->add_child(section);
- sections.push_back(section);
-
- if (capitalize_paths) {
- path_name = path_name.capitalize();
- }
+ if (!vbox_per_path.has(root_vbox)) {
+ vbox_per_path[root_vbox] = HashMap<String, VBoxContainer *>();
+ vbox_per_path[root_vbox][""] = root_vbox;
+ }
+
+ VBoxContainer *current_vbox = root_vbox;
+ String acc_path = "";
+ int level = 1;
+
+ Vector<String> components = path.split("/");
+ for (int i = 0; i < components.size(); i++) {
+ String component = components[i];
+ acc_path += (i > 0) ? "/" + component : component;
- Color c = sscolor;
- c.a /= level;
- section->setup(acc_path, path_name, object, c, use_folding);
+ if (!vbox_per_path[root_vbox].has(acc_path)) {
+ // If the section does not exists, create it.
+ EditorInspectorSection *section = memnew(EditorInspectorSection);
+ current_vbox->add_child(section);
+ sections.push_back(section);
- VBoxContainer *vb = section->get_vbox();
- item_path[acc_path] = vb;
- section_map[vb] = section;
+ if (capitalize_paths) {
+ component = component.capitalize();
}
- current_vbox = item_path[acc_path];
- level = (MIN(level + 1, 4));
- }
- if (current_vbox == main_vbox) {
- //do not add directly to the main vbox, given it has no spacing
- if (category_vbox == nullptr) {
- category_vbox = memnew(VBoxContainer);
+ Color c = sscolor;
+ c.a /= level;
+ section->setup(acc_path, component, object, c, use_folding);
+
+ vbox_per_path[root_vbox][acc_path] = section->get_vbox();
+ }
+
+ current_vbox = vbox_per_path[root_vbox][acc_path];
+ level = (MIN(level + 1, 4));
+ }
+
+ // If we did not find a section to add the property to, add it to the category vbox instead (the category vbox handles margins correctly).
+ if (current_vbox == main_vbox) {
+ current_vbox = category_vbox;
+ }
+
+ // Check if the property is an array counter, if so create a dedicated array editor for the array.
+ if (p.usage & PROPERTY_USAGE_ARRAY) {
+ EditorInspectorArray *editor_inspector_array = nullptr;
+ StringName array_element_prefix;
+ Color c = sscolor;
+ c.a /= level;
+ if (p.type == Variant::NIL) {
+ // Setup the array to use a method to create/move/delete elements.
+ array_element_prefix = p.class_name;
+ editor_inspector_array = memnew(EditorInspectorArray);
+
+ String array_label = (path.find("/") != -1) ? path.substr(path.rfind("/") + 1) : path;
+ array_label = property_label_string.capitalize();
+ int page = per_array_page.has(array_element_prefix) ? per_array_page[array_element_prefix] : 0;
+ editor_inspector_array->setup_with_move_element_function(object, array_label, array_element_prefix, page, c, use_folding);
+ editor_inspector_array->connect("page_change_request", callable_mp(this, &EditorInspector::_page_change_request), varray(array_element_prefix));
+ editor_inspector_array->set_undo_redo(undo_redo);
+ } else if (p.type == Variant::INT) {
+ // Setup the array to use the count property and built-in functions to create/move/delete elements.
+ Vector<String> class_name_components = String(p.class_name).split(",");
+ if (class_name_components.size() == 2) {
+ array_element_prefix = class_name_components[1];
+ editor_inspector_array = memnew(EditorInspectorArray);
+ int page = per_array_page.has(array_element_prefix) ? per_array_page[array_element_prefix] : 0;
+ editor_inspector_array->setup_with_count_property(object, class_name_components[0], p.name, array_element_prefix, page, c, use_folding);
+ editor_inspector_array->connect("page_change_request", callable_mp(this, &EditorInspector::_page_change_request), varray(array_element_prefix));
+ editor_inspector_array->set_undo_redo(undo_redo);
}
- current_vbox = category_vbox;
}
+
+ if (editor_inspector_array) {
+ current_vbox->add_child(editor_inspector_array);
+ editor_inspector_array_per_prefix[array_element_prefix] = editor_inspector_array;
+ }
+ continue;
}
+ // Checkable and checked properties.
bool checkable = false;
bool checked = false;
if (p.usage & PROPERTY_USAGE_CHECKABLE) {
@@ -1916,6 +2729,7 @@ void EditorInspector::update_tree() {
bool property_read_only = (p.usage & PROPERTY_USAGE_READ_ONLY) || read_only;
+ // Mark properties that would require an editor restart (mostly when editing editor settings).
if (p.usage & PROPERTY_USAGE_RESTART_IF_CHANGED) {
restart_request_props.insert(p.name);
}
@@ -1923,14 +2737,19 @@ void EditorInspector::update_tree() {
String doc_hint;
if (use_doc_hints) {
+ // Build the doc hint, to use as tooltip.
+
+ // Get the class name.
StringName classname = object->get_class_name();
if (object_class != String()) {
classname = object_class;
}
+
StringName propname = property_prefix + p.name;
String descr;
bool found = false;
+ // Search for the property description in the cache.
Map<StringName, Map<StringName, String>>::Element *E = descr_cache.find(classname);
if (E) {
Map<StringName, String>::Element *F = E->get().find(propname);
@@ -1941,6 +2760,7 @@ void EditorInspector::update_tree() {
}
if (!found) {
+ // Build the property description String and add it to the cache.
DocTools *dd = EditorHelp::get_doc_data();
Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(classname);
while (F && descr == String()) {
@@ -1973,17 +2793,18 @@ void EditorInspector::update_tree() {
doc_hint = descr;
}
+ // Seach for the inspector plugin that will handle the properties. Then add the correct property editor to it.
for (Ref<EditorInspectorPlugin> &ped : valid_plugins) {
bool exclusive = ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage, wide_editors);
- List<EditorInspectorPlugin::AddedEditor> editors = ped->added_editors; //make a copy, since plugins may be used again in a sub-inspector
+ List<EditorInspectorPlugin::AddedEditor> editors = ped->added_editors; // Make a copy, since plugins may be used again in a sub-inspector.
ped->added_editors.clear();
for (const EditorInspectorPlugin::AddedEditor &F : editors) {
EditorProperty *ep = Object::cast_to<EditorProperty>(F.property_editor);
if (ep) {
- //set all this before the control gets the ENTER_TREE notification
+ // Set all this before the control gets the ENTER_TREE notification.
ep->object = object;
if (F.properties.size()) {
@@ -1998,7 +2819,7 @@ void EditorInspector::update_tree() {
ep->set_label(F.label);
} else {
// Use the existing one.
- ep->set_label(name);
+ ep->set_label(property_label_string);
}
for (int i = 0; i < F.properties.size(); i++) {
String prop = F.properties[i];
@@ -2021,10 +2842,9 @@ void EditorInspector::update_tree() {
current_vbox->add_child(F.property_editor);
if (ep) {
- ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed));
- if (p.usage & PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED) {
- ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed_update_all), varray(), CONNECT_DEFERRED);
- }
+ // Eventually, set other properties/signals after the property editor got added to the tree.
+ bool update_all = (p.usage & PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED);
+ ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed), varray(update_all));
ep->connect("property_keyed", callable_mp(this, &EditorInspector::_property_keyed));
ep->connect("property_deleted", callable_mp(this, &EditorInspector::_property_deleted), varray(), CONNECT_DEFERRED);
ep->connect("property_keyed_with_value", callable_mp(this, &EditorInspector::_property_keyed_with_value));
@@ -2049,17 +2869,17 @@ void EditorInspector::update_tree() {
}
if (exclusive) {
+ // If we know the plugin is exclusive, we don't need to go through other plugins.
break;
}
}
}
+ // Get the lists of to add at the end.
for (Ref<EditorInspectorPlugin> &ped : valid_plugins) {
ped->parse_end();
_parse_added_editors(main_vbox, ped);
}
-
- //see if this property exists and should be kept
}
void EditorInspector::update_property(const String &p_prop) {
@@ -2098,6 +2918,7 @@ void EditorInspector::edit(Object *p_object) {
_clear();
object->disconnect("property_list_changed", callable_mp(this, &EditorInspector::_changed_callback));
}
+ per_array_page.clear();
object = p_object;
@@ -2243,6 +3064,15 @@ void EditorInspector::set_use_deletable_properties(bool p_enabled) {
deletable_properties = p_enabled;
}
+void EditorInspector::_page_change_request(int p_new_page, const StringName &p_array_prefix) {
+ int prev_page = per_array_page.has(p_array_prefix) ? per_array_page[p_array_prefix] : 0;
+ int new_page = MAX(0, p_new_page);
+ if (new_page != prev_page) {
+ per_array_page[p_array_prefix] = new_page;
+ update_tree_pending = true;
+ }
+}
+
void EditorInspector::_edit_request_change(Object *p_object, const String &p_property) {
if (object != p_object) { //may be undoing/redoing for a non edited object, so ignore
return;
@@ -2343,14 +3173,14 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo
}
}
-void EditorInspector::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) {
+void EditorInspector::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing, bool p_update_all) {
// The "changing" variable must be true for properties that trigger events as typing occurs,
// like "text_changed" signal. E.g. text property of Label, Button, RichTextLabel, etc.
if (p_changing) {
this->changing++;
}
- _edit_set(p_path, p_value, false, p_name);
+ _edit_set(p_path, p_value, p_update_all, p_name);
if (p_changing) {
this->changing--;
@@ -2361,11 +3191,7 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v
}
}
-void EditorInspector::_property_changed_update_all(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) {
- update_tree();
-}
-
-void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array p_values) {
+void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array p_values, bool p_changing) {
ERR_FAIL_COND(p_paths.size() == 0 || p_values.size() == 0);
ERR_FAIL_COND(p_paths.size() != p_values.size());
String names;
@@ -2382,9 +3208,13 @@ void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array
emit_signal(SNAME("restart_requested"));
}
}
- changing++;
+ if (p_changing) {
+ changing++;
+ }
undo_redo->commit_action();
- changing--;
+ if (p_changing) {
+ changing--;
+ }
}
void EditorInspector::_property_keyed(const String &p_path, bool p_advance) {
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index b5d70d5454..5992c23f8c 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -32,8 +32,12 @@
#define EDITOR_INSPECTOR_H
#include "scene/gui/box_container.h"
+#include "scene/gui/button.h"
+#include "scene/gui/dialogs.h"
#include "scene/gui/line_edit.h"
+#include "scene/gui/panel_container.h"
#include "scene/gui/scroll_container.h"
+#include "scene/gui/texture_rect.h"
class UndoRedo;
@@ -251,9 +255,7 @@ class EditorInspectorSection : public Container {
String label;
String section;
- Object *object;
- VBoxContainer *vbox;
- bool vbox_added; //optimization
+ bool vbox_added; // Optimization.
Color bg_color;
bool foldable;
@@ -263,6 +265,9 @@ class EditorInspectorSection : public Container {
void _test_unfold();
protected:
+ Object *object;
+ VBoxContainer *vbox;
+
void _notification(int p_what);
static void _bind_methods();
virtual void gui_input(const Ref<InputEvent> &p_event) override;
@@ -281,6 +286,118 @@ public:
~EditorInspectorSection();
};
+class EditorInspectorArray : public EditorInspectorSection {
+ GDCLASS(EditorInspectorArray, EditorInspectorSection);
+
+ UndoRedo *undo_redo;
+
+ enum Mode {
+ MODE_NONE,
+ MODE_USE_COUNT_PROPERTY,
+ MODE_USE_MOVE_ARRAY_ELEMENT_FUNCTION,
+ } mode;
+ StringName count_property;
+ StringName array_element_prefix;
+
+ int count = 0;
+
+ VBoxContainer *elements_vbox;
+
+ Control *control_dropping;
+ bool dropping = false;
+
+ Button *add_button;
+
+ AcceptDialog *resize_dialog;
+ int new_size = 0;
+ LineEdit *new_size_line_edit;
+
+ // Pagination
+ int page_lenght = 5;
+ int page = 0;
+ int max_page = 0;
+ int begin_array_index = 0;
+ int end_array_index = 0;
+ HBoxContainer *hbox_pagination;
+ Button *first_page_button;
+ Button *prev_page_button;
+ LineEdit *page_line_edit;
+ Label *page_count_label;
+ Button *next_page_button;
+ Button *last_page_button;
+
+ enum MenuOptions {
+ OPTION_MOVE_UP = 0,
+ OPTION_MOVE_DOWN,
+ OPTION_NEW_BEFORE,
+ OPTION_NEW_AFTER,
+ OPTION_REMOVE,
+ OPTION_CLEAR_ARRAY,
+ OPTION_RESIZE_ARRAY,
+ };
+ int popup_array_index_pressed = -1;
+ PopupMenu *rmb_popup;
+
+ struct ArrayElement {
+ PanelContainer *panel;
+ MarginContainer *margin;
+ HBoxContainer *hbox;
+ TextureRect *move_texture_rect;
+ VBoxContainer *vbox;
+ };
+ LocalVector<ArrayElement> array_elements;
+
+ Ref<StyleBoxFlat> odd_style;
+ Ref<StyleBoxFlat> even_style;
+
+ int _get_array_count();
+ void _add_button_pressed();
+
+ void _first_page_button_pressed();
+ void _prev_page_button_pressed();
+ void _page_line_edit_text_submitted(String p_text);
+ void _next_page_button_pressed();
+ void _last_page_button_pressed();
+
+ void _rmb_popup_id_pressed(int p_id);
+
+ void _control_dropping_draw();
+
+ void _vbox_visibility_changed();
+
+ void _panel_draw(int p_index);
+ void _panel_gui_input(Ref<InputEvent> p_event, int p_index);
+ void _move_element(int p_element_index, int p_to_pos);
+ void _clear_array();
+ void _resize_array(int p_size);
+ Array _extract_properties_as_array(const List<PropertyInfo> &p_list);
+ int _drop_position() const;
+
+ void _new_size_line_edit_text_changed(String p_text);
+ void _new_size_line_edit_text_submitted(String p_text);
+ void _resize_dialog_confirmed();
+
+ void _update_elements_visibility();
+ void _setup();
+
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ void set_undo_redo(UndoRedo *p_undo_redo);
+
+ void setup_with_move_element_function(Object *p_object, String p_label, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable);
+ void setup_with_count_property(Object *p_object, String p_label, const StringName &p_count_property, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable);
+ VBoxContainer *get_vbox(int p_index);
+
+ EditorInspectorArray();
+};
+
class EditorInspector : public ScrollContainer {
GDCLASS(EditorInspector, ScrollContainer);
@@ -340,9 +457,8 @@ class EditorInspector : public ScrollContainer {
void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field);
- void _property_changed(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false);
- void _property_changed_update_all(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false);
- void _multiple_properties_changed(Vector<String> p_paths, Array p_values);
+ void _property_changed(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false, bool p_update_all = false);
+ void _multiple_properties_changed(Vector<String> p_paths, Array p_values, bool p_changing = false);
void _property_keyed(const String &p_path, bool p_advance);
void _property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance);
void _property_deleted(const String &p_path);
@@ -355,6 +471,9 @@ class EditorInspector : public ScrollContainer {
void _node_removed(Node *p_node);
+ Map<StringName, int> per_array_page;
+ void _page_change_request(int p_new_page, const StringName &p_array_prefix);
+
void _changed_callback();
void _edit_request_change(Object *p_object, const String &p_prop);
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index daee61c2dd..5dd5c050e0 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -2158,6 +2158,14 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da
return true;
}
+ if (drag_data.has("type") && String(drag_data["type"]) == "nodes") {
+ // Save branch as scene.
+ String to_dir;
+ bool favorite;
+ _get_drag_target_folder(to_dir, favorite, p_point, p_from);
+ return !favorite && Array(drag_data["nodes"]).size() == 1;
+ }
+
return false;
}
@@ -2296,6 +2304,13 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
_update_tree(_compute_uncollapsed_paths());
}
}
+
+ if (drag_data.has("type") && String(drag_data["type"]) == "nodes") {
+ String to_dir;
+ bool favorite;
+ _get_drag_target_folder(to_dir, favorite, p_point, p_from);
+ EditorNode::get_singleton()->get_scene_tree_dock()->save_branch_to_file(to_dir);
+ }
}
void FileSystemDock::_get_drag_target_folder(String &target, bool &target_favorites, const Point2 &p_point, Control *p_from) const {
diff --git a/editor/icons/AnimatableBody2D.svg b/editor/icons/AnimatableBody2D.svg
new file mode 100644
index 0000000000..f4fed813c9
--- /dev/null
+++ b/editor/icons/AnimatableBody2D.svg
@@ -0,0 +1 @@
+<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="1.5" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#8da5f3" fill-opacity=".99" stroke-width="1.08904"><path d="m10.86822576 4.28299076h1.99947744v1.99947744h-1.99947744z"/><path d="m10.86822576 10.84273776h1.99947744v1.99947744h-1.99947744z"/><path d="m4.71256576 10.84273776h1.99947744v1.99947744h-1.99947744z"/></g><g fill="none" stroke="#8da5f3"><path d="m1.635 8.161v4.848c0 .713.579 1.293 1.292 1.293h9.857c.713 0 1.291-.58 1.291-1.293v-9.854c0-.714-.578-1.293-1.291-1.293h-5.526" stroke-width="1.07" transform="matrix(.939225 0 0 .938055 1.27996 1.07595)"/><path d="m1.339 1.364 2.539 2.539" stroke-width=".74" transform="matrix(2.04823 .655864 .655864 2.04823 -1.51683 -1.5267)"/><path d="m1.436 1.461 1.168 1.168" stroke-width="1.18" transform="matrix(1.69185 0 0 1.69185 4.50755 -.792876)"/><path d="m1.385 1.41 1.219 1.219" stroke-width="1.22" transform="matrix(1.63859 0 0 1.63859 -.688679 4.82985)"/></g></svg>
diff --git a/editor/icons/AnimatableBody3D.svg b/editor/icons/AnimatableBody3D.svg
new file mode 100644
index 0000000000..2e472f0625
--- /dev/null
+++ b/editor/icons/AnimatableBody3D.svg
@@ -0,0 +1 @@
+<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="1.5" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#fc7f7f" fill-opacity=".99" stroke-width="1.08904"><path d="m10.86822576 4.28299076h1.99947744v1.99947744h-1.99947744z"/><path d="m10.86822576 10.84273776h1.99947744v1.99947744h-1.99947744z"/><path d="m4.71256576 10.84273776h1.99947744v1.99947744h-1.99947744z"/></g><g fill="none" stroke="#fc7f7f"><path d="m1.635 8.161v4.848c0 .713.579 1.293 1.292 1.293h9.857c.713 0 1.291-.58 1.291-1.293v-9.854c0-.714-.578-1.293-1.291-1.293h-5.526" stroke-width="1.07" transform="matrix(.939225 0 0 .938055 1.27996 1.07595)"/><path d="m1.339 1.364 2.539 2.539" stroke-width=".74" transform="matrix(2.04823 .655864 .655864 2.04823 -1.51683 -1.5267)"/><path d="m1.436 1.461 1.168 1.168" stroke-width="1.18" transform="matrix(1.69185 0 0 1.69185 4.50755 -.792876)"/><path d="m1.385 1.41 1.219 1.219" stroke-width="1.22" transform="matrix(1.63859 0 0 1.63859 -.688679 4.82985)"/></g></svg>
diff --git a/editor/icons/Listener2D.svg b/editor/icons/Listener2D.svg
new file mode 100644
index 0000000000..db84dcfed7
--- /dev/null
+++ b/editor/icons/Listener2D.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m6 1a5 5 0 0 0 -5 5h2a3 3 0 0 1 3-3 3 3 0 0 1 3 3c0 1.75-.54175 2.3583-1.1406 2.8574-.29944.2495-.62954.44071-.97656.69141-.17351.1253-.35729.26529-.53711.49219-.17982.227-.3457.58398-.3457.95898 0 1.2778-.31632 1.5742-.63867 1.7676-.32236.1934-.86133.23242-1.3613.23242h-1v2h1c.5 0 1.461.038922 2.3887-.51758.87316-.5239 1.4826-1.6633 1.5566-3.2266.011365-.0098.027247-.024684.10938-.083984.21547-.1556.63537-.40194 1.0859-.77734.90112-.751 1.8594-2.1445 1.8594-4.3945a5 5 0 0 0 -5-5zm7.9277 1-1.7383 1.0039a6 6 0 0 1 .81055 2.9961 6 6 0 0 1 -.80859 2.998l1.7363 1.002a8 8 0 0 0 0-8z" fill="#a5b7f3"/></svg>
diff --git a/editor/icons/PageFirst.svg b/editor/icons/PageFirst.svg
new file mode 100644
index 0000000000..76078691ef
--- /dev/null
+++ b/editor/icons/PageFirst.svg
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ height="12"
+ viewBox="0 0 12 12"
+ width="12"
+ version="1.1"
+ id="svg4"
+ sodipodi:docname="PageFirst.svg"
+ inkscape:version="1.1 (c4e8f9ed74, 2021-05-24)"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <defs
+ id="defs8" />
+ <sodipodi:namedview
+ id="namedview6"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ inkscape:pagecheckerboard="0"
+ showgrid="true"
+ inkscape:zoom="74.25"
+ inkscape:cx="18.053872"
+ inkscape:cy="6.5252525"
+ inkscape:window-width="3838"
+ inkscape:window-height="1582"
+ inkscape:window-x="0"
+ inkscape:window-y="16"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg4">
+ <inkscape:grid
+ type="xygrid"
+ id="grid989" />
+ </sodipodi:namedview>
+ <path
+ d="M 6,9 3,6 6,3"
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ id="path2" />
+ <path
+ d="M 9,9 V 3"
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ id="path2211"
+ sodipodi:nodetypes="cc" />
+</svg>
diff --git a/editor/icons/PageLast.svg b/editor/icons/PageLast.svg
new file mode 100644
index 0000000000..17c874e8c9
--- /dev/null
+++ b/editor/icons/PageLast.svg
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ height="12"
+ viewBox="0 0 12 12"
+ width="12"
+ version="1.1"
+ id="svg4"
+ sodipodi:docname="PageLast.svg"
+ inkscape:version="1.1 (c4e8f9ed74, 2021-05-24)"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <defs
+ id="defs8" />
+ <sodipodi:namedview
+ id="namedview6"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ inkscape:pagecheckerboard="0"
+ showgrid="true"
+ inkscape:zoom="74.25"
+ inkscape:cx="18.053872"
+ inkscape:cy="6.5252525"
+ inkscape:window-width="3838"
+ inkscape:window-height="1582"
+ inkscape:window-x="0"
+ inkscape:window-y="16"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg4">
+ <inkscape:grid
+ type="xygrid"
+ id="grid989" />
+ </sodipodi:namedview>
+ <path
+ d="m 6.0000414,9 3,-3 -3,-3"
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ id="path2" />
+ <path
+ d="M 3.0000414,9 V 3"
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ id="path2211"
+ sodipodi:nodetypes="cc" />
+</svg>
diff --git a/editor/icons/PageNext.svg b/editor/icons/PageNext.svg
new file mode 100644
index 0000000000..89ff6219bb
--- /dev/null
+++ b/editor/icons/PageNext.svg
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ height="12"
+ viewBox="0 0 12 12"
+ width="12"
+ version="1.1"
+ id="svg4"
+ sodipodi:docname="PageNext.svg"
+ inkscape:version="1.1 (c4e8f9ed74, 2021-05-24)"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <defs
+ id="defs8" />
+ <sodipodi:namedview
+ id="namedview6"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ inkscape:pagecheckerboard="0"
+ showgrid="true"
+ inkscape:zoom="105.00536"
+ inkscape:cx="4.5854803"
+ inkscape:cy="5.9377923"
+ inkscape:window-width="3838"
+ inkscape:window-height="1582"
+ inkscape:window-x="0"
+ inkscape:window-y="16"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg4">
+ <inkscape:grid
+ type="xygrid"
+ id="grid989" />
+ </sodipodi:namedview>
+ <path
+ d="m 4.5000207,9 3,-3 -3,-3"
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ id="path2" />
+</svg>
diff --git a/editor/icons/PagePrevious.svg b/editor/icons/PagePrevious.svg
new file mode 100644
index 0000000000..a2fa84da0c
--- /dev/null
+++ b/editor/icons/PagePrevious.svg
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ height="12"
+ viewBox="0 0 12 12"
+ width="12"
+ version="1.1"
+ id="svg4"
+ sodipodi:docname="PagePrevious.svg"
+ inkscape:version="1.1 (c4e8f9ed74, 2021-05-24)"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <defs
+ id="defs8" />
+ <sodipodi:namedview
+ id="namedview6"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ inkscape:pagecheckerboard="0"
+ showgrid="true"
+ inkscape:zoom="105.00536"
+ inkscape:cx="4.5854803"
+ inkscape:cy="5.9377923"
+ inkscape:window-width="3838"
+ inkscape:window-height="1582"
+ inkscape:window-x="0"
+ inkscape:window-y="16"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg4">
+ <inkscape:grid
+ type="xygrid"
+ id="grid989" />
+ </sodipodi:namedview>
+ <path
+ d="m 7.4999793,9 -3,-3 3,-3"
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ id="path2" />
+</svg>
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index daf7b15794..61745cb6ee 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -393,7 +393,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
float lossy = p_options["compress/lossy_quality"];
int pack_channels = p_options["compress/channel_pack"];
bool mipmaps = p_options["mipmaps/generate"];
- uint32_t mipmap_limit = int(mipmaps ? int(p_options["mipmaps/limit"]) : int(-1));
+ uint32_t mipmap_limit = mipmaps ? uint32_t(p_options["mipmaps/limit"]) : uint32_t(-1);
bool fix_alpha_border = p_options["process/fix_alpha_border"];
bool premult_alpha = p_options["process/premult_alpha"];
bool normal_map_invert_y = p_options["process/normal_map_invert_y"];
diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp
index d04e88e915..d20f3d105b 100644
--- a/editor/plugins/node_3d_editor_gizmos.cpp
+++ b/editor/plugins/node_3d_editor_gizmos.cpp
@@ -2097,7 +2097,6 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Color bonecolor = Color(1.0, 0.4, 0.4, 0.3);
Color rootcolor = Color(0.4, 1.0, 0.4, 0.1);
- //LocalVector<int> bones_to_process = skel->get_parentless_bones();
LocalVector<int> bones_to_process;
bones_to_process = skel->get_parentless_bones();
@@ -2109,19 +2108,18 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
child_bones_vector = skel->get_bone_children(current_bone_idx);
int child_bones_size = child_bones_vector.size();
- // You have children but no parent, then you must be a root/parentless bone.
- if (child_bones_size >= 0 && skel->get_bone_parent(current_bone_idx) <= 0) {
- grests[current_bone_idx] = skel->global_pose_to_local_pose(current_bone_idx, skel->get_bone_global_pose(current_bone_idx));
+ if (skel->get_bone_parent(current_bone_idx) < 0) {
+ grests[current_bone_idx] = skel->get_bone_rest(current_bone_idx);
}
for (int i = 0; i < child_bones_size; i++) {
int child_bone_idx = child_bones_vector[i];
- grests[child_bone_idx] = skel->global_pose_to_local_pose(child_bone_idx, skel->get_bone_global_pose(child_bone_idx));
+ grests[child_bone_idx] = grests[current_bone_idx] * skel->get_bone_rest(child_bone_idx);
Vector3 v0 = grests[current_bone_idx].origin;
Vector3 v1 = grests[child_bone_idx].origin;
- Vector3 d = skel->get_bone_rest(child_bone_idx).origin.normalized();
- real_t dist = skel->get_bone_rest(child_bone_idx).origin.length();
+ Vector3 d = (v1 - v0).normalized();
+ real_t dist = v0.distance_to(v1);
// Find closest axis.
int closest = -1;
diff --git a/editor/plugins/packed_scene_translation_parser_plugin.cpp b/editor/plugins/packed_scene_translation_parser_plugin.cpp
index 0a949c8610..53c5b8dd70 100644
--- a/editor/plugins/packed_scene_translation_parser_plugin.cpp
+++ b/editor/plugins/packed_scene_translation_parser_plugin.cpp
@@ -31,6 +31,7 @@
#include "packed_scene_translation_parser_plugin.h"
#include "core/io/resource_loader.h"
+#include "scene/gui/option_button.h"
#include "scene/resources/packed_scene.h"
void PackedSceneEditorTranslationParserPlugin::get_recognized_extensions(List<String> *r_extensions) const {
@@ -50,21 +51,31 @@ Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path,
Ref<SceneState> state = Ref<PackedScene>(loaded_res)->get_state();
Vector<String> parsed_strings;
- String property_name;
- Variant property_value;
for (int i = 0; i < state->get_node_count(); i++) {
- if (!ClassDB::is_parent_class(state->get_node_type(i), "Control") && !ClassDB::is_parent_class(state->get_node_type(i), "Viewport")) {
+ String node_type = state->get_node_type(i);
+ if (!ClassDB::is_parent_class(node_type, "Control") && !ClassDB::is_parent_class(node_type, "Window")) {
continue;
}
+ // Find the `auto_translate` property, and abort the string parsing of the node if disabled.
+ bool auto_translating = true;
for (int j = 0; j < state->get_node_property_count(i); j++) {
- property_name = state->get_node_property_name(i, j);
- if (!lookup_properties.has(property_name)) {
- continue;
+ if (state->get_node_property_name(i, j) == "auto_translate" && (bool)state->get_node_property_value(i, j) == false) {
+ auto_translating = false;
+ break;
}
+ }
+ if (!auto_translating) {
+ continue;
+ }
- property_value = state->get_node_property_value(i, j);
+ for (int j = 0; j < state->get_node_property_count(i); j++) {
+ String property_name = state->get_node_property_name(i, j);
+ if (!lookup_properties.has(property_name) || (exception_list.has(node_type) && exception_list[node_type].has(property_name))) {
+ continue;
+ }
+ Variant property_value = state->get_node_property_value(i, j);
if (property_name == "script" && property_value.get_type() == Variant::OBJECT && !property_value.is_null()) {
// Parse built-in script.
Ref<Script> s = Object::cast_to<Script>(property_value);
@@ -76,7 +87,16 @@ Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path,
parsed_strings.append_array(temp);
r_ids_ctx_plural->append_array(ids_context_plural);
}
- } else if (property_name == "filters") {
+ } else if ((node_type == "MenuButton" || node_type == "OptionButton") && property_name == "items") {
+ Vector<String> str_values = property_value;
+ int incr_value = node_type == "MenuButton" ? PopupMenu::ITEM_PROPERTY_SIZE : OptionButton::ITEM_PROPERTY_SIZE;
+ for (int k = 0; k < str_values.size(); k += incr_value) {
+ String desc = str_values[k].get_slice(";", 1).strip_edges();
+ if (!desc.is_empty()) {
+ parsed_strings.push_back(desc);
+ }
+ }
+ } else if (node_type == "FileDialog" && property_name == "filters") {
// Extract FileDialog's filters property with values in format "*.png ; PNG Images","*.gd ; GDScript Files".
Vector<String> str_values = property_value;
for (int k = 0; k < str_values.size(); k++) {
@@ -105,12 +125,17 @@ PackedSceneEditorTranslationParserPlugin::PackedSceneEditorTranslationParserPlug
lookup_properties.insert("text");
lookup_properties.insert("hint_tooltip");
lookup_properties.insert("placeholder_text");
+ lookup_properties.insert("items");
+ lookup_properties.insert("title");
lookup_properties.insert("dialog_text");
lookup_properties.insert("filters");
lookup_properties.insert("script");
- //Add exception list (to prevent false positives)
- //line edit, text edit, richtextlabel
- //Set<String> exception_list;
- //exception_list.insert("RichTextLabel");
+ // Exception list (to prevent false positives).
+ exception_list.insert("LineEdit", Vector<StringName>());
+ exception_list["LineEdit"].append("text");
+ exception_list.insert("TextEdit", Vector<StringName>());
+ exception_list["TextEdit"].append("text");
+ exception_list.insert("CodeEdit", Vector<StringName>());
+ exception_list["CodeEdit"].append("text");
}
diff --git a/editor/plugins/packed_scene_translation_parser_plugin.h b/editor/plugins/packed_scene_translation_parser_plugin.h
index e51d65414e..af0291b69c 100644
--- a/editor/plugins/packed_scene_translation_parser_plugin.h
+++ b/editor/plugins/packed_scene_translation_parser_plugin.h
@@ -37,7 +37,9 @@ class PackedSceneEditorTranslationParserPlugin : public EditorTranslationParserP
GDCLASS(PackedSceneEditorTranslationParserPlugin, EditorTranslationParserPlugin);
// Scene Node's properties that contain translation strings.
- Set<String> lookup_properties;
+ Set<StringName> lookup_properties;
+ // Properties from specific Nodes that should be ignored.
+ Map<StringName, Vector<StringName>> exception_list;
public:
virtual Error parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural) override;
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index c44760807f..48239a5d99 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -158,7 +158,6 @@ void ScriptTextEditor::enable_editor() {
editor_enabled = true;
_enable_code_editor();
- _set_theme_for_script();
_validate_script();
}
diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp
index d406c2514c..fd5c59af34 100644
--- a/editor/plugins/tiles/tile_data_editors.cpp
+++ b/editor/plugins/tiles/tile_data_editors.cpp
@@ -1465,12 +1465,13 @@ void TileDataTerrainsEditor::_tile_set_changed() {
ERR_FAIL_COND(!tile_set.is_valid());
// Fix if wrong values are selected.
- if (int(dummy_object->get("terrain_set")) > tile_set->get_terrain_sets_count()) {
+ int terrain_set = int(dummy_object->get("terrain_set"));
+ if (terrain_set >= tile_set->get_terrain_sets_count()) {
+ terrain_set = -1;
dummy_object->set("terrain_set", -1);
}
- int terrain_set = int(dummy_object->get("terrain"));
if (terrain_set >= 0) {
- if (int(dummy_object->get("terrain")) > tile_set->get_terrains_count(terrain_set)) {
+ if (int(dummy_object->get("terrain")) >= tile_set->get_terrains_count(terrain_set)) {
dummy_object->set("terrain", -1);
}
}
diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp
index 77084f551a..b5e070b4d6 100644
--- a/editor/plugins/tiles/tile_map_editor.cpp
+++ b/editor/plugins/tiles/tile_map_editor.cpp
@@ -3549,30 +3549,76 @@ void TileMapEditor::_update_layers_selection() {
tile_map_editor_plugins[tabs->get_current_tab()]->edit(tile_map_id, tile_map_layer);
}
-void TileMapEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) {
+void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) {
UndoRedo *undo_redo = Object::cast_to<UndoRedo>(p_undo_redo);
ERR_FAIL_COND(!undo_redo);
TileMap *tile_map = Object::cast_to<TileMap>(p_edited);
- if (tile_map) {
- if (p_property == "layers_count") {
- int new_layers_count = (int)p_new_value;
- if (new_layers_count < tile_map->get_layers_count()) {
- List<PropertyInfo> property_list;
- tile_map->get_property_list(&property_list);
-
- for (PropertyInfo property_info : property_list) {
- Vector<String> components = String(property_info.name).split("/", true, 2);
- if (components.size() == 2 && components[0].begins_with("layer_") && components[0].trim_prefix("layer_").is_valid_int()) {
- int index = components[0].trim_prefix("layer_").to_int();
- if (index >= new_layers_count) {
- undo_redo->add_undo_property(tile_map, property_info.name, tile_map->get(property_info.name));
- }
- }
+ if (!tile_map) {
+ return;
+ }
+
+ // Compute the array indices to save.
+ int begin = 0;
+ int end;
+ if (p_array_prefix == "layer_") {
+ end = tile_map->get_layers_count();
+ } else {
+ ERR_FAIL_MSG("Invalid array prefix for TileSet.");
+ }
+ if (p_from_index < 0) {
+ // Adding new.
+ if (p_to_pos >= 0) {
+ begin = p_to_pos;
+ } else {
+ end = 0; // Nothing to save when adding at the end.
+ }
+ } else if (p_to_pos < 0) {
+ // Removing.
+ begin = p_from_index;
+ } else {
+ // Moving.
+ begin = MIN(p_from_index, p_to_pos);
+ end = MIN(MAX(p_from_index, p_to_pos) + 1, end);
+ }
+
+#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property));
+ // Save layers' properties.
+ if (p_from_index < 0) {
+ undo_redo->add_undo_method(tile_map, "remove_layer", p_to_pos < 0 ? tile_map->get_layers_count() : p_to_pos);
+ } else if (p_to_pos < 0) {
+ undo_redo->add_undo_method(tile_map, "add_layer", p_from_index);
+ }
+
+ List<PropertyInfo> properties;
+ tile_map->get_property_list(&properties);
+ for (PropertyInfo pi : properties) {
+ if (pi.name.begins_with(p_array_prefix)) {
+ String str = pi.name.trim_prefix(p_array_prefix);
+ int to_char_index = 0;
+ while (to_char_index < str.length()) {
+ if (str[to_char_index] < '0' || str[to_char_index] > '9') {
+ break;
+ }
+ to_char_index++;
+ }
+ if (to_char_index > 0) {
+ int array_index = str.left(to_char_index).to_int();
+ if (array_index >= begin && array_index < end) {
+ ADD_UNDO(tile_map, pi.name);
}
}
}
}
+#undef ADD_UNDO
+
+ if (p_from_index < 0) {
+ undo_redo->add_do_method(tile_map, "add_layer", p_to_pos);
+ } else if (p_to_pos < 0) {
+ undo_redo->add_do_method(tile_map, "remove_layer", p_from_index);
+ } else {
+ undo_redo->add_do_method(tile_map, "move_layer", p_from_index, p_to_pos);
+ }
}
bool TileMapEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
@@ -3851,7 +3897,7 @@ TileMapEditor::TileMapEditor() {
_tab_changed(0);
// Registers UndoRedo inspector callback.
- EditorNode::get_singleton()->get_editor_data().add_undo_redo_inspector_hook_callback(callable_mp(this, &TileMapEditor::_undo_redo_inspector_callback));
+ EditorNode::get_singleton()->get_editor_data().add_move_array_element_function(SNAME("TileMap"), callable_mp(this, &TileMapEditor::_move_tile_map_array_element));
}
TileMapEditor::~TileMapEditor() {
diff --git a/editor/plugins/tiles/tile_map_editor.h b/editor/plugins/tiles/tile_map_editor.h
index 6e2f2ce2ba..6126db59e9 100644
--- a/editor/plugins/tiles/tile_map_editor.h
+++ b/editor/plugins/tiles/tile_map_editor.h
@@ -341,7 +341,7 @@ private:
void _update_layers_selection();
// Inspector undo/redo callback.
- void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value);
+ void _move_tile_map_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos);
protected:
void _notification(int p_what);
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
index 432f48fa85..c3a3f40e00 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
@@ -1866,7 +1866,7 @@ void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo
UndoRedo *undo_redo = Object::cast_to<UndoRedo>(p_undo_redo);
ERR_FAIL_COND(!undo_redo);
-#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, tile_data->get(property));
+#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property));
AtlasTileProxyObject *tile_data = Object::cast_to<AtlasTileProxyObject>(p_edited);
if (tile_data) {
diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp
index ba98a7d6b3..48d0d9b333 100644
--- a/editor/plugins/tiles/tile_set_editor.cpp
+++ b/editor/plugins/tiles/tile_set_editor.cpp
@@ -330,11 +330,192 @@ void TileSetEditor::_tile_set_changed() {
tile_set_changed_needs_update = true;
}
+void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) {
+ UndoRedo *undo_redo = Object::cast_to<UndoRedo>(p_undo_redo);
+ ERR_FAIL_COND(!undo_redo);
+
+ TileSet *tile_set = Object::cast_to<TileSet>(p_edited);
+ if (!tile_set) {
+ return;
+ }
+
+ Vector<String> components = String(p_array_prefix).split("/", true, 2);
+
+ // Compute the array indices to save.
+ int begin = 0;
+ int end;
+ if (p_array_prefix == "occlusion_layer_") {
+ end = tile_set->get_occlusion_layers_count();
+ } else if (p_array_prefix == "physics_layer_") {
+ end = tile_set->get_physics_layers_count();
+ } else if (p_array_prefix == "terrain_set_") {
+ end = tile_set->get_terrain_sets_count();
+ } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") {
+ int terrain_set = components[0].trim_prefix("terrain_set_").to_int();
+ end = tile_set->get_terrains_count(terrain_set);
+ } else if (p_array_prefix == "navigation_layer_") {
+ end = tile_set->get_navigation_layers_count();
+ } else if (p_array_prefix == "custom_data_layer_") {
+ end = tile_set->get_custom_data_layers_count();
+ } else {
+ ERR_FAIL_MSG("Invalid array prefix for TileSet.");
+ }
+ if (p_from_index < 0) {
+ // Adding new.
+ if (p_to_pos >= 0) {
+ begin = p_to_pos;
+ } else {
+ end = 0; // Nothing to save when adding at the end.
+ }
+ } else if (p_to_pos < 0) {
+ // Removing.
+ begin = p_from_index;
+ } else {
+ // Moving.
+ begin = MIN(p_from_index, p_to_pos);
+ end = MIN(MAX(p_from_index, p_to_pos) + 1, end);
+ }
+
+#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property));
+ // Save layers' properties.
+ List<PropertyInfo> properties;
+ tile_set->get_property_list(&properties);
+ for (PropertyInfo pi : properties) {
+ if (pi.name.begins_with(p_array_prefix)) {
+ String str = pi.name.trim_prefix(p_array_prefix);
+ int to_char_index = 0;
+ while (to_char_index < str.length()) {
+ if (str[to_char_index] < '0' || str[to_char_index] > '9') {
+ break;
+ }
+ to_char_index++;
+ }
+ if (to_char_index > 0) {
+ int array_index = str.left(to_char_index).to_int();
+ if (array_index >= begin && array_index < end) {
+ ADD_UNDO(tile_set, pi.name);
+ }
+ }
+ }
+ }
+
+ // Save properties for TileSetAtlasSources tile data
+ for (int i = 0; i < tile_set->get_source_count(); i++) {
+ int source_id = tile_set->get_source_id(i);
+
+ Ref<TileSetAtlasSource> tas = tile_set->get_source(source_id);
+ if (tas.is_valid()) {
+ for (int j = 0; j < tas->get_tiles_count(); j++) {
+ Vector2i tile_id = tas->get_tile_id(j);
+ for (int k = 0; k < tas->get_alternative_tiles_count(tile_id); k++) {
+ int alternative_id = tas->get_alternative_tile_id(tile_id, k);
+ TileData *tile_data = Object::cast_to<TileData>(tas->get_tile_data(tile_id, alternative_id));
+ ERR_FAIL_COND(!tile_data);
+
+ // Actually saving stuff.
+ if (p_array_prefix == "occlusion_layer_") {
+ for (int layer_index = begin; layer_index < end; layer_index++) {
+ ADD_UNDO(tile_data, vformat("occlusion_layer_%d/polygon", layer_index));
+ }
+ } else if (p_array_prefix == "physics_layer_") {
+ for (int layer_index = begin; layer_index < end; layer_index++) {
+ ADD_UNDO(tile_data, vformat("physics_layer_%d/polygons_count", layer_index));
+ for (int polygon_index = 0; polygon_index < tile_data->get_collision_polygons_count(layer_index); polygon_index++) {
+ ADD_UNDO(tile_data, vformat("physics_layer_%d/polygon_%d/points", layer_index, polygon_index));
+ ADD_UNDO(tile_data, vformat("physics_layer_%d/polygon_%d/one_way", layer_index, polygon_index));
+ ADD_UNDO(tile_data, vformat("physics_layer_%d/polygon_%d/one_way_margin", layer_index, polygon_index));
+ }
+ }
+ } else if (p_array_prefix == "terrain_set_") {
+ ADD_UNDO(tile_data, "terrain_set");
+ for (int terrain_set_index = begin; terrain_set_index < end; terrain_set_index++) {
+ for (int l = 0; l < TileSet::CELL_NEIGHBOR_MAX; l++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(l);
+ if (tile_data->is_valid_peering_bit_terrain(bit)) {
+ ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l]));
+ }
+ }
+ }
+ } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") {
+ for (int terrain_index = 0; terrain_index < TileSet::CELL_NEIGHBOR_MAX; terrain_index++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(terrain_index);
+ if (tile_data->is_valid_peering_bit_terrain(bit)) {
+ ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[terrain_index]));
+ }
+ }
+ } else if (p_array_prefix == "navigation_layer_") {
+ for (int layer_index = begin; layer_index < end; layer_index++) {
+ ADD_UNDO(tile_data, vformat("navigation_layer_%d/polygon", layer_index));
+ }
+ } else if (p_array_prefix == "custom_data_layer_") {
+ for (int layer_index = begin; layer_index < end; layer_index++) {
+ ADD_UNDO(tile_data, vformat("custom_data_%d", layer_index));
+ }
+ }
+ }
+ }
+ }
+ }
+#undef ADD_UNDO
+
+ // Add do method.
+ if (p_array_prefix == "occlusion_layer_") {
+ if (p_from_index < 0) {
+ undo_redo->add_do_method(tile_set, "add_occlusion_layer", p_to_pos);
+ } else if (p_to_pos < 0) {
+ undo_redo->add_do_method(tile_set, "remove_occlusion_layer", p_from_index);
+ } else {
+ undo_redo->add_do_method(tile_set, "move_occlusion_layer", p_from_index, p_to_pos);
+ }
+ } else if (p_array_prefix == "physics_layer_") {
+ if (p_from_index < 0) {
+ undo_redo->add_do_method(tile_set, "add_physics_layer", p_to_pos);
+ } else if (p_to_pos < 0) {
+ undo_redo->add_do_method(tile_set, "remove_physics_layer", p_from_index);
+ } else {
+ undo_redo->add_do_method(tile_set, "move_physics_layer", p_from_index, p_to_pos);
+ }
+ } else if (p_array_prefix == "terrain_set_") {
+ if (p_from_index < 0) {
+ undo_redo->add_do_method(tile_set, "add_terrain_set", p_to_pos);
+ } else if (p_to_pos < 0) {
+ undo_redo->add_do_method(tile_set, "remove_terrain_set", p_from_index);
+ } else {
+ undo_redo->add_do_method(tile_set, "move_terrain_set", p_from_index, p_to_pos);
+ }
+ } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") {
+ int terrain_set = components[0].trim_prefix("terrain_set_").to_int();
+ if (p_from_index < 0) {
+ undo_redo->add_do_method(tile_set, "add_terrain", terrain_set, p_to_pos);
+ } else if (p_to_pos < 0) {
+ undo_redo->add_do_method(tile_set, "remove_terrain", terrain_set, p_from_index);
+ } else {
+ undo_redo->add_do_method(tile_set, "move_terrain", terrain_set, p_from_index, p_to_pos);
+ }
+ } else if (p_array_prefix == "navigation_layer_") {
+ if (p_from_index < 0) {
+ undo_redo->add_do_method(tile_set, "add_navigation_layer", p_to_pos);
+ } else if (p_to_pos < 0) {
+ undo_redo->add_do_method(tile_set, "remove_navigation_layer", p_from_index);
+ } else {
+ undo_redo->add_do_method(tile_set, "move_navigation_layer", p_from_index, p_to_pos);
+ }
+ } else if (p_array_prefix == "custom_data_layer_") {
+ if (p_from_index < 0) {
+ undo_redo->add_do_method(tile_set, "add_custom_data_layer", p_to_pos);
+ } else if (p_to_pos < 0) {
+ undo_redo->add_do_method(tile_set, "remove_custom_data_layer", p_from_index);
+ } else {
+ undo_redo->add_do_method(tile_set, "move_custom_data_layer", p_from_index, p_to_pos);
+ }
+ }
+}
+
void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) {
UndoRedo *undo_redo = Object::cast_to<UndoRedo>(p_undo_redo);
ERR_FAIL_COND(!undo_redo);
-#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, tile_data->get(property));
+#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property));
TileSet *tile_set = Object::cast_to<TileSet>(p_edited);
if (tile_set) {
Vector<String> components = p_property.split("/", true, 3);
@@ -350,30 +531,7 @@ void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p
TileData *tile_data = Object::cast_to<TileData>(tas->get_tile_data(tile_id, alternative_id));
ERR_FAIL_COND(!tile_data);
- if (p_property == "occlusion_layers_count") {
- int new_layer_count = p_new_value;
- int old_layer_count = tile_set->get_occlusion_layers_count();
- if (new_layer_count < old_layer_count) {
- for (int occclusion_layer_index = new_layer_count - 1; occclusion_layer_index < old_layer_count; occclusion_layer_index++) {
- ADD_UNDO(tile_data, vformat("occlusion_layer_%d/polygon", occclusion_layer_index));
- }
- }
- } else if (p_property == "physics_layers_count") {
- int new_layer_count = p_new_value;
- int old_layer_count = tile_set->get_physics_layers_count();
- if (new_layer_count < old_layer_count) {
- for (int physics_layer_index = new_layer_count - 1; physics_layer_index < old_layer_count; physics_layer_index++) {
- ADD_UNDO(tile_data, vformat("physics_layer_%d/polygons_count", physics_layer_index));
- for (int polygon_index = 0; polygon_index < tile_data->get_collision_polygons_count(physics_layer_index); polygon_index++) {
- ADD_UNDO(tile_data, vformat("physics_layer_%d/polygon_%d/points", physics_layer_index, polygon_index));
- ADD_UNDO(tile_data, vformat("physics_layer_%d/polygon_%d/one_way", physics_layer_index, polygon_index));
- ADD_UNDO(tile_data, vformat("physics_layer_%d/polygon_%d/one_way_margin", physics_layer_index, polygon_index));
- }
- }
- }
- } else if ((p_property == "terrains_sets_count" && tile_data->get_terrain_set() >= (int)p_new_value) ||
- (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "mode") ||
- (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrains_count" && tile_data->get_terrain_set() == components[0].trim_prefix("terrain_set_").to_int() && (int)p_new_value < tile_set->get_terrains_count(tile_data->get_terrain_set()))) {
+ if (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "mode") {
ADD_UNDO(tile_data, "terrain_set");
for (int l = 0; l < TileSet::CELL_NEIGHBOR_MAX; l++) {
TileSet::CellNeighbor bit = TileSet::CellNeighbor(l);
@@ -381,22 +539,6 @@ void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p
ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l]));
}
}
- } else if (p_property == "navigation_layers_count") {
- int new_layer_count = p_new_value;
- int old_layer_count = tile_set->get_navigation_layers_count();
- if (new_layer_count < old_layer_count) {
- for (int navigation_layer_index = new_layer_count - 1; navigation_layer_index < old_layer_count; navigation_layer_index++) {
- ADD_UNDO(tile_data, vformat("navigation_layer_%d/polygon", navigation_layer_index));
- }
- }
- } else if (p_property == "custom_data_layers_count") {
- int new_layer_count = p_new_value;
- int old_layer_count = tile_set->get_custom_data_layers_count();
- if (new_layer_count < old_layer_count) {
- for (int custom_data_layer_index = new_layer_count - 1; custom_data_layer_index < old_layer_count; custom_data_layer_index++) {
- ADD_UNDO(tile_data, vformat("custom_data_%d", custom_data_layer_index));
- }
- }
} else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int() && components[1] == "type") {
int custom_data_layer = components[0].trim_prefix("custom_data_layer_").is_valid_int();
ADD_UNDO(tile_data, vformat("custom_data_%d", custom_data_layer));
@@ -531,6 +673,7 @@ TileSetEditor::TileSetEditor() {
tile_set_scenes_collection_source_editor->hide();
// Registers UndoRedo inspector callback.
+ EditorNode::get_singleton()->get_editor_data().add_move_array_element_function(SNAME("TileSet"), callable_mp(this, &TileSetEditor::_move_tile_set_array_element));
EditorNode::get_singleton()->get_editor_data().add_undo_redo_inspector_hook_callback(callable_mp(this, &TileSetEditor::_undo_redo_inspector_callback));
}
diff --git a/editor/plugins/tiles/tile_set_editor.h b/editor/plugins/tiles/tile_set_editor.h
index 970e3fabb6..fe854b2281 100644
--- a/editor/plugins/tiles/tile_set_editor.h
+++ b/editor/plugins/tiles/tile_set_editor.h
@@ -71,6 +71,7 @@ private:
void _tile_set_changed();
+ void _move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos);
void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value);
protected:
diff --git a/editor/pot_generator.cpp b/editor/pot_generator.cpp
index b58b7e4cac..d57345cac1 100644
--- a/editor/pot_generator.cpp
+++ b/editor/pot_generator.cpp
@@ -108,7 +108,6 @@ void POTGenerator::_write_to_pot(const String &p_file) {
const String header =
"# LANGUAGE translation for " + project_name + " for the following files:\n" + extracted_files +
"#\n"
- "#\n"
"# FIRST AUTHOR < EMAIL @ADDRESS>, YEAR.\n"
"#\n"
"#, fuzzy\n"
@@ -116,8 +115,9 @@ void POTGenerator::_write_to_pot(const String &p_file) {
"msgstr \"\"\n"
"\"Project-Id-Version: " +
project_name + "\\n\"\n"
+ "\"MIME-Version: 1.0\\n\"\n"
"\"Content-Type: text/plain; charset=UTF-8\\n\"\n"
- "\"Content-Transfer-Encoding: 8-bit\\n\"\n\n";
+ "\"Content-Transfer-Encoding: 8-bit\\n\"\n";
file->store_string(header);
@@ -129,6 +129,9 @@ void POTGenerator::_write_to_pot(const String &p_file) {
String plural = v_msgid_data[i].plural;
const Set<String> &locations = v_msgid_data[i].locations;
+ // Put the blank line at the start, to avoid a double at the end when closing the file.
+ file->store_line("");
+
// Write file locations.
for (Set<String>::Element *E = locations.front(); E; E = E->next()) {
file->store_line("#: " + E->get().trim_prefix("res://"));
@@ -142,13 +145,13 @@ void POTGenerator::_write_to_pot(const String &p_file) {
// Write msgid.
_write_msgid(file, msgid, false);
- // Write msgid_plural
+ // Write msgid_plural.
if (!plural.is_empty()) {
_write_msgid(file, plural, true);
file->store_line("msgstr[0] \"\"");
- file->store_line("msgstr[1] \"\"\n");
+ file->store_line("msgstr[1] \"\"");
} else {
- file->store_line("msgstr \"\"\n");
+ file->store_line("msgstr \"\"");
}
}
}
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index b8ccab78dd..db12e90540 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -222,7 +222,6 @@ void ProjectSettingsEditor::_add_feature_overrides() {
presets.insert("standalone");
presets.insert("32");
presets.insert("64");
- presets.insert("Server"); // Not available as an export platform yet, so it needs to be added manually
EditorExport *ee = EditorExport::get_singleton();
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 2ec4a088a2..a08a628216 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -2837,6 +2837,11 @@ void SceneTreeDock::set_filter(const String &p_filter) {
scene_tree->set_filter(p_filter);
}
+void SceneTreeDock::save_branch_to_file(String p_directory) {
+ new_scene_from_dialog->set_current_dir(p_directory);
+ _tool_selected(TOOL_NEW_SCENE_FROM);
+}
+
void SceneTreeDock::_focus_node() {
Node *node = scene_tree->get_selected();
ERR_FAIL_COND(!node);
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index 387a35acbb..1086e8615f 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -269,6 +269,7 @@ protected:
public:
String get_filter();
void set_filter(const String &p_filter);
+ void save_branch_to_file(String p_directory);
void _focus_node();
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index e7ba80677d..d54bf73028 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -291,10 +291,12 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll
}
}
+ // Display the node name in all tooltips so that long node names can be previewed
+ // without having to rename them.
if (p_node == get_scene_node() && p_node->get_scene_inherited_state().is_valid()) {
item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
- String tooltip = TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path() + "\n" + TTR("Type:") + " " + p_node->get_class();
+ String tooltip = String(p_node->get_name()) + "\n" + TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path() + "\n" + TTR("Type:") + " " + p_node->get_class();
if (p_node->get_editor_description() != String()) {
tooltip += "\n\n" + p_node->get_editor_description();
}
@@ -303,7 +305,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll
} else if (p_node != get_scene_node() && p_node->get_filename() != "" && can_open_instance) {
item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
- String tooltip = TTR("Instance:") + " " + p_node->get_filename() + "\n" + TTR("Type:") + " " + p_node->get_class();
+ String tooltip = String(p_node->get_name()) + "\n" + TTR("Instance:") + " " + p_node->get_filename() + "\n" + TTR("Type:") + " " + p_node->get_class();
if (p_node->get_editor_description() != String()) {
tooltip += "\n\n" + p_node->get_editor_description();
}
@@ -315,7 +317,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll
type = p_node->get_class();
}
- String tooltip = TTR("Type:") + " " + type;
+ String tooltip = String(p_node->get_name()) + "\n" + TTR("Type:") + " " + type;
if (p_node->get_editor_description() != String()) {
tooltip += "\n\n" + p_node->get_editor_description();
}