From c8bd1259af8aa2370597551caa96ea7b3b17cd5b Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 13 Jul 2023 20:02:39 +0200 Subject: [PATCH 001/126] Allow using floating-point bone sizes and outline widths in the 2D editor This is useful when animating pixel art sprites in the 2D editor, as a value of `1` is often too large when zoomed in. (cherry picked from commit a39190a18f4d1d2971d30147e47f51dea65f4304) --- doc/classes/EditorSettings.xml | 6 ++++-- editor/editor_settings.cpp | 4 ++-- scene/2d/skeleton_2d.cpp | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index c6744827252..3fee6d64901 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -232,14 +232,16 @@ The outline color to use for non-selected bones in the 2D skeleton editor. See also [member editors/2d/bone_selected_color]. - + The outline size in the 2D skeleton editor (in pixels). See also [member editors/2d/bone_width]. + [b]Note:[/b] Changes to this value only apply after modifying a [Bone2D] node in any way, or closing and reopening the scene. The color to use for selected bones in the 2D skeleton editor. See also [member editors/2d/bone_outline_color]. - + The bone width in the 2D skeleton editor (in pixels). See also [member editors/2d/bone_outline_size]. + [b]Note:[/b] Changes to this value only apply after modifying a [Bone2D] node in any way, or closing and reopening the scene. The grid color to use in the 2D editor. diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 8634b94858d..d9889856459 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -679,13 +679,13 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { _initial_set("editors/2d/grid_color", Color(1.0, 1.0, 1.0, 0.07)); _initial_set("editors/2d/guides_color", Color(0.6, 0.0, 0.8)); _initial_set("editors/2d/smart_snapping_line_color", Color(0.9, 0.1, 0.1)); - _initial_set("editors/2d/bone_width", 5); + EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/2d/bone_width", 5.0, "0.01,20,0.01,or_greater") _initial_set("editors/2d/bone_color1", Color(1.0, 1.0, 1.0, 0.7)); _initial_set("editors/2d/bone_color2", Color(0.6, 0.6, 0.6, 0.7)); _initial_set("editors/2d/bone_selected_color", Color(0.9, 0.45, 0.45, 0.7)); _initial_set("editors/2d/bone_ik_color", Color(0.9, 0.9, 0.45, 0.7)); _initial_set("editors/2d/bone_outline_color", Color(0.35, 0.35, 0.35, 0.5)); - _initial_set("editors/2d/bone_outline_size", 2); + EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/2d/bone_outline_size", 2.0, "0.01,8,0.01,or_greater") _initial_set("editors/2d/viewport_border_color", Color(0.4, 0.4, 1.0, 0.4)); // Panning diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp index c31b42bebaf..350fdad7d79 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/scene/2d/skeleton_2d.cpp @@ -309,8 +309,8 @@ void Bone2D::_notification(int p_what) { #ifdef TOOLS_ENABLED bool Bone2D::_editor_get_bone_shape(Vector *p_shape, Vector *p_outline_shape, Bone2D *p_other_bone) { - int bone_width = EDITOR_GET("editors/2d/bone_width"); - int bone_outline_width = EDITOR_GET("editors/2d/bone_outline_size"); + float bone_width = EDITOR_GET("editors/2d/bone_width"); + float bone_outline_width = EDITOR_GET("editors/2d/bone_outline_size"); if (!is_inside_tree()) { return false; //may have been removed From 77f6d00ad861c8db1e6d85112a58a6abd573296f Mon Sep 17 00:00:00 2001 From: Sathvik Mulukutla <72032381+DarthKitten2130@users.noreply.github.com> Date: Sat, 22 Jul 2023 22:04:38 +0530 Subject: [PATCH 002/126] Updated Deprecated Method in C# Example Size to Region (cherry picked from commit 5b3f14cc827acd2c3cc6a3c542d0eb577af4cd8c) --- doc/classes/AStarGrid2D.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/classes/AStarGrid2D.xml b/doc/classes/AStarGrid2D.xml index 418a57dfa4b..afef25643da 100644 --- a/doc/classes/AStarGrid2D.xml +++ b/doc/classes/AStarGrid2D.xml @@ -17,7 +17,7 @@ [/gdscript] [csharp] AStarGrid2D astarGrid = new AStarGrid2D(); - astarGrid.Size = new Vector2I(32, 32); + astarGrid.Region = new Rect2I(0, 0, 32, 32); astarGrid.CellSize = new Vector2I(16, 16); astarGrid.Update(); GD.Print(astarGrid.GetIdPath(Vector2I.Zero, new Vector2I(3, 4))); // prints (0, 0), (1, 1), (2, 2), (3, 3), (3, 4) From f7d1f9e25b377452d38f48b3f824bc1f21aedb6d Mon Sep 17 00:00:00 2001 From: kobewi Date: Tue, 25 Jul 2023 13:29:30 +0200 Subject: [PATCH 003/126] Improve and clarify paused Tweens (cherry picked from commit dbecf8bd1ab800d1349c6519c9199692a4a486a7) --- doc/classes/Tween.xml | 2 ++ scene/animation/tween.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml index cb255170f3e..6f7ac87a990 100644 --- a/doc/classes/Tween.xml +++ b/doc/classes/Tween.xml @@ -206,6 +206,7 @@ Pauses the tweening. The animation can be resumed by using [method play]. + [b]Note:[/b] If a Tween is paused and not bound to any node, it will exist indefinitely until manually started or invalidated. If you lose a reference to such Tween, you can retrieve it using [method SceneTree.get_processed_tweens]. @@ -273,6 +274,7 @@ Stops the tweening and resets the [Tween] to its initial state. This will not remove any appended [Tweener]s. + [b]Note:[/b] If a Tween is stopped and not bound to any node, it will exist indefinitely until manually started or invalidated. If you lose a reference to such Tween, you can retrieve it using [method SceneTree.get_processed_tweens]. diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 96e5da5a400..b32b04655d2 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -284,10 +284,6 @@ bool Tween::step(double p_delta) { return false; } - if (!running) { - return true; - } - if (is_bound) { Node *node = get_bound_node(); if (node) { @@ -299,6 +295,10 @@ bool Tween::step(double p_delta) { } } + if (!running) { + return true; + } + if (!started) { if (tweeners.is_empty()) { String tween_id; From ff6229e79466889da1935b8a79da148a65d64528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 27 Jun 2023 14:21:31 +0200 Subject: [PATCH 004/126] Support loading of translations on threads (cherry picked from commit 5301bbb3a5cbf94e38662b7ac977ba20f341c8ca) --- core/string/translation.cpp | 9 +++++++++ core/string/translation.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 3ca2e5ccdf4..02380c92bb0 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -82,6 +82,15 @@ void Translation::_set_messages(const Dictionary &p_messages) { void Translation::set_locale(const String &p_locale) { locale = TranslationServer::get_singleton()->standardize_locale(p_locale); + if (Thread::is_main_thread()) { + _notify_translation_changed_if_applies(); + } else { + // Avoid calling non-thread-safe functions here. + callable_mp(this, &Translation::_notify_translation_changed_if_applies).call_deferred(); + } +} + +void Translation::_notify_translation_changed_if_applies() { if (OS::get_singleton()->get_main_loop() && TranslationServer::get_singleton()->get_loaded_locales().has(get_locale())) { OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_TRANSLATION_CHANGED); } diff --git a/core/string/translation.h b/core/string/translation.h index 01d239f81ce..ca8b4603123 100644 --- a/core/string/translation.h +++ b/core/string/translation.h @@ -47,6 +47,8 @@ class Translation : public Resource { virtual Dictionary _get_messages() const; virtual void _set_messages(const Dictionary &p_messages); + void _notify_translation_changed_if_applies(); + protected: static void _bind_methods(); From 8fab0ff8484bcb392b24b72c758e6f64643e0017 Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Thu, 13 Jul 2023 00:06:45 +0200 Subject: [PATCH 005/126] Add detail to NavigationAgent signal descriptions Adds detail to NavigationAgent signal descriptions. (cherry picked from commit 99e70ab6efd18c0ed472041dcc2b7b3ae1c22de1) --- doc/classes/NavigationAgent2D.xml | 16 ++++++++++------ doc/classes/NavigationAgent3D.xml | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/doc/classes/NavigationAgent2D.xml b/doc/classes/NavigationAgent2D.xml index 332219be1ea..f5a52d4ddba 100644 --- a/doc/classes/NavigationAgent2D.xml +++ b/doc/classes/NavigationAgent2D.xml @@ -53,7 +53,7 @@ - Returns the reachable final position of the current navigation path in global coordinates. This can change if the navigation path is altered in any way. Because of this, it would be best to check this each frame. + Returns the reachable final position of the current navigation path in global coordinates. This position can change if the agent needs to update the navigation path which makes the agent emit the [signal path_changed] signal. @@ -84,13 +84,14 @@ - Returns true if the navigation path's final position has been reached. + Returns [code]true[/code] if the end of the currently loaded navigation path has been reached. + [b]Note:[/b] While true prefer to stop calling update functions like [method get_next_path_position]. This avoids jittering the standing agent due to calling repeated path updates. - Returns true if [member target_position] is reachable. The target position is set using [member target_position]. + Returns [code]true[/code] if [method get_final_position] is within [member target_desired_distance] of the [member target_position]. @@ -229,17 +230,20 @@ - Notifies when the final position is reached. + Emitted once per loaded path when the agent internal navigation path index reaches the last index of the loaded path array. The agent internal navigation path index can be received with [method get_current_navigation_path_index]. - Notifies when the navigation path changes. + Emitted when the agent had to update the loaded path: + - because path was previously empty. + - because navigation map has changed. + - because agent pushed further away from the current path segment than the [member path_max_distance]. - Notifies when the player-defined [member target_position] is reached. + Emitted once per loaded path when the agent's global position is the first time within [member target_desired_distance] to the [member target_position]. diff --git a/doc/classes/NavigationAgent3D.xml b/doc/classes/NavigationAgent3D.xml index 82817948aa4..9f2d78df0f3 100644 --- a/doc/classes/NavigationAgent3D.xml +++ b/doc/classes/NavigationAgent3D.xml @@ -53,7 +53,7 @@ - Returns the reachable final position of the current navigation path in global coordinates. This position can change if the navigation path is altered in any way. Because of this, it would be best to check this each frame. + Returns the reachable final position of the current navigation path in global coordinates. This position can change if the agent needs to update the navigation path which makes the agent emit the [signal path_changed] signal. @@ -84,13 +84,14 @@ - Returns true if the navigation path's final position has been reached. + Returns [code]true[/code] if the end of the currently loaded navigation path has been reached. + [b]Note:[/b] While true prefer to stop calling update functions like [method get_next_path_position]. This avoids jittering the standing agent due to calling repeated path updates. - Returns true if [member target_position] is reachable. The target position is set using [member target_position]. + Returns [code]true[/code] if [method get_final_position] is within [member target_desired_distance] of the [member target_position]. @@ -236,17 +237,20 @@ - Notifies when the final position is reached. + Emitted once per loaded path when the agent internal navigation path index reaches the last index of the loaded path array. The agent internal navigation path index can be received with [method get_current_navigation_path_index]. - Notifies when the navigation path changes. + Emitted when the agent had to update the loaded path: + - because path was previously empty. + - because navigation map has changed. + - because agent pushed further away from the current path segment than the [member path_max_distance]. - Notifies when the player-defined [member target_position] is reached. + Emitted once per loaded path when the agent's global position is the first time within [member target_desired_distance] to the [member target_position]. From 188d9040d3aafe8636964c260a4176ea0766f2b7 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Fri, 21 Jul 2023 09:50:29 +0800 Subject: [PATCH 006/126] Fix typo in ResourceImporterImageFont (cherry picked from commit 80728bdf1e5929dd779ca9adac4b66d09971c6ef) --- editor/import/resource_importer_imagefont.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/import/resource_importer_imagefont.cpp b/editor/import/resource_importer_imagefont.cpp index cbd00f0f6b5..8e04ce4c7ea 100644 --- a/editor/import/resource_importer_imagefont.cpp +++ b/editor/import/resource_importer_imagefont.cpp @@ -111,7 +111,7 @@ Error ResourceImporterImageFont::import(const String &p_source_file, const Strin int chr_width = chr_cell_width - char_margin.position.x - char_margin.size.x; int chr_height = chr_cell_height - char_margin.position.y - char_margin.size.y; - ERR_FAIL_COND_V_MSG(chr_width <= 0 || chr_height <= 0, ERR_FILE_CANT_READ, TTR("Character margin too bit.")); + ERR_FAIL_COND_V_MSG(chr_width <= 0 || chr_height <= 0, ERR_FILE_CANT_READ, TTR("Character margin too big.")); Ref font; font.instantiate(); From cf1674c423d1cb863ea623504ba9be8abc5f31c8 Mon Sep 17 00:00:00 2001 From: detomon Date: Fri, 28 Jul 2023 13:09:02 +0200 Subject: [PATCH 007/126] Initialize MSDF parameters in BaseMaterial3D with default (cherry picked from commit d275a7487d6728a490184971589f5e4854965466) --- doc/classes/BaseMaterial3D.xml | 2 +- scene/resources/material.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/classes/BaseMaterial3D.xml b/doc/classes/BaseMaterial3D.xml index f5e14e29bf2..c04de121491 100644 --- a/doc/classes/BaseMaterial3D.xml +++ b/doc/classes/BaseMaterial3D.xml @@ -269,7 +269,7 @@ Specifies the channel of the [member metallic_texture] in which the metallic information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use. - The width of the shape outine. + The width of the shape outline. The width of the range around the shape between the minimum and maximum representable signed distance. diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index a2aab8e7b45..8ebfd887700 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -2876,7 +2876,7 @@ void BaseMaterial3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "proximity_fade_distance", PROPERTY_HINT_RANGE, "0,4096,0.01,suffix:m"), "set_proximity_fade_distance", "get_proximity_fade_distance"); ADD_GROUP("MSDF", "msdf_"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "msdf_pixel_range", PROPERTY_HINT_RANGE, "1,100,1"), "set_msdf_pixel_range", "get_msdf_pixel_range"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "msdf_outline_size", PROPERTY_HINT_RANGE, "1,250,1"), "set_msdf_outline_size", "get_msdf_outline_size"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "msdf_outline_size", PROPERTY_HINT_RANGE, "0,250,1"), "set_msdf_outline_size", "get_msdf_outline_size"); ADD_GROUP("Distance Fade", "distance_fade_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "distance_fade_mode", PROPERTY_HINT_ENUM, "Disabled,PixelAlpha,PixelDither,ObjectDither"), "set_distance_fade", "get_distance_fade"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "distance_fade_min_distance", PROPERTY_HINT_RANGE, "0,4096,0.01,suffix:m"), "set_distance_fade_min_distance", "get_distance_fade_min_distance"); @@ -3064,6 +3064,9 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) : set_grow(0.0); + set_msdf_pixel_range(4.0); + set_msdf_outline_size(0.0); + set_heightmap_deep_parallax_min_layers(8); set_heightmap_deep_parallax_max_layers(32); set_heightmap_deep_parallax_flip_tangent(false); //also sets binormal From 2192c717a41e11f4722a1796dce7a976958fb518 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Wed, 12 Jul 2023 09:12:02 +0800 Subject: [PATCH 008/126] Make indentation indicators translatable (cherry picked from commit a552103531a305072bcd0b4c63994354d7de164b) --- editor/code_editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index c1a4b052c18..4c3d23aa631 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -891,7 +891,7 @@ void CodeTextEditor::_line_col_changed() { sb.append(itos(positional_column + 1).lpad(3)); sb.append(" | "); - sb.append(text_editor->is_indent_using_spaces() ? "Spaces" : "Tabs"); + sb.append(text_editor->is_indent_using_spaces() ? TTR("Spaces", "Indentation") : TTR("Tabs", "Indentation")); line_and_col_txt->set_text(sb.as_string()); From 3df5907c87e5e0afe02074e6a43b85ff41ef369e Mon Sep 17 00:00:00 2001 From: LRFLEW Date: Sat, 22 Jul 2023 01:31:02 -0500 Subject: [PATCH 009/126] Mobile: Uncomment code required for fog rendering on clear color (cherry picked from commit db17415df837f4900fed418c9c7646632ef2bba0) --- .../renderer_rd/forward_mobile/render_forward_mobile.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp index 61a940593cf..98a26ac36e1 100644 --- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp @@ -805,24 +805,20 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color clear_color.r *= bg_energy_multiplier; clear_color.g *= bg_energy_multiplier; clear_color.b *= bg_energy_multiplier; - /* - if (p_render_data->render_buffers->has_custom_data(RB_SCOPE_FOG) || environment_get_fog_enabled(p_render_data->environment)) { + if (environment_get_fog_enabled(p_render_data->environment)) { draw_sky_fog_only = true; RendererRD::MaterialStorage::get_singleton()->material_set_param(sky.sky_scene_state.fog_material, "clear_color", Variant(clear_color.srgb_to_linear())); } - */ } break; case RS::ENV_BG_COLOR: { clear_color = environment_get_bg_color(p_render_data->environment); clear_color.r *= bg_energy_multiplier; clear_color.g *= bg_energy_multiplier; clear_color.b *= bg_energy_multiplier; - /* - if (p_render_data->render_buffers->has_custom_data(RB_SCOPE_FOG) || environment_get_fog_enabled(p_render_data->environment)) { + if (environment_get_fog_enabled(p_render_data->environment)) { draw_sky_fog_only = true; RendererRD::MaterialStorage::get_singleton()->material_set_param(sky.sky_scene_state.fog_material, "clear_color", Variant(clear_color.srgb_to_linear())); } - */ } break; case RS::ENV_BG_SKY: { draw_sky = true; From 06b777fe4a84a6a996a61a47e24f99f853e01ebe Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Tue, 1 Aug 2023 23:30:21 +0800 Subject: [PATCH 010/126] Fix "a number is required" error when printing RID (cherry picked from commit 35f28407d9368b47f440a772b60d863b9e5faef5) --- scene/2d/tile_map.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 5ea751f089a..3d78e708a9a 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -2894,12 +2894,12 @@ HashMap *TileMap::get_quadrant_map(int p_layer) { } Vector2i TileMap::get_coords_for_body_rid(RID p_physics_body) { - ERR_FAIL_COND_V_MSG(!bodies_coords.has(p_physics_body), Vector2i(), vformat("No tiles for the given body RID %d.", p_physics_body)); + ERR_FAIL_COND_V_MSG(!bodies_coords.has(p_physics_body), Vector2i(), vformat("No tiles for the given body RID %d.", p_physics_body.get_id())); return bodies_coords[p_physics_body]; } int TileMap::get_layer_for_body_rid(RID p_physics_body) { - ERR_FAIL_COND_V_MSG(!bodies_layers.has(p_physics_body), int(), vformat("No tiles for the given body RID %d.", p_physics_body)); + ERR_FAIL_COND_V_MSG(!bodies_layers.has(p_physics_body), int(), vformat("No tiles for the given body RID %d.", p_physics_body.get_id())); return bodies_layers[p_physics_body]; } From 5cc85fb119f21f74de406c6b84950813be53898e Mon Sep 17 00:00:00 2001 From: Ninni Pipping Date: Sun, 25 Jun 2023 18:18:58 +0200 Subject: [PATCH 011/126] Fix indentation in script templates (cherry picked from commit 39353462acfd5c32d6ad02076dd7568ec0ab06e4) --- editor/script_create_dialog.cpp | 51 ++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 23272ab2842..a4eabf409ac 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -863,7 +863,7 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptL ScriptLanguage::ScriptTemplate script_template = ScriptLanguage::ScriptTemplate(); script_template.origin = p_origin; script_template.inherit = p_inherits; - String space_indent = " "; + int space_indent_size = 4; // Get meta delimiter String meta_delimiter; List comment_delimiters; @@ -884,30 +884,49 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptL String line = file->get_line(); if (line.begins_with(meta_prefix)) { // Store meta information - line = line.substr(meta_prefix.length(), -1); - if (line.begins_with("name")) { - script_template.name = line.substr(5, -1).strip_edges(); - } - if (line.begins_with("description")) { - script_template.description = line.substr(12, -1).strip_edges(); - } - if (line.begins_with("space-indent")) { - String indent_value = line.substr(17, -1).strip_edges(); + line = line.substr(meta_prefix.length()); + if (line.begins_with("name:")) { + script_template.name = line.substr(5).strip_edges(); + } else if (line.begins_with("description:")) { + script_template.description = line.substr(12).strip_edges(); + } else if (line.begins_with("space-indent:")) { + String indent_value = line.substr(13).strip_edges(); if (indent_value.is_valid_int()) { int indent_size = indent_value.to_int(); if (indent_size >= 0) { - space_indent = String(" ").repeat(indent_size); + space_indent_size = indent_size; + } else { + WARN_PRINT(vformat("Template meta-space-indent need to be a non-negative integer value. Found %s.", indent_value)); } } else { - WARN_PRINT(vformat("Template meta-use_space_indent need to be a valid integer value. Found %s.", indent_value)); + WARN_PRINT(vformat("Template meta-space-indent need to be a valid integer value. Found %s.", indent_value)); } } } else { - // Store script - if (space_indent != "") { - line = line.replace(space_indent, "_TS_"); + // Replace indentation. + int i = 0; + int space_count = 0; + for (; i < line.length(); i++) { + if (line[i] == '\t') { + if (space_count) { + script_template.content += String(" ").repeat(space_count); + space_count = 0; + } + script_template.content += "_TS_"; + } else if (line[i] == ' ') { + space_count++; + if (space_count == space_indent_size) { + script_template.content += "_TS_"; + space_count = 0; + } + } else { + break; + } } - script_template.content += line.replace("\t", "_TS_") + "\n"; + if (space_count) { + script_template.content += String(" ").repeat(space_count); + } + script_template.content += line.substr(i) + "\n"; } } } From 85ab2697969c24f5a540d1a0c4abcbab8299764d Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Thu, 13 Jul 2023 02:52:09 +0200 Subject: [PATCH 012/126] C#: Fix line in OpenInExternalEditor (cherry picked from commit 132a1daf1a7eac623829bd1d149f79ac95853c9a) --- editor/editor_interface.cpp | 2 +- editor/plugins/script_editor_plugin.cpp | 6 +++--- .../editor/GodotTools/GodotTools/Build/BuildOutputView.cs | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/editor/editor_interface.cpp b/editor/editor_interface.cpp index d9d9dc01c0d..8b2a51d4d22 100644 --- a/editor/editor_interface.cpp +++ b/editor/editor_interface.cpp @@ -280,7 +280,7 @@ void EditorInterface::edit_node(Node *p_node) { } void EditorInterface::edit_script(const Ref