diff options
38 files changed, 295 insertions, 234 deletions
diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml index ed4ef01012..666b10d016 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -19,13 +19,6 @@ jobs: steps: - uses: actions/checkout@v3 - # Azure repositories are not reliable, we need to prevent azure giving us packages. - - name: Make apt sources.list use the default Ubuntu repositories - run: | - sudo rm -f /etc/apt/sources.list.d/* - sudo cp -f misc/ci/sources.list /etc/apt/sources.list - sudo apt-get update - - name: Set up Java 11 uses: actions/setup-java@v3 with: diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index bfda7c72f8..46a9228616 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -74,16 +74,13 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Linux dependencies - shell: bash + # Need newer mesa for lavapipe to work properly. + - name: Linux dependencies for tests + if: ${{ matrix.proj-test }} run: | - # Azure repositories are not reliable, we need to prevent azure giving us packages. - sudo rm -f /etc/apt/sources.list.d/* - sudo cp -f misc/ci/sources.list /etc/apt/sources.list + sudo add-apt-repository ppa:kisak/kisak-mesa sudo apt-get update - # The actual dependencies - sudo apt-get install build-essential pkg-config libgl1-mesa-dev libglu-dev \ - xvfb wget unzip llvm + sudo apt-get install -qq mesa-vulkan-drivers - name: Setup Godot build cache uses: ./.github/actions/godot-cache @@ -138,16 +135,6 @@ jobs: ${{ matrix.bin }} --doctool --headless 2>&1 > /dev/null || true git diff --color --exit-code && ! git ls-files --others --exclude-standard | sed -e 's/^/New doc file missing in PR: /' | grep 'xml$' - # Download, unzip and setup SwiftShader library - # See https://github.com/godotengine/regression-test-project/releases/tag/_ci-deps for details - - name: Download SwiftShader - if: ${{ matrix.tests }} - run: | - wget https://github.com/godotengine/regression-test-project/releases/download/_ci-deps/swiftshader-ubuntu20.04-20211002.zip - unzip swiftshader-ubuntu20.04-20211002.zip - curr="$(pwd)/libvk_swiftshader.so" - sed -i "s|PATH_TO_CHANGE|$curr|" vk_swiftshader_icd.json - # Test 3.x -> 4.x project converter - name: Test project converter if: ${{ matrix.proj-conv }} @@ -155,7 +142,7 @@ jobs: mkdir converter_test cd converter_test touch project.godot - ../${{ matrix.bin }} --headless --audio-driver Dummy --validate-conversion-3to4 + ../${{ matrix.bin }} --headless --validate-conversion-3to4 cd .. rm converter_test -rf @@ -171,7 +158,7 @@ jobs: - name: Open and close editor (Vulkan) if: ${{ matrix.proj-test }} run: | - VK_ICD_FILENAMES=$(pwd)/vk_swiftshader_icd.json DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --audio-driver Dummy --editor --quit --path test_project 2>&1 | tee sanitizers_log.txt || true + xvfb-run ${{ matrix.bin }} --audio-driver Dummy --editor --quit --path test_project 2>&1 | tee sanitizers_log.txt || true misc/scripts/check_ci_log.py sanitizers_log.txt - name: Open and close editor (GLES3) @@ -184,7 +171,7 @@ jobs: - name: Run project if: ${{ matrix.proj-test }} run: | - VK_ICD_FILENAMES=$(pwd)/vk_swiftshader_icd.json DRI_PRIME=0 xvfb-run ${{ matrix.bin }} 40 --audio-driver Dummy --path test_project 2>&1 | tee sanitizers_log.txt || true + xvfb-run ${{ matrix.bin }} 40 --audio-driver Dummy --path test_project 2>&1 | tee sanitizers_log.txt || true misc/scripts/check_ci_log.py sanitizers_log.txt # Checkout godot-cpp diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index eece270dd9..a3722e19ce 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -13,17 +13,11 @@ jobs: - name: Checkout uses: actions/checkout@v3 - # Azure repositories are not reliable, we need to prevent Azure giving us packages. - - name: Make apt sources.list use the default Ubuntu repositories + - name: Install dependencies run: | - sudo rm -f /etc/apt/sources.list.d/* - sudo cp -f misc/ci/sources.list /etc/apt/sources.list wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" sudo apt-get update - - - name: Install dependencies - run: | sudo apt-get install -qq dos2unix clang-format-15 libxml2-utils python3-pip moreutils sudo update-alternatives --remove-all clang-format || true sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 100 diff --git a/core/string/string_name.cpp b/core/string/string_name.cpp index 95812fc311..df9b6b3f1a 100644 --- a/core/string/string_name.cpp +++ b/core/string/string_name.cpp @@ -226,19 +226,16 @@ StringName::StringName(const char *p_name, bool p_static) { _data = _data->next; } - if (_data) { - if (_data->refcount.ref()) { - // exists - if (p_static) { - _data->static_count.increment(); - } + if (_data && _data->refcount.ref()) { + // exists + if (p_static) { + _data->static_count.increment(); + } #ifdef DEBUG_ENABLED - if (unlikely(debug_stringname)) { - _data->debug_references++; - } -#endif + if (unlikely(debug_stringname)) { + _data->debug_references++; } - +#endif return; } @@ -288,19 +285,17 @@ StringName::StringName(const StaticCString &p_static_string, bool p_static) { _data = _data->next; } - if (_data) { - if (_data->refcount.ref()) { - // exists - if (p_static) { - _data->static_count.increment(); - } + if (_data && _data->refcount.ref()) { + // exists + if (p_static) { + _data->static_count.increment(); + } #ifdef DEBUG_ENABLED - if (unlikely(debug_stringname)) { - _data->debug_references++; - } -#endif - return; + if (unlikely(debug_stringname)) { + _data->debug_references++; } +#endif + return; } _data = memnew(_Data); @@ -348,19 +343,17 @@ StringName::StringName(const String &p_name, bool p_static) { _data = _data->next; } - if (_data) { - if (_data->refcount.ref()) { - // exists - if (p_static) { - _data->static_count.increment(); - } + if (_data && _data->refcount.ref()) { + // exists + if (p_static) { + _data->static_count.increment(); + } #ifdef DEBUG_ENABLED - if (unlikely(debug_stringname)) { - _data->debug_references++; - } -#endif - return; + if (unlikely(debug_stringname)) { + _data->debug_references++; } +#endif + return; } _data = memnew(_Data); diff --git a/core/variant/array.cpp b/core/variant/array.cpp index 2e1adb9167..d156c35343 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -225,6 +225,9 @@ void Array::assign(const Array &p_array) { _p->array = p_array._p->array; return; } + if (typed.type == Variant::OBJECT || source_typed.type == Variant::OBJECT) { + ERR_FAIL_MSG(vformat(R"(Cannot assign contents of "Array[%s]" to "Array[%s]".)", Variant::get_type_name(source_typed.type), Variant::get_type_name(typed.type))); + } Vector<Variant> array; array.resize(size); diff --git a/core/variant/container_type_validate.h b/core/variant/container_type_validate.h index 796b66dc77..ad679db9d0 100644 --- a/core/variant/container_type_validate.h +++ b/core/variant/container_type_validate.h @@ -41,34 +41,26 @@ struct ContainerTypeValidate { const char *where = "container"; _FORCE_INLINE_ bool can_reference(const ContainerTypeValidate &p_type) const { - if (type == p_type.type) { - if (type != Variant::OBJECT) { - return true; //nothing else to check - } - } else { + if (type != p_type.type) { return false; + } else if (type != Variant::OBJECT) { + return true; } - //both are object - - if ((class_name != StringName()) != (p_type.class_name != StringName())) { - return false; //both need to have class or none - } - - if (class_name != p_type.class_name) { - if (!ClassDB::is_parent_class(p_type.class_name, class_name)) { - return false; - } - } - - if (script.is_null() != p_type.script.is_null()) { + if (class_name == StringName()) { + return true; + } else if (p_type.class_name == StringName()) { + return false; + } else if (class_name != p_type.class_name && !ClassDB::is_parent_class(p_type.class_name, class_name)) { return false; } - if (script != p_type.script) { - if (!p_type.script->inherits_script(script)) { - return false; - } + if (script.is_null()) { + return true; + } else if (p_type.script.is_null()) { + return false; + } else if (script != p_type.script && !p_type.script->inherits_script(script)) { + return false; } return true; diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml index 6f4a7fc13d..55ba1f4f0c 100644 --- a/doc/classes/DisplayServer.xml +++ b/doc/classes/DisplayServer.xml @@ -1325,6 +1325,7 @@ <param index="1" name="window_id" type="int" default="0" /> <description> Sets the maximum size of the window specified by [param window_id] in pixels. Normally, the user will not be able to drag the window to make it smaller than the specified size. See also [method window_get_max_size]. + [b]Note:[/b] It's recommended to change this value using [member Window.max_size] instead. [b]Note:[/b] Using third-party tools, it is possible for users to disable window geometry restrictions and therefore bypass this limit. </description> </method> @@ -1334,6 +1335,7 @@ <param index="1" name="window_id" type="int" default="0" /> <description> Sets the minimum size for the given window to [param min_size] (in pixels). Normally, the user will not be able to drag the window to make it larger than the specified size. See also [method window_get_min_size]. + [b]Note:[/b] It's recommended to change this value using [member Window.min_size] instead. [b]Note:[/b] By default, the main window has a minimum size of [code]Vector2i(64, 64)[/code]. This prevents issues that can arise when the window is resized to a near-zero size. [b]Note:[/b] Using third-party tools, it is possible for users to disable window geometry restrictions and therefore bypass this limit. </description> @@ -1403,6 +1405,7 @@ +-------------+ +-------+ [/codeblock] See also [method window_get_position] and [method window_set_size]. + [b]Note:[/b] It's recommended to change this value using [member Window.position] instead. </description> </method> <method name="window_set_rect_changed_callback"> @@ -1419,6 +1422,7 @@ <param index="1" name="window_id" type="int" default="0" /> <description> Sets the size of the given window to [param size] (in pixels). See also [method window_get_size] and [method window_get_position]. + [b]Note:[/b] It's recommended to change this value using [member Window.size] instead. </description> </method> <method name="window_set_title"> @@ -1427,6 +1431,7 @@ <param index="1" name="window_id" type="int" default="0" /> <description> Sets the title of the given window to [param title]. + [b]Note:[/b] It's recommended to change this value using [member Window.title] instead. [b]Note:[/b] Avoid changing the window title every frame, as this can cause performance issues on certain window managers. Try to change the window title only a few times per second at most. </description> </method> @@ -1436,7 +1441,8 @@ <param index="1" name="parent_window_id" type="int" /> <description> Sets window transient parent. Transient window is will be destroyed with its transient parent and will return focus to their parent when closed. The transient window is displayed on top of a non-exclusive full-screen parent window. Transient windows can't enter full-screen mode. - Note that behavior might be different depending on the platform. + [b]Note:[/b] It's recommended to change this value using [member Window.transient] instead. + [b]Note:[/b] The behavior might be different depending on the platform. </description> </method> <method name="window_set_vsync_mode"> diff --git a/doc/classes/EditorImportPlugin.xml b/doc/classes/EditorImportPlugin.xml index 1d6a642ab2..66b61f187e 100644 --- a/doc/classes/EditorImportPlugin.xml +++ b/doc/classes/EditorImportPlugin.xml @@ -232,8 +232,9 @@ <param index="0" name="path" type="String" /> <param index="1" name="custom_options" type="Dictionary" default="{}" /> <param index="2" name="custom_importer" type="String" default="""" /> + <param index="3" name="generator_parameters" type="Variant" default="null" /> <description> - This function can only be called during the [method _import] callback and it allows manually importing resources from it. This is useful when the imported file generates external resources that require importing (as example, images). Custom parameters for the ".import" file can be passed via the [param custom_options]. Additionally, in cases where multiple importers can handle a file, the [param custom_importer] ca be specified to force a specific one. This function performs a resource import and returns immediately with a success or error code. + This function can only be called during the [method _import] callback and it allows manually importing resources from it. This is useful when the imported file generates external resources that require importing (as example, images). Custom parameters for the ".import" file can be passed via the [param custom_options]. Additionally, in cases where multiple importers can handle a file, the [param custom_importer] ca be specified to force a specific one. This function performs a resource import and returns immediately with a success or error code. [param generator_parameters] defines optional extra metadata which will be stored as [code]generator_parameters[/code] in the [code]remap[/code] section of the [code].import[/code] file, for example to store a md5 hash of the source data. </description> </method> </methods> diff --git a/doc/classes/FontFile.xml b/doc/classes/FontFile.xml index 69a7627774..a349c2b7b7 100644 --- a/doc/classes/FontFile.xml +++ b/doc/classes/FontFile.xml @@ -17,13 +17,13 @@ [codeblocks] [gdscript] var f = load("res://BarlowCondensed-Bold.ttf") - $"Label".set("custom_fonts/font", f) - $"Label".set("custom_fonts/font_size", 64) + $Label.add_theme_font_override("font", f) + $Label.add_theme_font_size_override("font_size", 64) [/gdscript] [csharp] var f = ResourceLoader.Load<FontFile>("res://BarlowCondensed-Bold.ttf"); - GetNode("Label").Set("custom_fonts/font", f); - GetNode("Label").Set("custom_font_sizes/font_size", 64); + GetNode("Label").AddThemeFontOverride("font", f); + GetNode("Label").AddThemeFontSizeOverride("font_size", 64); [/csharp] [/codeblocks] </description> @@ -88,6 +88,7 @@ <param index="0" name="cache_index" type="int" /> <param index="1" name="size" type="int" /> <description> + Returns the font descent (number of pixels below the baseline). </description> </method> <method name="get_cache_scale" qualifiers="const"> @@ -95,6 +96,7 @@ <param index="0" name="cache_index" type="int" /> <param index="1" name="size" type="int" /> <description> + Returns scaling factor of the color bitmap font. </description> </method> <method name="get_cache_underline_position" qualifiers="const"> @@ -102,6 +104,7 @@ <param index="0" name="cache_index" type="int" /> <param index="1" name="size" type="int" /> <description> + Returns pixel offset of the underline below the baseline. </description> </method> <method name="get_cache_underline_thickness" qualifiers="const"> @@ -109,6 +112,7 @@ <param index="0" name="cache_index" type="int" /> <param index="1" name="size" type="int" /> <description> + Returns thickness of the underline in pixels. </description> </method> <method name="get_embolden" qualifiers="const"> @@ -377,6 +381,7 @@ <param index="1" name="size" type="int" /> <param index="2" name="ascent" type="float" /> <description> + Sets the font ascent (number of pixels above the baseline). </description> </method> <method name="set_cache_descent"> @@ -385,6 +390,7 @@ <param index="1" name="size" type="int" /> <param index="2" name="descent" type="float" /> <description> + Sets the font descent (number of pixels below the baseline). </description> </method> <method name="set_cache_scale"> @@ -393,6 +399,7 @@ <param index="1" name="size" type="int" /> <param index="2" name="scale" type="float" /> <description> + Sets scaling factor of the color bitmap font. </description> </method> <method name="set_cache_underline_position"> @@ -401,6 +408,7 @@ <param index="1" name="size" type="int" /> <param index="2" name="underline_position" type="float" /> <description> + Sets pixel offset of the underline below the baseline. </description> </method> <method name="set_cache_underline_thickness"> @@ -409,6 +417,7 @@ <param index="1" name="size" type="int" /> <param index="2" name="underline_thickness" type="float" /> <description> + Sets thickness of the underline in pixels. </description> </method> <method name="set_embolden"> diff --git a/doc/classes/FontVariation.xml b/doc/classes/FontVariation.xml index e0fad126b9..5bc2606adb 100644 --- a/doc/classes/FontVariation.xml +++ b/doc/classes/FontVariation.xml @@ -10,16 +10,16 @@ [gdscript] var fv = FontVariation.new() fv.set_base_font(load("res://BarlowCondensed-Regular.ttf")) - fv.set_variation_embolden(1.2); - $"Label".set("custom_fonts/font", fv) - $"Label".set("custom_fonts/font_size", 64) + fv.set_variation_embolden(1.2) + $Label.add_theme_font_override("font", fv) + $Label.add_theme_font_size_override("font_size", 64) [/gdscript] [csharp] var fv = new FontVariation(); fv.SetBaseFont(ResourceLoader.Load<FontFile>("res://BarlowCondensed-Regular.ttf")); fv.SetVariationEmbolden(1.2); - GetNode("Label").Set("custom_fonts/font", fv); - GetNode("Label").Set("custom_font_sizes/font_size", 64); + GetNode("Label").AddThemeFontOverride("font", fv); + GetNode("Label").AddThemeFontSizeOverride("font_size", 64); [/csharp] [/codeblocks] </description> diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index dc594e1e9b..ec1ef8a6bc 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1900,7 +1900,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector return err; } -Error EditorFileSystem::_reimport_file(const String &p_file, const HashMap<StringName, Variant> *p_custom_options, const String &p_custom_importer) { +Error EditorFileSystem::_reimport_file(const String &p_file, const HashMap<StringName, Variant> &p_custom_options, const String &p_custom_importer, Variant *p_generator_parameters) { EditorFileSystemDirectory *fs = nullptr; int cpos = -1; bool found = _find_file(p_file, &fs, cpos); @@ -1908,46 +1908,48 @@ Error EditorFileSystem::_reimport_file(const String &p_file, const HashMap<Strin //try to obtain existing params - HashMap<StringName, Variant> params; + HashMap<StringName, Variant> params = p_custom_options; String importer_name; //empty by default though if (!p_custom_importer.is_empty()) { importer_name = p_custom_importer; } - if (p_custom_options != nullptr) { - params = *p_custom_options; - } ResourceUID::ID uid = ResourceUID::INVALID_ID; - Variant gen_params; + Variant generator_parameters; + if (p_generator_parameters) { + generator_parameters = *p_generator_parameters; + } if (FileAccess::exists(p_file + ".import")) { //use existing - if (p_custom_options == nullptr) { - Ref<ConfigFile> cf; - cf.instantiate(); - Error err = cf->load(p_file + ".import"); - if (err == OK) { - if (cf->has_section("params")) { - List<String> sk; - cf->get_section_keys("params", &sk); - for (const String &E : sk) { + Ref<ConfigFile> cf; + cf.instantiate(); + Error err = cf->load(p_file + ".import"); + if (err == OK) { + if (cf->has_section("params")) { + List<String> sk; + cf->get_section_keys("params", &sk); + for (const String &E : sk) { + if (!params.has(E)) { params[E] = cf->get_value("params", E); } } + } - if (cf->has_section("remap")) { - if (p_custom_importer.is_empty()) { - importer_name = cf->get_value("remap", "importer"); - } + if (cf->has_section("remap")) { + if (p_custom_importer.is_empty()) { + importer_name = cf->get_value("remap", "importer"); + } - if (cf->has_section_key("remap", "uid")) { - String uidt = cf->get_value("remap", "uid"); - uid = ResourceUID::get_singleton()->text_to_id(uidt); - } + if (cf->has_section_key("remap", "uid")) { + String uidt = cf->get_value("remap", "uid"); + uid = ResourceUID::get_singleton()->text_to_id(uidt); + } - if (cf->has_section_key("remap", "gen_params")) { - gen_params = cf->get_value("remap", "gen_params"); + if (!p_generator_parameters) { + if (cf->has_section_key("remap", "generator_parameters")) { + generator_parameters = cf->get_value("remap", "generator_parameters"); } } } @@ -2061,8 +2063,8 @@ Error EditorFileSystem::_reimport_file(const String &p_file, const HashMap<Strin f->store_line("metadata=" + meta.get_construct_string()); } - if (gen_params != Variant()) { - f->store_line("gen_params=" + gen_params.get_construct_string()); + if (generator_parameters != Variant()) { + f->store_line("generator_parameters=" + generator_parameters.get_construct_string()); } f->store_line(""); @@ -2164,7 +2166,7 @@ void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, HashMap } void EditorFileSystem::reimport_file_with_custom_parameters(const String &p_file, const String &p_importer, const HashMap<StringName, Variant> &p_custom_params) { - _reimport_file(p_file, &p_custom_params, p_importer); + _reimport_file(p_file, p_custom_params, p_importer); } void EditorFileSystem::_reimport_thread(uint32_t p_index, ImportThreadData *p_import_data) { @@ -2301,9 +2303,9 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { emit_signal(SNAME("resources_reimported"), reloads); } -Error EditorFileSystem::reimport_append(const String &p_file, const HashMap<StringName, Variant> &p_custom_options, const String &p_custom_importer) { +Error EditorFileSystem::reimport_append(const String &p_file, const HashMap<StringName, Variant> &p_custom_options, const String &p_custom_importer, Variant p_generator_parameters) { ERR_FAIL_COND_V_MSG(!importing, ERR_INVALID_PARAMETER, "Can only append files to import during a current reimport process."); - return _reimport_file(p_file, &p_custom_options, p_custom_importer); + return _reimport_file(p_file, p_custom_options, p_custom_importer, &p_generator_parameters); } Error EditorFileSystem::_resource_import(const String &p_path) { diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 79101813ac..0d558c84c5 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -242,7 +242,7 @@ class EditorFileSystem : public Node { void _update_extensions(); - Error _reimport_file(const String &p_file, const HashMap<StringName, Variant> *p_custom_options = nullptr, const String &p_custom_importer = String()); + Error _reimport_file(const String &p_file, const HashMap<StringName, Variant> &p_custom_options = HashMap<StringName, Variant>(), const String &p_custom_importer = String(), Variant *generator_parameters = nullptr); Error _reimport_group(const String &p_group_file, const Vector<String> &p_files); bool _test_for_reimport(const String &p_path, bool p_only_imported_files); @@ -315,7 +315,7 @@ public: EditorFileSystemDirectory *find_file(const String &p_file, int *r_index) const; void reimport_files(const Vector<String> &p_files); - Error reimport_append(const String &p_file, const HashMap<StringName, Variant> &p_custom_options, const String &p_custom_importer = String()); + Error reimport_append(const String &p_file, const HashMap<StringName, Variant> &p_custom_options, const String &p_custom_importer, Variant p_generator_parameters); void reimport_file_with_custom_parameters(const String &p_file, const String &p_importer, const HashMap<StringName, Variant> &p_custom_params); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f317c23b83..f6fe6c9f76 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -852,6 +852,18 @@ void EditorNode::_remove_plugin_from_enabled(const String &p_name) { ps->set("editor_plugins/enabled", enabled_plugins); } +void EditorNode::_plugin_over_edit(EditorPlugin *p_plugin, Object *p_object) { + if (p_object) { + editor_plugins_over->add_plugin(p_plugin); + p_plugin->make_visible(true); + p_plugin->edit(p_object); + } else { + editor_plugins_over->remove_plugin(p_plugin); + p_plugin->make_visible(false); + p_plugin->edit(nullptr); + } +} + void EditorNode::_resources_changed(const Vector<String> &p_resources) { List<Ref<Resource>> changed; @@ -2102,8 +2114,7 @@ void EditorNode::edit_item(Object *p_object, Object *p_editing_owner) { if (!item_plugins.has(plugin)) { // Remove plugins no longer used by this editing owner. to_remove.push_back(plugin); - plugin->make_visible(false); - plugin->edit(nullptr); + _plugin_over_edit(plugin, nullptr); } } @@ -2113,6 +2124,7 @@ void EditorNode::edit_item(Object *p_object, Object *p_editing_owner) { for (EditorPlugin *plugin : item_plugins) { if (active_plugins[owner_id].has(plugin)) { + plugin->edit(p_object); continue; } @@ -2127,9 +2139,7 @@ void EditorNode::edit_item(Object *p_object, Object *p_editing_owner) { } } active_plugins[owner_id].insert(plugin); - editor_plugins_over->add_plugin(plugin); - plugin->edit(p_object); - plugin->make_visible(true); + _plugin_over_edit(plugin, p_object); } } else { hide_unused_editors(p_editing_owner); @@ -2181,9 +2191,7 @@ void EditorNode::hide_unused_editors(const Object *p_editing_owner) { if (p_editing_owner) { const ObjectID id = p_editing_owner->get_instance_id(); for (EditorPlugin *plugin : active_plugins[id]) { - plugin->make_visible(false); - plugin->edit(nullptr); - editor_plugins_over->remove_plugin(plugin); + _plugin_over_edit(plugin, nullptr); } active_plugins.erase(id); } else { @@ -2194,9 +2202,7 @@ void EditorNode::hide_unused_editors(const Object *p_editing_owner) { if (!ObjectDB::get_instance(kv.key)) { to_remove.push_back(kv.key); for (EditorPlugin *plugin : kv.value) { - plugin->make_visible(false); - plugin->edit(nullptr); - editor_plugins_over->remove_plugin(plugin); + _plugin_over_edit(plugin, nullptr); } } } diff --git a/editor/editor_node.h b/editor/editor_node.h index 914dab0254..19a0e49a12 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -565,6 +565,7 @@ private: void _update_file_menu_closed(); void _remove_plugin_from_enabled(const String &p_name); + void _plugin_over_edit(EditorPlugin *p_plugin, Object *p_object); void _fs_changed(); void _resources_reimported(const Vector<String> &p_resources); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index c9eae77b53..33bba90c70 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -4593,7 +4593,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ } break; case Variant::PACKED_STRING_ARRAY: { EditorPropertyArray *editor = memnew(EditorPropertyArray); - editor->setup(Variant::PACKED_STRING_ARRAY); + editor->setup(Variant::PACKED_STRING_ARRAY, p_hint_text); return editor; } break; case Variant::PACKED_VECTOR2_ARRAY: { diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index b96ac9dbcb..24cfa7ad7b 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -574,7 +574,7 @@ void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint // The format of p_hint_string is: // subType/subTypeHint:nextSubtype ... etc. - if (array_type == Variant::ARRAY && !p_hint_string.is_empty()) { + if (!p_hint_string.is_empty()) { int hint_subtype_separator = p_hint_string.find(":"); if (hint_subtype_separator >= 0) { String subtype_string = p_hint_string.substr(0, hint_subtype_separator); diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp index 7de79881d0..7afce116b8 100644 --- a/editor/import/editor_import_plugin.cpp +++ b/editor/import/editor_import_plugin.cpp @@ -186,18 +186,18 @@ Error EditorImportPlugin::import(const String &p_source_file, const String &p_sa ERR_FAIL_V_MSG(ERR_METHOD_NOT_FOUND, "Unimplemented _import in add-on."); } -Error EditorImportPlugin::_append_import_external_resource(const String &p_file, const Dictionary &p_custom_options, const String &p_custom_importer) { +Error EditorImportPlugin::_append_import_external_resource(const String &p_file, const Dictionary &p_custom_options, const String &p_custom_importer, Variant p_generator_parameters) { HashMap<StringName, Variant> options; List<Variant> keys; p_custom_options.get_key_list(&keys); for (const Variant &K : keys) { options.insert(K, p_custom_options[K]); } - return append_import_external_resource(p_file, options, p_custom_importer); + return append_import_external_resource(p_file, options, p_custom_importer, p_generator_parameters); } -Error EditorImportPlugin::append_import_external_resource(const String &p_file, const HashMap<StringName, Variant> &p_custom_options, const String &p_custom_importer) { - return EditorFileSystem::get_singleton()->reimport_append(p_file, p_custom_options, p_custom_importer); +Error EditorImportPlugin::append_import_external_resource(const String &p_file, const HashMap<StringName, Variant> &p_custom_options, const String &p_custom_importer, Variant p_generator_parameters) { + return EditorFileSystem::get_singleton()->reimport_append(p_file, p_custom_options, p_custom_importer, p_generator_parameters); } void EditorImportPlugin::_bind_methods() { @@ -213,5 +213,5 @@ void EditorImportPlugin::_bind_methods() { GDVIRTUAL_BIND(_get_import_order) GDVIRTUAL_BIND(_get_option_visibility, "path", "option_name", "options") GDVIRTUAL_BIND(_import, "source_file", "save_path", "options", "platform_variants", "gen_files"); - ClassDB::bind_method(D_METHOD("append_import_external_resource", "path", "custom_options", "custom_importer"), &EditorImportPlugin::_append_import_external_resource, DEFVAL(Dictionary()), DEFVAL(String())); + ClassDB::bind_method(D_METHOD("append_import_external_resource", "path", "custom_options", "custom_importer", "generator_parameters"), &EditorImportPlugin::_append_import_external_resource, DEFVAL(Dictionary()), DEFVAL(String()), DEFVAL(Variant())); } diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h index 448659d4e3..fb164c7f15 100644 --- a/editor/import/editor_import_plugin.h +++ b/editor/import/editor_import_plugin.h @@ -53,7 +53,7 @@ protected: GDVIRTUAL3RC(bool, _get_option_visibility, String, StringName, Dictionary) GDVIRTUAL5RC(Error, _import, String, String, Dictionary, TypedArray<String>, TypedArray<String>) - Error _append_import_external_resource(const String &p_file, const Dictionary &p_custom_options = Dictionary(), const String &p_custom_importer = String()); + Error _append_import_external_resource(const String &p_file, const Dictionary &p_custom_options = Dictionary(), const String &p_custom_importer = String(), Variant p_generator_parameters = Variant()); public: EditorImportPlugin(); @@ -69,7 +69,7 @@ public: virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const override; virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr) override; - Error append_import_external_resource(const String &p_file, const HashMap<StringName, Variant> &p_custom_options = HashMap<StringName, Variant>(), const String &p_custom_importer = String()); + Error append_import_external_resource(const String &p_file, const HashMap<StringName, Variant> &p_custom_options = HashMap<StringName, Variant>(), const String &p_custom_importer = String(), Variant p_generator_parameters = Variant()); }; #endif // EDITOR_IMPORT_PLUGIN_H diff --git a/misc/ci/sources.list b/misc/ci/sources.list deleted file mode 100644 index 4d8f94f35c..0000000000 --- a/misc/ci/sources.list +++ /dev/null @@ -1,4 +0,0 @@ -deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse -deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse -deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse -deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index e84c79d681..cd1dcf9a78 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2471,30 +2471,27 @@ void GDScriptAnalyzer::reduce_await(GDScriptParser::AwaitNode *p_await) { return; } - GDScriptParser::DataType awaiting_type; - if (p_await->to_await->type == GDScriptParser::Node::CALL) { reduce_call(static_cast<GDScriptParser::CallNode *>(p_await->to_await), true); - awaiting_type = p_await->to_await->get_datatype(); } else { reduce_expression(p_await->to_await); } - if (p_await->to_await->is_constant) { + GDScriptParser::DataType await_type = p_await->to_await->get_datatype(); + // We cannot infer the type of the result of waiting for a signal. + if (await_type.is_hard_type() && await_type.kind == GDScriptParser::DataType::BUILTIN && await_type.builtin_type == Variant::SIGNAL) { + await_type.kind = GDScriptParser::DataType::VARIANT; + await_type.type_source = GDScriptParser::DataType::UNDETECTED; + } else if (p_await->to_await->is_constant) { p_await->is_constant = p_await->to_await->is_constant; p_await->reduced_value = p_await->to_await->reduced_value; - - awaiting_type = p_await->to_await->get_datatype(); - } else { - awaiting_type.kind = GDScriptParser::DataType::VARIANT; - awaiting_type.type_source = GDScriptParser::DataType::UNDETECTED; } - - p_await->set_datatype(awaiting_type); + await_type.is_coroutine = false; + p_await->set_datatype(await_type); #ifdef DEBUG_ENABLED - awaiting_type = p_await->to_await->get_datatype(); - if (!(awaiting_type.has_no_type() || awaiting_type.is_coroutine || awaiting_type.builtin_type == Variant::SIGNAL)) { + GDScriptParser::DataType to_await_type = p_await->to_await->get_datatype(); + if (!(to_await_type.has_no_type() || to_await_type.is_coroutine || to_await_type.builtin_type == Variant::SIGNAL)) { parser->push_warning(p_await, GDScriptWarning::REDUNDANT_AWAIT); } #endif @@ -4113,7 +4110,6 @@ void GDScriptAnalyzer::reduce_ternary_op(GDScriptParser::TernaryOpNode *p_ternar if (!is_type_compatible(true_type, false_type)) { result = false_type; if (!is_type_compatible(false_type, true_type)) { - result.type_source = GDScriptParser::DataType::UNDETECTED; result.kind = GDScriptParser::DataType::VARIANT; #ifdef DEBUG_ENABLED parser->push_warning(p_ternary_op, GDScriptWarning::INCOMPATIBLE_TERNARY); @@ -4121,6 +4117,7 @@ void GDScriptAnalyzer::reduce_ternary_op(GDScriptParser::TernaryOpNode *p_ternar } } } + result.type_source = true_type.is_hard_type() && false_type.is_hard_type() ? GDScriptParser::DataType::ANNOTATED_INFERRED : GDScriptParser::DataType::INFERRED; p_ternary_op->set_datatype(result); } diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 4e7d278aab..8cfd48b52b 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -977,7 +977,7 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, } break; case GDScriptParser::ClassNode::Member::SIGNAL: - if (p_only_functions || outer) { + if (p_only_functions || outer || p_static) { continue; } option = ScriptLanguage::CodeCompletionOption(member.signal->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location); @@ -1033,6 +1033,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, location); r_result.insert(option.display, option); } + + List<MethodInfo> signals; + scr->get_script_signal_list(&signals); + for (const MethodInfo &E : signals) { + int location = p_recursion_depth + _get_signal_location(scr->get_class_name(), E.name); + ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location); + r_result.insert(option.display, option); + } } HashMap<StringName, Variant> constants; scr->get_constants(&constants); @@ -1041,14 +1049,6 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base ScriptLanguage::CodeCompletionOption option(E.key.operator String(), ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT, location); r_result.insert(option.display, option); } - - List<MethodInfo> signals; - scr->get_script_signal_list(&signals); - for (const MethodInfo &E : signals) { - int location = p_recursion_depth + _get_signal_location(scr->get_class_name(), E.name); - ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location); - r_result.insert(option.display, option); - } } List<MethodInfo> methods; @@ -1093,14 +1093,6 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base r_result.insert(option.display, option); } - List<MethodInfo> signals; - ClassDB::get_signal_list(type, &signals); - for (const MethodInfo &E : signals) { - int location = p_recursion_depth + _get_signal_location(type, StringName(E.name)); - ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location); - r_result.insert(option.display, option); - } - if (!base_type.is_meta_type || Engine::get_singleton()->has_singleton(type)) { List<PropertyInfo> pinfo; ClassDB::get_property_list(type, &pinfo); @@ -1115,6 +1107,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, location); r_result.insert(option.display, option); } + + List<MethodInfo> signals; + ClassDB::get_signal_list(type, &signals); + for (const MethodInfo &E : signals) { + int location = p_recursion_depth + _get_signal_location(type, StringName(E.name)); + ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location); + r_result.insert(option.display, option); + } } } @@ -2031,6 +2031,7 @@ static bool _guess_identifier_type(GDScriptParser::CompletionContext &p_context, r_type.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT; r_type.type.script_path = script; r_type.type.class_type = parser->get_parser()->get_tree(); + r_type.type.is_meta_type = true; r_type.type.is_constant = false; r_type.type.kind = GDScriptParser::DataType::CLASS; r_type.value = Variant(); @@ -2142,6 +2143,7 @@ static bool _guess_identifier_type_from_base(GDScriptParser::CompletionContext & r_type.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT; r_type.type.kind = GDScriptParser::DataType::CLASS; r_type.type.class_type = member.m_class; + r_type.type.is_meta_type = true; return true; case GDScriptParser::ClassNode::Member::GROUP: return false; // No-op, but silences warnings. diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index acc3c5d079..0a1a64cb59 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -1833,10 +1833,18 @@ GDScriptParser::IfNode *GDScriptParser::parse_if(const String &p_token) { if (match(GDScriptTokenizer::Token::ELIF)) { SuiteNode *else_block = alloc_node<SuiteNode>(); + else_block->parent_function = current_function; + else_block->parent_block = current_suite; + + SuiteNode *previous_suite = current_suite; + current_suite = else_block; + IfNode *elif = parse_if("elif"); else_block->statements.push_back(elif); complete_extents(else_block); n_if->false_block = else_block; + + current_suite = previous_suite; } else if (match(GDScriptTokenizer::Token::ELSE)) { consume(GDScriptTokenizer::Token::COLON, R"(Expected ":" after "else".)"); n_if->false_block = parse_suite(R"("else" block)"); @@ -3611,7 +3619,7 @@ bool GDScriptParser::icon_annotation(const AnnotationNode *p_annotation, Node *p bool GDScriptParser::onready_annotation(const AnnotationNode *p_annotation, Node *p_node) { ERR_FAIL_COND_V_MSG(p_node->type != Node::VARIABLE, false, R"("@onready" annotation can only be applied to class variables.)"); - if (head && !ClassDB::is_parent_class(head->get_datatype().native_type, SNAME("Node"))) { + if (current_class && !ClassDB::is_parent_class(current_class->get_datatype().native_type, SNAME("Node"))) { push_error(R"("@onready" can only be used in classes that inherit "Node".)", p_annotation); } @@ -3689,6 +3697,13 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node variable->export_info.type = Variant::DICTIONARY; return true; + } else if (export_type.builtin_type == Variant::PACKED_STRING_ARRAY) { + String hint_prefix = itos(Variant::STRING) + "/" + itos(variable->export_info.hint); + variable->export_info.hint = PROPERTY_HINT_TYPE_STRING; + variable->export_info.hint_string = hint_prefix + ":" + variable->export_info.hint_string; + variable->export_info.type = Variant::PACKED_STRING_ARRAY; + + return true; } } diff --git a/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd new file mode 100644 index 0000000000..c787d9e50e --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd @@ -0,0 +1,4 @@ +signal my_signal() + +func test(): + var _a := await my_signal diff --git a/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out new file mode 100644 index 0000000000..8f8744ad7e --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Cannot infer the type of "_a" variable because the value doesn't have a set type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.gd b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.gd new file mode 100644 index 0000000000..1639bbbd52 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.gd @@ -0,0 +1,7 @@ +extends Node + +class Inner extends RefCounted: + @onready var nope = 0 + +func test(): + print("Cannot use @onready without a Node base") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.out b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.out new file mode 100644 index 0000000000..8088d28329 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +"@onready" can only be used in classes that inherit "Node". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.gd b/modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.gd new file mode 100644 index 0000000000..fac0e8756c --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.gd @@ -0,0 +1,6 @@ +func test(): + var left_hard_int := 1 + var right_weak_int = 2 + var result_hm_int := left_hard_int if true else right_weak_int + + print('not ok') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.out b/modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.out new file mode 100644 index 0000000000..71d1e2f8ae --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Cannot infer the type of "result_hm_int" variable because the value doesn't have a set type. diff --git a/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd new file mode 100644 index 0000000000..9d8cfc7f99 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd @@ -0,0 +1,15 @@ +func coroutine() -> int: + @warning_ignore("redundant_await") + await 0 + return 1 + +func not_coroutine() -> int: + return 2 + +func test(): + var a := await coroutine() + @warning_ignore("redundant_await") + var b := await not_coroutine() + @warning_ignore("redundant_await") + var c := await 3 + prints(a, b, c) diff --git a/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out new file mode 100644 index 0000000000..2920e2ce9c --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out @@ -0,0 +1,2 @@ +GDTEST_OK +1 2 3 diff --git a/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.gd b/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.gd new file mode 100644 index 0000000000..1ac03c2181 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.gd @@ -0,0 +1,7 @@ +extends RefCounted + +func test(): + print("ok") + +class Inner extends Node: + @onready var okay = 0 diff --git a/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.out b/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.out new file mode 100644 index 0000000000..1b47ed10dc --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.out @@ -0,0 +1,2 @@ +GDTEST_OK +ok diff --git a/modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.gd b/modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.gd new file mode 100644 index 0000000000..44ca5f4dd0 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.gd @@ -0,0 +1,15 @@ +func test(): + var left_hard_int := 1 + var right_hard_int := 2 + var result_hard_int := left_hard_int if true else right_hard_int + assert(result_hard_int == 1) + + @warning_ignore("inference_on_variant") + var left_hard_variant := 1 as Variant + @warning_ignore("inference_on_variant") + var right_hard_variant := 2.0 as Variant + @warning_ignore("inference_on_variant") + var result_hard_variant := left_hard_variant if true else right_hard_variant + assert(result_hard_variant == 1) + + print('ok') diff --git a/modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.out b/modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.out new file mode 100644 index 0000000000..1b47ed10dc --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.out @@ -0,0 +1,2 @@ +GDTEST_OK +ok diff --git a/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd b/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd index e1e6134fd4..092ae49d00 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd @@ -201,4 +201,10 @@ func test(): assert(typed_enums.get_typed_builtin() == TYPE_INT) + var a := A.new() + var typed_natives: Array[RefCounted] = [a] + var typed_scripts = Array(typed_natives, TYPE_OBJECT, "RefCounted", A) + assert(typed_scripts[0] == a) + + print('ok') diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 1a09b5bdcc..bd3ee1881f 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -54,6 +54,9 @@ #include "modules/modules_enabled.gen.h" // For csg, gridmap. +#ifdef TOOLS_ENABLED +#include "editor/editor_file_system.h" +#endif #ifdef MODULE_CSG_ENABLED #include "modules/csg/csg_shape.h" #endif // MODULE_CSG_ENABLED @@ -3232,54 +3235,38 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> p_state, const String &p_base_p p_state->source_images.push_back(Ref<Image>()); } else { Error err = OK; - bool must_import = false; + bool must_import = true; + Vector<uint8_t> img_data = img->get_data(); + Dictionary generator_parameters; String file_path = p_state->get_base_path() + "/" + p_state->filename.get_basename() + "_" + img->get_name() + ".png"; - if (!FileAccess::exists(file_path + ".import")) { + if (FileAccess::exists(file_path + ".import")) { Ref<ConfigFile> config; config.instantiate(); - config->set_value("remap", "importer", "texture"); - config->set_value("remap", "type", "Texture2D"); - // Currently, it will likely use project defaults of Detect 3D, so textures will be reimported again. - if (!config->has_section_key("params", "mipmaps/generate")) { - config->set_value("params", "mipmaps/generate", true); + config->load(file_path + ".import"); + if (config->has_section_key("remap", "generator_parameters")) { + generator_parameters = (Dictionary)config->get_value("remap", "generator_parameters"); } - - if (ProjectSettings::get_singleton()->has_setting("importer_defaults/texture")) { - //use defaults if exist - Dictionary importer_defaults = GLOBAL_GET("importer_defaults/texture"); - List<Variant> importer_def_keys; - importer_defaults.get_key_list(&importer_def_keys); - for (const Variant &key : importer_def_keys) { - if (!config->has_section_key("params", (String)key)) { - config->set_value("params", (String)key, importer_defaults[key]); - } - } + if (!generator_parameters.has("md5")) { + must_import = false; // Didn't come form a gltf document; don't overwrite. } - err = config->save(file_path + ".import"); - ERR_FAIL_COND_V(err != OK, err); - must_import = true; - } - Vector<uint8_t> png_buffer = img->save_png_to_buffer(); - if (ResourceLoader::exists(file_path)) { - Ref<FileAccess> file = FileAccess::open(file_path, FileAccess::READ, &err); - if (err == OK && file.is_valid()) { - Vector<uint8_t> orig_png_buffer = file->get_buffer(file->get_length()); - if (png_buffer != orig_png_buffer) { - must_import = true; - } + String existing_md5 = generator_parameters["md5"]; + unsigned char md5_hash[16]; + CryptoCore::md5(img_data.ptr(), img_data.size(), md5_hash); + String new_md5 = String::hex_encode_buffer(md5_hash, 16); + generator_parameters["md5"] = new_md5; + if (new_md5 == existing_md5) { + must_import = false; } - } else { - must_import = true; } if (must_import) { - Ref<FileAccess> file = FileAccess::open(file_path, FileAccess::WRITE, &err); + err = img->save_png(file_path); ERR_FAIL_COND_V(err != OK, err); - ERR_FAIL_COND_V(file.is_null(), FAILED); - file->store_buffer(png_buffer); - file->flush(); - file.unref(); // ResourceLoader::import will crash if not is_editor_hint(), so this case is protected above and will fall through to uncompressed. - ResourceLoader::import(file_path); + HashMap<StringName, Variant> custom_options; + custom_options[SNAME("mipmaps/generate")] = true; + // Will only use project settings defaults if custom_importer is empty. + EditorFileSystem::get_singleton()->update_file(file_path); + EditorFileSystem::get_singleton()->reimport_append(file_path, custom_options, String(), generator_parameters); } Ref<Texture2D> saved_image = ResourceLoader::load(file_path, "Texture2D"); if (saved_image.is_valid()) { diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 2e25d685d6..8087ac6250 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -857,7 +857,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double HashMap<int, TrackNodeCache::PlayingAudioStreamInfo> &map = aa->playing_streams; // Find stream. int idx = -1; - if (p_seeked) { + if (p_seeked || p_started) { idx = a->track_find_key(i, p_time); // Discard previous stream when seeking. if (map.has(idx)) { @@ -866,12 +866,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double } } else { List<int> to_play; - if (p_started) { - int first_key = a->track_find_key(i, p_prev_time, Animation::FIND_MODE_EXACT); - if (first_key >= 0) { - to_play.push_back(first_key); - } - } + a->track_get_key_indices_in_range(i, p_time, p_delta, &to_play, p_looped_flag); if (to_play.size()) { idx = to_play.back()->get(); @@ -888,6 +883,10 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double double end_ofs = a->audio_track_get_key_end_offset(i, idx); double len = stream->get_length(); + if (p_seeked || p_started) { + start_ofs += p_time - a->track_get_key_time(i, idx); + } + if (aa->object->call(SNAME("get_stream")) != aa->audio_stream) { aa->object->call(SNAME("set_stream"), aa->audio_stream); aa->audio_stream_playback.unref(); @@ -1286,6 +1285,8 @@ void AnimationPlayer::_animation_process(double p_delta) { _animation_update_transforms(); if (end_reached) { + _clear_audio_streams(); + _stop_playing_caches(false); if (queued.size()) { String old = playback.assigned; play(queued.front()->get()); diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index dd5bf31c66..8b1a5e3aac 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -1546,6 +1546,10 @@ void AnimationTree::_process_graph(double p_delta) { double end_ofs = a->audio_track_get_key_end_offset(i, idx); double len = stream->get_length(); + if (seeked) { + start_ofs += time - a->track_get_key_time(i, idx); + } + if (t->object->call(SNAME("get_stream")) != t->audio_stream) { t->object->call(SNAME("set_stream"), t->audio_stream); t->audio_stream_playback.unref(); |