From 6f71bc2a06eb40d5baa18145c364cc7518671329 Mon Sep 17 00:00:00 2001 From: Daniel Ting Date: Wed, 15 Jul 2020 15:56:00 -0500 Subject: [PATCH 01/20] Evenly distribute stretched Nodes in BoxContainer Add any leftover fractional pixels to an error accumulator. When the accumulator is greater or equal to one, add one pixel to the current Node's size and subtract one from the accumulator. Closes #36522 (cherry picked from commit 04ea6ec88dac45679458f8752ddc4c2ae285e103) --- scene/gui/box_container.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index 24312af1b54..39a6611ac0a 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -103,6 +103,7 @@ void BoxContainer::_resort() { has_stretched = true; bool refit_successful = true; //assume refit-test will go well + float error = 0; // Keep track of accumulated error in pixels for (int i = 0; i < get_child_count(); i++) { @@ -117,8 +118,9 @@ void BoxContainer::_resort() { if (msc.will_stretch) { //wants to stretch //let's see if it can really stretch - - int final_pixel_size = stretch_avail * c->get_stretch_ratio() / stretch_ratio_total; + float final_pixel_size = stretch_avail * c->get_stretch_ratio() / stretch_ratio_total; + // Add leftover fractional pixels to error accumulator + error += final_pixel_size - (int)final_pixel_size; if (final_pixel_size < msc.min_size) { //if available stretching area is too small for widget, //then remove it from stretching area @@ -130,6 +132,11 @@ void BoxContainer::_resort() { break; } else { msc.final_size = final_pixel_size; + // Dump accumulated error if one pixel or more + if (error >= 1) { + msc.final_size += 1; + error -= 1; + } } } } From 508388a9fdf060a92328147b1590615bfcbb501a Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 16 Jul 2020 09:40:51 +0200 Subject: [PATCH 02/20] Document an example dictionary returned by `TileSet.tile_get_shapes()` (cherry picked from commit 60bb80505f538e320e8c81a5af286347e83757a1) --- doc/classes/TileSet.xml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/classes/TileSet.xml b/doc/classes/TileSet.xml index f8a5be11717..df977adddee 100644 --- a/doc/classes/TileSet.xml +++ b/doc/classes/TileSet.xml @@ -478,7 +478,17 @@ - Returns an array of the tile's shapes. + Returns an array of dictionaries describing the tile's shapes. + [b]Dictionary structure in the array returned by this method:[/b] + [codeblock] + { + "autotile_coord": Vector2, + "one_way": bool, + "one_way_margin": int, + "shape": CollisionShape2D, + "shape_transform": Transform2D, + } + [/codeblock] From 993a421333079f68a17be7b31c3337afa396b500 Mon Sep 17 00:00:00 2001 From: "Wilson E. Alvarez" Date: Sat, 18 Jul 2020 03:11:07 -0400 Subject: [PATCH 03/20] Show errors on Object.call_deferred (cherry picked from commit 1cd02ef600575e12a02d8ec99128737d23dcc746) --- core/object.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/object.cpp b/core/object.cpp index b36f1420d2d..e07ce0d9e42 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -695,7 +695,7 @@ Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Vari StringName method = *p_args[0]; - MessageQueue::get_singleton()->push_call(get_instance_id(), method, &p_args[1], p_argcount - 1); + MessageQueue::get_singleton()->push_call(get_instance_id(), method, &p_args[1], p_argcount - 1, true); return Variant(); } From 6abaf4d0eb4cc6693caa36bb3584df379a05a4fe Mon Sep 17 00:00:00 2001 From: "Andrii Doroshenko (Xrayez)" Date: Thu, 23 Jul 2020 20:51:17 +0300 Subject: [PATCH 04/20] Skip internal scripts for breakpoints without printing an error This removes: ``` ERROR: get_breakpoints: Condition ' base.begins_with("local://") ``` while running a project with blank scripts caused by deleting or moving, or built-in scripts which are not yet saved within a scene on running a project. (cherry picked from commit 1c70a33d9c4a6641f63b067134a357b102640d66) --- editor/plugins/script_editor_plugin.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 56e1b9d2ee6..b2ebad5ea50 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1559,7 +1559,9 @@ void ScriptEditor::get_breakpoints(List *p_breakpoints) { List bpoints; se->get_breakpoints(&bpoints); String base = script->get_path(); - ERR_CONTINUE(base.begins_with("local://") || base == ""); + if (base.begins_with("local://") || base == "") { + continue; + } for (List::Element *E = bpoints.front(); E; E = E->next()) { From 4b9bb50176aa3dee7e93907ba539234d5efc88a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 25 Jul 2020 21:38:34 +0200 Subject: [PATCH 05/20] Style: Fix code format scripts compat with non-GNU Unices It's too hard to get compatibility between GNU and BSD sed, so let's just use perl oneliners. And improve it to also remove trailing tabs, not just spaces. (cherry picked from commit c71e189efd63b3875904d8fe2b8a030e68919aad) --- misc/scripts/black_format.sh | 4 +--- misc/scripts/clang_format.sh | 4 +--- misc/scripts/file_format.sh | 21 +++++++++++---------- platform/windows/godot.natvis | 6 +++--- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/misc/scripts/black_format.sh b/misc/scripts/black_format.sh index 04dfe32f606..f93e8cbc2a7 100755 --- a/misc/scripts/black_format.sh +++ b/misc/scripts/black_format.sh @@ -16,11 +16,9 @@ PY_FILES=$(find \( -path "./.git" \ black -l 120 $PY_FILES git diff > patch.patch -FILESIZE="$(stat -c%s patch.patch)" -MAXSIZE=5 # If no patch has been generated all is OK, clean up, and exit. -if (( FILESIZE < MAXSIZE )); then +if [ ! -s patch.patch ] ; then printf "Files in this commit comply with the black style rules.\n" rm -f patch.patch exit 0 diff --git a/misc/scripts/clang_format.sh b/misc/scripts/clang_format.sh index 5131f7fe333..e686305dead 100755 --- a/misc/scripts/clang_format.sh +++ b/misc/scripts/clang_format.sh @@ -39,11 +39,9 @@ while IFS= read -rd '' f; do done git diff > patch.patch -FILESIZE="$(stat -c%s patch.patch)" -MAXSIZE=5 # If no patch has been generated all is OK, clean up, and exit. -if (( FILESIZE < MAXSIZE )); then +if [ ! -s patch.patch ] ; then printf "Files in this commit comply with the clang-format style rules.\n" rm -f patch.patch exit 0 diff --git a/misc/scripts/file_format.sh b/misc/scripts/file_format.sh index 30988e51c67..773999cf0c1 100755 --- a/misc/scripts/file_format.sh +++ b/misc/scripts/file_format.sh @@ -1,7 +1,13 @@ #!/usr/bin/env bash # This script ensures proper POSIX text file formatting and a few other things. -# This is supplementary to clang-black-format.sh, but should be run before it. +# This is supplementary to clang_format.sh and black_format.sh, but should be +# run before them. + +# We need dos2unix and recode. +if [ ! -x "$(command -v dos2unix)" -o ! -x "$(command -v recode)" ]; then + printf "Install 'dos2unix' and 'recode' to use this script.\n" +fi set -uo pipefail IFS=$'\n\t' @@ -29,22 +35,17 @@ while IFS= read -rd '' f; do recode UTF-8 "$f" 2> /dev/null # Ensures that files have LF line endings. dos2unix "$f" 2> /dev/null - # Ensures that files do not contain a BOM. - sed -i '1s/^\xEF\xBB\xBF//' "$f" - # Ensures that files end with newline characters. - tail -c1 < "$f" | read -r _ || echo >> "$f"; # Remove trailing space characters. - sed -z -i 's/\x20\x0A/\x0A/g' "$f" + # -l option handles newlines conveniently and seems to also get rid of BOMs. + perl -i -ple 's/\s*$//g' "$f" # Remove the character sequence "== true" if it has a leading space. - sed -z -i 's/\x20== true//g' "$f" + perl -i -pe 's/\x20== true//g' "$f" done git diff > patch.patch -FILESIZE="$(stat -c%s patch.patch)" -MAXSIZE=5 # If no patch has been generated all is OK, clean up, and exit. -if (( FILESIZE < MAXSIZE )); then +if [ ! -s patch.patch ] ; then printf "Files in this commit comply with the formatting rules.\n" rm -f patch.patch exit 0 diff --git a/platform/windows/godot.natvis b/platform/windows/godot.natvis index 593557cc692..90f0b55d0a4 100644 --- a/platform/windows/godot.natvis +++ b/platform/windows/godot.natvis @@ -19,7 +19,7 @@ - + _data ? (_data->size_cache) : 0 @@ -62,7 +62,7 @@ {*(PoolColorArray *)_data._mem} ((String *)(_data._mem))->_cowdata._ptr,su - + _data._bool _data._int @@ -143,7 +143,7 @@ a - + (Object*)this From 5692bb4c813ef13addc4478ef36669763ae132c3 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Fri, 24 Jul 2020 12:08:01 +0100 Subject: [PATCH 06/20] Ensure Bullet HeightMapShape3D data width and depth are at least 2. (cherry picked from commit 236857c92a01473724f205eaba8fe8c0f89e3576) --- modules/bullet/shape_bullet.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp index f46db09e4a6..58695e3ea78 100644 --- a/modules/bullet/shape_bullet.cpp +++ b/modules/bullet/shape_bullet.cpp @@ -468,6 +468,9 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) { int l_width = d["width"]; int l_depth = d["depth"]; + ERR_FAIL_COND_MSG(l_width < 2, "Map width must be at least 2."); + ERR_FAIL_COND_MSG(l_depth < 2, "Map depth must be at least 2."); + // TODO This code will need adjustments if real_t is set to `double`, // because that precision is unnecessary for a heightmap and Bullet doesn't support it... From cd01cda143dd5ab71a6bad225c60e846fb06bd61 Mon Sep 17 00:00:00 2001 From: Tomasz Chabora Date: Sun, 26 Jul 2020 15:29:50 +0200 Subject: [PATCH 07/20] Fix ultra long node names (cherry picked from commit d3f2062d866ca0838549f83cd8870bbde5cda636) --- scene/main/node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 0d516ce4f09..81c7b382c7f 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1004,7 +1004,7 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) { bool unique = true; - if (p_child->data.name == StringName() || p_child->data.name.operator String()[0] == '@') { + if (p_child->data.name == StringName()) { //new unique name must be assigned unique = false; } else { From a2f034d3ab78df26090e2240ed9f3fdbf2ff975f Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Sun, 26 Jul 2020 23:00:30 +0300 Subject: [PATCH 08/20] [macOS] Refocus last key window after `DisplayServer::alert` is closed. (cherry picked from commit a05776e20da8220ea7af364bbffbd43cd4605981) --- platform/osx/os_osx.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 49c4f755d38..bfa7194a1a2 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1873,8 +1873,12 @@ void OS_OSX::alert(const String &p_alert, const String &p_title) { [window setAlertStyle:NSAlertStyleWarning]; // Display it, then release + id key_window = [[NSApplication sharedApplication] keyWindow]; [window runModal]; [window release]; + if (key_window) { + [key_window makeKeyAndOrderFront:nil]; + } } Error OS_OSX::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) { From 518f109927bf09e60f1a938f6ebaea8eb8daff28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 26 Jul 2020 23:18:05 +0200 Subject: [PATCH 09/20] Script editor: Don't open dominant script in external editor Fixes #13429. (cherry picked from commits b5f110c77eaef5d9f1b3b0c9308a4eed65f04363, 6b3f013a82557624aac49b567f4a8139848aa40e, and e016859c3b4a324ece0023c34faf9cfe9d729e21) --- editor/plugins/script_editor_plugin.cpp | 33 ++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index b2ebad5ea50..579ea389c64 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -2057,15 +2057,15 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra Ref