diff options
author | Larry Tran <lawrence.c.tran@outlook.com> | 2022-08-05 18:47:20 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-05 18:47:20 -0500 |
commit | 2ea4baae0a0dbf76b9b2fe71bdcb72601ddab868 (patch) | |
tree | 622c070fce3229f151f941d74324b31f5f5ac3fd | |
parent | e029e664548dcada4d07a7e2f85cad18bb2feebe (diff) | |
parent | c80540f9a20b45d107b9bed1e749571a83492337 (diff) |
Merge branch 'master' into bugfix-ios-export
34 files changed, 1201 insertions, 1278 deletions
diff --git a/SConstruct b/SConstruct index 0fd9326e1c..17184c2e36 100644 --- a/SConstruct +++ b/SConstruct @@ -337,21 +337,27 @@ for path in module_search_paths: # Add module options. for name, path in modules_detected.items(): + sys.path.insert(0, path) + import config + if env_base["modules_enabled_by_default"]: enabled = True - - sys.path.insert(0, path) - import config - try: enabled = config.is_enabled() except AttributeError: pass - sys.path.remove(path) - sys.modules.pop("config") else: enabled = False + # Add module-specific options. + try: + for opt in config.get_opts(selected_platform): + opts.Add(opt) + except AttributeError: + pass + + sys.path.remove(path) + sys.modules.pop("config") opts.Add(BoolVariable("module_" + name + "_enabled", "Enable module '%s'" % (name,), enabled)) methods.write_modules(modules_detected) diff --git a/core/io/dir_access.h b/core/io/dir_access.h index 22017efaa3..d5318dfb45 100644 --- a/core/io/dir_access.h +++ b/core/io/dir_access.h @@ -108,6 +108,8 @@ public: if (da->remove(p_path) != OK) { ERR_FAIL_MSG("Cannot remove file or directory: " + p_path); } + } else { + ERR_FAIL_MSG("Cannot remove non-existent file or directory: " + p_path); } } diff --git a/core/variant/variant_op.cpp b/core/variant/variant_op.cpp index 669e18b5f7..6cca7955ae 100644 --- a/core/variant/variant_op.cpp +++ b/core/variant/variant_op.cpp @@ -341,6 +341,8 @@ void Variant::_register_variant_operators() { register_op<OperatorEvaluatorXFormInv<Vector3, Vector3, Transform3D>>(Variant::OP_MULTIPLY, Variant::VECTOR3, Variant::TRANSFORM3D); register_op<OperatorEvaluatorXForm<::AABB, Transform3D, ::AABB>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::AABB); register_op<OperatorEvaluatorXFormInv<::AABB, ::AABB, Transform3D>>(Variant::OP_MULTIPLY, Variant::AABB, Variant::TRANSFORM3D); + register_op<OperatorEvaluatorXForm<Plane, Transform3D, Plane>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::PLANE); + register_op<OperatorEvaluatorXFormInv<Plane, Plane, Transform3D>>(Variant::OP_MULTIPLY, Variant::PLANE, Variant::TRANSFORM3D); register_op<OperatorEvaluatorXForm<Vector<Vector3>, Transform3D, Vector<Vector3>>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::PACKED_VECTOR3_ARRAY); register_op<OperatorEvaluatorXFormInv<Vector<Vector3>, Vector<Vector3>, Transform3D>>(Variant::OP_MULTIPLY, Variant::PACKED_VECTOR3_ARRAY, Variant::TRANSFORM3D); diff --git a/doc/classes/Camera3D.xml b/doc/classes/Camera3D.xml index 5595abc02a..643351efc0 100644 --- a/doc/classes/Camera3D.xml +++ b/doc/classes/Camera3D.xml @@ -144,7 +144,7 @@ # This code block is part of a script that inherits from Node3D. # `control` is a reference to a node inheriting from Control. control.visible = not get_viewport().get_camera_3d().is_position_behind(global_transform.origin) - control.rect_position = get_viewport().get_camera_3d().unproject_position(global_transform.origin) + control.position = get_viewport().get_camera_3d().unproject_position(global_transform.origin) [/codeblock] </description> </method> diff --git a/doc/classes/Plane.xml b/doc/classes/Plane.xml index 32eb71f1c7..df9d25902b 100644 --- a/doc/classes/Plane.xml +++ b/doc/classes/Plane.xml @@ -179,6 +179,13 @@ [b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable. </description> </operator> + <operator name="operator *"> + <return type="Plane" /> + <argument index="0" name="right" type="Transform3D" /> + <description> + Inversely transforms (multiplies) the [Plane] by the given [Transform3D] transformation matrix. + </description> + </operator> <operator name="operator =="> <return type="bool" /> <argument index="0" name="right" type="Plane" /> diff --git a/doc/classes/Transform3D.xml b/doc/classes/Transform3D.xml index 9b673701ae..cefc74867c 100644 --- a/doc/classes/Transform3D.xml +++ b/doc/classes/Transform3D.xml @@ -216,6 +216,13 @@ </description> </operator> <operator name="operator *"> + <return type="Plane" /> + <argument index="0" name="right" type="Plane" /> + <description> + Transforms (multiplies) the [Plane] by the given [Transform3D] transformation matrix. + </description> + </operator> + <operator name="operator *"> <return type="Transform3D" /> <argument index="0" name="right" type="Transform3D" /> <description> diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 45e114b130..89daa2af64 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -2004,6 +2004,9 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T } RID id = texture_owner.make_rid(texture); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif if (p_data.size()) { for (uint32_t i = 0; i < image_create_info.arrayLayers; i++) { @@ -2133,6 +2136,9 @@ RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID texture.owner = p_with_texture; RID id = texture_owner.make_rid(texture); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif _add_dependency(id, p_with_texture); return id; @@ -2252,6 +2258,9 @@ RID RenderingDeviceVulkan::texture_create_from_extension(TextureType p_type, Dat } RID id = texture_owner.make_rid(texture); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif return id; } @@ -2377,6 +2386,9 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p texture.owner = p_with_texture; RID id = texture_owner.make_rid(texture); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif _add_dependency(id, p_with_texture); return id; @@ -4082,7 +4094,11 @@ RID RenderingDeviceVulkan::framebuffer_create_empty(const Size2i &p_size, Textur framebuffer.size = p_size; framebuffer.view_count = 1; - return framebuffer_owner.make_rid(framebuffer); + RID id = framebuffer_owner.make_rid(framebuffer); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif + return id; } RID RenderingDeviceVulkan::framebuffer_create(const Vector<RID> &p_texture_attachments, FramebufferFormatID p_format_check, uint32_t p_view_count) { @@ -4162,6 +4178,9 @@ RID RenderingDeviceVulkan::framebuffer_create_multipass(const Vector<RID> &p_tex framebuffer.view_count = p_view_count; RID id = framebuffer_owner.make_rid(framebuffer); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif for (int i = 0; i < p_texture_attachments.size(); i++) { if (p_texture_attachments[i].is_valid()) { @@ -4239,7 +4258,11 @@ RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) { VkResult res = vkCreateSampler(device, &sampler_create_info, nullptr, &sampler); ERR_FAIL_COND_V_MSG(res, RID(), "vkCreateSampler failed with error " + itos(res) + "."); - return sampler_owner.make_rid(sampler); + RID id = sampler_owner.make_rid(sampler); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif + return id; } /**********************/ @@ -4268,7 +4291,11 @@ RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const Vec _buffer_memory_barrier(buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_INPUT_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT, false); } - return vertex_buffer_owner.make_rid(buffer); + RID id = vertex_buffer_owner.make_rid(buffer); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif + return id; } // Internally reference counted, this ID is warranted to be unique for the same description, but needs to be freed as many times as it was allocated @@ -4429,7 +4456,11 @@ RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBuff _buffer_update(&index_buffer, 0, r, data_size); _buffer_memory_barrier(index_buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_INPUT_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_INDEX_READ_BIT, false); } - return index_buffer_owner.make_rid(index_buffer); + RID id = index_buffer_owner.make_rid(index_buffer); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif + return id; } RID RenderingDeviceVulkan::index_array_create(RID p_index_buffer, uint32_t p_index_offset, uint32_t p_index_count) { @@ -5526,7 +5557,11 @@ RID RenderingDeviceVulkan::shader_create_from_bytecode(const Vector<uint8_t> &p_ ERR_FAIL_V_MSG(RID(), error_text); } - return shader_owner.make_rid(shader); + RID id = shader_owner.make_rid(shader); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif + return id; } uint32_t RenderingDeviceVulkan::shader_get_vertex_input_attribute_mask(RID p_shader) { @@ -5559,7 +5594,11 @@ RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const Ve _buffer_update(&buffer, 0, r, data_size); _buffer_memory_barrier(buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_UNIFORM_READ_BIT, false); } - return uniform_buffer_owner.make_rid(buffer); + RID id = uniform_buffer_owner.make_rid(buffer); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif + return id; } RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data, uint32_t p_usage) { @@ -5630,7 +5669,11 @@ RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataF } //allocate the view - return texture_buffer_owner.make_rid(texture_buffer); + RID id = texture_buffer_owner.make_rid(texture_buffer); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif + return id; } RenderingDeviceVulkan::DescriptorPool *RenderingDeviceVulkan::_descriptor_pool_allocate(const DescriptorPoolKey &p_key) { @@ -6209,6 +6252,9 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, uniform_set.shader_id = p_shader; RID id = uniform_set_owner.make_rid(uniform_set); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif //add dependencies _add_dependency(id, p_shader); for (uint32_t i = 0; i < uniform_count; i++) { @@ -6831,6 +6877,9 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma #endif //create ID to associate with this pipeline RID id = render_pipeline_owner.make_rid(pipeline); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif //now add all the dependencies _add_dependency(id, p_shader); return id; @@ -6920,6 +6969,9 @@ RID RenderingDeviceVulkan::compute_pipeline_create(RID p_shader, const Vector<Pi //create ID to associate with this pipeline RID id = compute_pipeline_owner.make_rid(pipeline); +#ifdef DEV_ENABLED + set_resource_name(id, "RID:" + itos(id.get_id())); +#endif //now add all the dependencies _add_dependency(id, p_shader); return id; diff --git a/editor/editor_build_profile.cpp b/editor/editor_build_profile.cpp index d093ab518e..0f0ab4a339 100644 --- a/editor/editor_build_profile.cpp +++ b/editor/editor_build_profile.cpp @@ -46,19 +46,68 @@ const char *EditorBuildProfile::build_option_identifiers[BUILD_OPTION_MAX] = { "disable_3d_physics", "disable_navigation", "openxr", + "rendering_device", // FIXME: there's no scons option to disable rendering device "opengl3", "vulkan", + "module_text_server_fb_enabled", + "module_text_server_adv_enabled", + "module_freetype_enabled", + "brotli", + "graphite", + "module_msdfgen_enabled" +}; + +const bool EditorBuildProfile::build_option_disabled_by_default[BUILD_OPTION_MAX] = { + // This maps to SCons build options. + false, // 3D + false, // PHYSICS_2D + false, // PHYSICS_3D + false, // NAVIGATION + false, // XR + false, // RENDERING_DEVICE + false, // OPENGL + false, // VULKAN + true, // TEXT_SERVER_FALLBACK + false, // TEXT_SERVER_COMPLEX + false, // DYNAMIC_FONTS + false, // WOFF2_FONTS + false, // GRPAHITE_FONTS + false, // MSDFGEN }; const bool EditorBuildProfile::build_option_disable_values[BUILD_OPTION_MAX] = { // This maps to SCons build options. - true, - true, - true, - true, - false, - false, - false + true, // 3D + true, // PHYSICS_2D + true, // PHYSICS_3D + true, // NAVIGATION + false, // XR + false, // RENDERING_DEVICE + false, // OPENGL + false, // VULKAN + false, // TEXT_SERVER_FALLBACK + false, // TEXT_SERVER_COMPLEX + false, // DYNAMIC_FONTS + false, // WOFF2_FONTS + false, // GRPAHITE_FONTS + false, // MSDFGEN +}; + +const EditorBuildProfile::BuildOptionCategory EditorBuildProfile::build_option_category[BUILD_OPTION_MAX] = { + BUILD_OPTION_CATEGORY_GENERAL, // 3D + BUILD_OPTION_CATEGORY_GENERAL, // PHYSICS_2D + BUILD_OPTION_CATEGORY_GENERAL, // PHYSICS_3D + BUILD_OPTION_CATEGORY_GENERAL, // NAVIGATION + BUILD_OPTION_CATEGORY_GENERAL, // XR + BUILD_OPTION_CATEGORY_GENERAL, // RENDERING_DEVICE + BUILD_OPTION_CATEGORY_GENERAL, // OPENGL + BUILD_OPTION_CATEGORY_GENERAL, // VULKAN + BUILD_OPTION_CATEGORY_TEXT_SERVER, // TEXT_SERVER_FALLBACK + BUILD_OPTION_CATEGORY_TEXT_SERVER, // TEXT_SERVER_COMPLEX + BUILD_OPTION_CATEGORY_TEXT_SERVER, // DYNAMIC_FONTS + BUILD_OPTION_CATEGORY_TEXT_SERVER, // WOFF2_FONTS + BUILD_OPTION_CATEGORY_TEXT_SERVER, // GRPAHITE_FONTS + BUILD_OPTION_CATEGORY_TEXT_SERVER, // MSDFGEN }; void EditorBuildProfile::set_disable_class(const StringName &p_class, bool p_disabled) { @@ -127,6 +176,12 @@ String EditorBuildProfile::get_build_option_name(BuildOption p_build_option) { TTRC("RenderingDevice"), TTRC("OpenGL"), TTRC("Vulkan"), + TTRC("Text Server: Fallback"), + TTRC("Text Server: Advanced"), + TTRC("TTF, OTF, Type 1, WOFF1 Fonts"), + TTRC("WOFF2 Fonts"), + TTRC("SIL Graphite Fonts"), + TTRC("Multi-channel Signed Distance Field Font Rendering"), }; return TTRGET(build_option_names[p_build_option]); } @@ -143,11 +198,33 @@ String EditorBuildProfile::get_build_option_description(BuildOption p_build_opti TTRC("RenderingDevice based rendering (if disabled, the OpenGL back-end is required)."), TTRC("OpenGL back-end (if disabled, the RenderingDevice back-end is required)."), TTRC("Vulkan back-end of RenderingDevice."), + TTRC("Fallback implementation of Text Server\nSupports basic text layouts."), + TTRC("Text Server implementation powered by ICU and HarfBuzz libraries.\nSupports complex text layouts, BiDi, and contextual OpenType font features."), + TTRC("TrueType, OpenType, Type 1, and WOFF1 font format support using FreeType library (if disabled, WOFF2 support is also disabled)."), + TTRC("WOFF2 font format support using FreeType and Brotli libraries."), + TTRC("SIL Graphite smart font technology support (supported by Advanced Text Server only)."), + TTRC("Multi-channel signed distance field font rendering support using msdfgen library (pre-rendered MSDF fonts can be used even if this option disabled)."), }; return TTRGET(build_option_descriptions[p_build_option]); } +EditorBuildProfile::BuildOptionCategory EditorBuildProfile::get_build_option_category(BuildOption p_build_option) { + ERR_FAIL_INDEX_V(p_build_option, BUILD_OPTION_MAX, BUILD_OPTION_CATEGORY_GENERAL); + return build_option_category[p_build_option]; +} + +String EditorBuildProfile::get_build_option_category_name(BuildOptionCategory p_build_option_category) { + ERR_FAIL_INDEX_V(p_build_option_category, BUILD_OPTION_CATEGORY_MAX, String()); + + const char *build_option_subcategories[BUILD_OPTION_CATEGORY_MAX]{ + TTRC("General Features:"), + TTRC("Text Rendering and Font Options:"), + }; + + return TTRGET(build_option_subcategories[p_build_option_category]); +} + Error EditorBuildProfile::save_to_file(const String &p_path) { Dictionary data; data["type"] = "build_profile"; @@ -160,8 +237,12 @@ Error EditorBuildProfile::save_to_file(const String &p_path) { Dictionary dis_build_options; for (int i = 0; i < BUILD_OPTION_MAX; i++) { - if (build_options_disabled[i]) { - dis_build_options[build_option_identifiers[i]] = build_option_disable_values[i]; + if (build_options_disabled[i] != build_option_disabled_by_default[i]) { + if (build_options_disabled[i]) { + dis_build_options[build_option_identifiers[i]] = build_option_disable_values[i]; + } else { + dis_build_options[build_option_identifiers[i]] = !build_option_disable_values[i]; + } } } @@ -211,7 +292,7 @@ Error EditorBuildProfile::load_from_file(const String &p_path) { } for (int i = 0; i < BUILD_OPTION_MAX; i++) { - build_options_disabled[i] = false; + build_options_disabled[i] = build_option_disabled_by_default[i]; } if (data.has("disabled_build_options")) { @@ -259,10 +340,24 @@ void EditorBuildProfile::_bind_methods() { BIND_ENUM_CONSTANT(BUILD_OPTION_RENDERING_DEVICE); BIND_ENUM_CONSTANT(BUILD_OPTION_OPENGL); BIND_ENUM_CONSTANT(BUILD_OPTION_VULKAN); + BIND_ENUM_CONSTANT(BUILD_OPTION_TEXT_SERVER_FALLBACK); + BIND_ENUM_CONSTANT(BUILD_OPTION_TEXT_SERVER_ADVANCED); + BIND_ENUM_CONSTANT(BUILD_OPTION_DYNAMIC_FONTS); + BIND_ENUM_CONSTANT(BUILD_OPTION_WOFF2_FONTS); + BIND_ENUM_CONSTANT(BUILD_OPTION_GRPAHITE_FONTS); + BIND_ENUM_CONSTANT(BUILD_OPTION_MSDFGEN); BIND_ENUM_CONSTANT(BUILD_OPTION_MAX); + + BIND_ENUM_CONSTANT(BUILD_OPTION_CATEGORY_GENERAL); + BIND_ENUM_CONSTANT(BUILD_OPTION_CATEGORY_TEXT_SERVER); + BIND_ENUM_CONSTANT(BUILD_OPTION_CATEGORY_MAX); } -EditorBuildProfile::EditorBuildProfile() {} +EditorBuildProfile::EditorBuildProfile() { + for (int i = 0; i < EditorBuildProfile::BUILD_OPTION_MAX; i++) { + build_options_disabled[i] = build_option_disabled_by_default[i]; + } +} ////////////////////////// @@ -633,11 +728,18 @@ void EditorBuildProfileManager::_update_edited_profile() { TreeItem *root = class_list->create_item(); - TreeItem *build_options = class_list->create_item(root); - build_options->set_text(0, TTR("General Features:")); + HashMap<EditorBuildProfile::BuildOptionCategory, TreeItem *> subcats; + for (int i = 0; i < EditorBuildProfile::BUILD_OPTION_CATEGORY_MAX; i++) { + TreeItem *build_cat; + build_cat = class_list->create_item(root); + + build_cat->set_text(0, EditorBuildProfile::get_build_option_category_name(EditorBuildProfile::BuildOptionCategory(i))); + subcats[EditorBuildProfile::BuildOptionCategory(i)] = build_cat; + } + for (int i = 0; i < EditorBuildProfile::BUILD_OPTION_MAX; i++) { TreeItem *build_option; - build_option = class_list->create_item(build_options); + build_option = class_list->create_item(subcats[EditorBuildProfile::get_build_option_category(EditorBuildProfile::BuildOption(i))]); build_option->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); build_option->set_text(0, EditorBuildProfile::get_build_option_name(EditorBuildProfile::BuildOption(i))); diff --git a/editor/editor_build_profile.h b/editor/editor_build_profile.h index bb6494b8c9..606c415429 100644 --- a/editor/editor_build_profile.h +++ b/editor/editor_build_profile.h @@ -53,7 +53,19 @@ public: BUILD_OPTION_RENDERING_DEVICE, BUILD_OPTION_OPENGL, BUILD_OPTION_VULKAN, - BUILD_OPTION_MAX + BUILD_OPTION_TEXT_SERVER_FALLBACK, + BUILD_OPTION_TEXT_SERVER_ADVANCED, + BUILD_OPTION_DYNAMIC_FONTS, + BUILD_OPTION_WOFF2_FONTS, + BUILD_OPTION_GRPAHITE_FONTS, + BUILD_OPTION_MSDFGEN, + BUILD_OPTION_MAX, + }; + + enum BuildOptionCategory { + BUILD_OPTION_CATEGORY_GENERAL, + BUILD_OPTION_CATEGORY_TEXT_SERVER, + BUILD_OPTION_CATEGORY_MAX, }; private: @@ -65,7 +77,9 @@ private: bool build_options_disabled[BUILD_OPTION_MAX] = {}; static const char *build_option_identifiers[BUILD_OPTION_MAX]; + static const bool build_option_disabled_by_default[BUILD_OPTION_MAX]; static const bool build_option_disable_values[BUILD_OPTION_MAX]; + static const BuildOptionCategory build_option_category[BUILD_OPTION_MAX]; String _get_build_option_name(BuildOption p_build_option) { return get_build_option_name(p_build_option); } @@ -93,11 +107,15 @@ public: static String get_build_option_name(BuildOption p_build_option); static String get_build_option_description(BuildOption p_build_option); static bool get_build_option_disable_value(BuildOption p_build_option); + static BuildOptionCategory get_build_option_category(BuildOption p_build_option); + + static String get_build_option_category_name(BuildOptionCategory p_build_option_category); EditorBuildProfile(); }; VARIANT_ENUM_CAST(EditorBuildProfile::BuildOption) +VARIANT_ENUM_CAST(EditorBuildProfile::BuildOptionCategory) class EditorFileSystemDirectory; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 8caa38737c..e7946f56da 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -141,6 +141,7 @@ #include "editor/plugins/bone_map_editor_plugin.h" #include "editor/plugins/camera_3d_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h" +#include "editor/plugins/cast_2d_editor_plugin.h" #include "editor/plugins/collision_polygon_2d_editor_plugin.h" #include "editor/plugins/collision_shape_2d_editor_plugin.h" #include "editor/plugins/control_editor_plugin.h" @@ -176,7 +177,6 @@ #include "editor/plugins/physical_bone_3d_editor_plugin.h" #include "editor/plugins/polygon_2d_editor_plugin.h" #include "editor/plugins/polygon_3d_editor_plugin.h" -#include "editor/plugins/ray_cast_2d_editor_plugin.h" #include "editor/plugins/resource_preloader_editor_plugin.h" #include "editor/plugins/root_motion_editor_plugin.h" #include "editor/plugins/script_editor_plugin.h" @@ -7192,7 +7192,7 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(NavigationPolygonEditorPlugin)); add_editor_plugin(memnew(Path2DEditorPlugin)); add_editor_plugin(memnew(Polygon2DEditorPlugin)); - add_editor_plugin(memnew(RayCast2DEditorPlugin)); + add_editor_plugin(memnew(Cast2DEditorPlugin)); add_editor_plugin(memnew(Skeleton2DEditorPlugin)); add_editor_plugin(memnew(Sprite2DEditorPlugin)); add_editor_plugin(memnew(TilesEditorPlugin)); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 5298b818e7..c713fe3df0 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -133,6 +133,11 @@ void EditorPropertyMultilineText::_text_changed() { void EditorPropertyMultilineText::_open_big_text() { if (!big_text_dialog) { big_text = memnew(TextEdit); + if (expression) { + big_text->set_syntax_highlighter(text->get_syntax_highlighter()); + big_text->add_theme_font_override("font", get_theme_font(SNAME("expression"), SNAME("EditorFonts"))); + big_text->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts"))); + } big_text->connect("text_changed", callable_mp(this, &EditorPropertyMultilineText::_big_text_changed)); big_text->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); big_text_dialog = memnew(AcceptDialog); @@ -162,12 +167,24 @@ void EditorPropertyMultilineText::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { Ref<Texture2D> df = get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons")); open_big_text->set_icon(df); - Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); - int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); - text->set_custom_minimum_size(Vector2(0, font->get_height(font_size) * 6)); - text->add_theme_font_override("font", get_theme_font("expression", "EditorFonts")); - text->add_theme_font_size_override("font_size", get_theme_font_size("expression_size", "EditorFonts")); + Ref<Font> font; + int font_size; + if (expression) { + font = get_theme_font(SNAME("expression"), SNAME("EditorFonts")); + font_size = get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts")); + + text->add_theme_font_override("font", font); + text->add_theme_font_size_override("font_size", font_size); + if (big_text) { + big_text->add_theme_font_override("font", font); + big_text->add_theme_font_size_override("font_size", font_size); + } + } else { + font = get_theme_font(SNAME("font"), SNAME("TextEdit")); + font_size = get_theme_font_size(SNAME("font_size"), SNAME("TextEdit")); + } + text->set_custom_minimum_size(Vector2(0, font->get_height(font_size) * 6)); } break; } } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 6f8d33532f..ac85eb5e1b 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -4237,13 +4237,13 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, Control *ctrl = Object::cast_to<Control>(canvas_item); if (key_pos) { - te->insert_node_value_key(ctrl, "rect_position", ctrl->get_position(), p_on_existing); + te->insert_node_value_key(ctrl, "position", ctrl->get_position(), p_on_existing); } if (key_rot) { - te->insert_node_value_key(ctrl, "rect_rotation", ctrl->get_rotation(), p_on_existing); + te->insert_node_value_key(ctrl, "rotation", ctrl->get_rotation(), p_on_existing); } if (key_scale) { - te->insert_node_value_key(ctrl, "rect_size", ctrl->get_size(), p_on_existing); + te->insert_node_value_key(ctrl, "size", ctrl->get_size(), p_on_existing); } } } diff --git a/editor/plugins/ray_cast_2d_editor_plugin.cpp b/editor/plugins/cast_2d_editor_plugin.cpp index 6f247a37ef..18c38e7ab8 100644 --- a/editor/plugins/ray_cast_2d_editor_plugin.cpp +++ b/editor/plugins/cast_2d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* ray_cast_2d_editor_plugin.cpp */ +/* cast_2d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,30 +28,32 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "ray_cast_2d_editor_plugin.h" +#include "cast_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" #include "editor/editor_node.h" +#include "scene/2d/ray_cast_2d.h" +#include "scene/2d/shape_cast_2d.h" -void RayCast2DEditor::_notification(int p_what) { +void Cast2DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - get_tree()->connect("node_removed", callable_mp(this, &RayCast2DEditor::_node_removed)); + get_tree()->connect("node_removed", callable_mp(this, &Cast2DEditor::_node_removed)); } break; case NOTIFICATION_EXIT_TREE: { - get_tree()->disconnect("node_removed", callable_mp(this, &RayCast2DEditor::_node_removed)); + get_tree()->disconnect("node_removed", callable_mp(this, &Cast2DEditor::_node_removed)); } break; } } -void RayCast2DEditor::_node_removed(Node *p_node) { +void Cast2DEditor::_node_removed(Node *p_node) { if (p_node == node) { node = nullptr; } } -bool RayCast2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { +bool Cast2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { if (!node || !node->is_visible_in_tree()) { return false; } @@ -60,10 +62,12 @@ bool RayCast2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) { + Vector2 target_position = node->get("target_position"); + if (mb->is_pressed()) { - if (xform.xform(node->get_target_position()).distance_to(mb->get_position()) < 8) { + if (xform.xform(target_position).distance_to(mb->get_position()) < 8) { pressed = true; - original_target_position = node->get_target_position(); + original_target_position = target_position; return true; } else { @@ -73,9 +77,9 @@ bool RayCast2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { } } else if (pressed) { undo_redo->create_action(TTR("Set target_position")); - undo_redo->add_do_method(node, "set_target_position", node->get_target_position()); + undo_redo->add_do_property(node, "target_position", target_position); undo_redo->add_do_method(canvas_item_editor, "update_viewport"); - undo_redo->add_undo_method(node, "set_target_position", original_target_position); + undo_redo->add_undo_property(node, "target_position", original_target_position); undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); @@ -90,7 +94,7 @@ bool RayCast2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { Vector2 point = canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mm->get_position())); point = node->get_global_transform().affine_inverse().xform(point); - node->set_target_position(point); + node->set("target_position", point); canvas_item_editor->update_viewport(); node->notify_property_list_changed(); @@ -100,7 +104,7 @@ bool RayCast2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return false; } -void RayCast2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { +void Cast2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { if (!node || !node->is_visible_in_tree()) { return; } @@ -108,16 +112,16 @@ void RayCast2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); const Ref<Texture2D> handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); - p_overlay->draw_texture(handle, gt.xform(node->get_target_position()) - handle->get_size() / 2); + p_overlay->draw_texture(handle, gt.xform((Vector2)node->get("target_position")) - handle->get_size() / 2); } -void RayCast2DEditor::edit(Node *p_node) { +void Cast2DEditor::edit(Node2D *p_node) { if (!canvas_item_editor) { canvas_item_editor = CanvasItemEditor::get_singleton(); } - if (p_node) { - node = Object::cast_to<RayCast2D>(p_node); + if (Object::cast_to<RayCast2D>(p_node) || Object::cast_to<ShapeCast2D>(p_node)) { + node = p_node; } else { node = nullptr; } @@ -125,27 +129,27 @@ void RayCast2DEditor::edit(Node *p_node) { canvas_item_editor->update_viewport(); } -RayCast2DEditor::RayCast2DEditor() { +Cast2DEditor::Cast2DEditor() { undo_redo = EditorNode::get_singleton()->get_undo_redo(); } /////////////////////// -void RayCast2DEditorPlugin::edit(Object *p_object) { - ray_cast_2d_editor->edit(Object::cast_to<RayCast2D>(p_object)); +void Cast2DEditorPlugin::edit(Object *p_object) { + cast_2d_editor->edit(Object::cast_to<Node2D>(p_object)); } -bool RayCast2DEditorPlugin::handles(Object *p_object) const { - return Object::cast_to<RayCast2D>(p_object) != nullptr; +bool Cast2DEditorPlugin::handles(Object *p_object) const { + return Object::cast_to<RayCast2D>(p_object) != nullptr || Object::cast_to<ShapeCast2D>(p_object) != nullptr; } -void RayCast2DEditorPlugin::make_visible(bool p_visible) { +void Cast2DEditorPlugin::make_visible(bool p_visible) { if (!p_visible) { edit(nullptr); } } -RayCast2DEditorPlugin::RayCast2DEditorPlugin() { - ray_cast_2d_editor = memnew(RayCast2DEditor); - EditorNode::get_singleton()->get_gui_base()->add_child(ray_cast_2d_editor); +Cast2DEditorPlugin::Cast2DEditorPlugin() { + cast_2d_editor = memnew(Cast2DEditor); + EditorNode::get_singleton()->get_gui_base()->add_child(cast_2d_editor); } diff --git a/editor/plugins/ray_cast_2d_editor_plugin.h b/editor/plugins/cast_2d_editor_plugin.h index 74628da0e4..d9c0cc4a06 100644 --- a/editor/plugins/ray_cast_2d_editor_plugin.h +++ b/editor/plugins/cast_2d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* ray_cast_2d_editor_plugin.h */ +/* cast_2d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,20 +28,20 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RAY_CAST_2D_EDITOR_PLUGIN_H -#define RAY_CAST_2D_EDITOR_PLUGIN_H +#ifndef CAST_2D_EDITOR_PLUGIN_H +#define CAST_2D_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" -#include "scene/2d/ray_cast_2d.h" +#include "scene/2d/node_2d.h" class CanvasItemEditor; -class RayCast2DEditor : public Control { - GDCLASS(RayCast2DEditor, Control); +class Cast2DEditor : public Control { + GDCLASS(Cast2DEditor, Control); UndoRedo *undo_redo = nullptr; CanvasItemEditor *canvas_item_editor = nullptr; - RayCast2D *node; + Node2D *node; bool pressed = false; Point2 original_target_position; @@ -53,27 +53,27 @@ protected: public: bool forward_canvas_gui_input(const Ref<InputEvent> &p_event); void forward_canvas_draw_over_viewport(Control *p_overlay); - void edit(Node *p_node); + void edit(Node2D *p_node); - RayCast2DEditor(); + Cast2DEditor(); }; -class RayCast2DEditorPlugin : public EditorPlugin { - GDCLASS(RayCast2DEditorPlugin, EditorPlugin); +class Cast2DEditorPlugin : public EditorPlugin { + GDCLASS(Cast2DEditorPlugin, EditorPlugin); - RayCast2DEditor *ray_cast_2d_editor = nullptr; + Cast2DEditor *cast_2d_editor = nullptr; public: - virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) override { return ray_cast_2d_editor->forward_canvas_gui_input(p_event); } - virtual void forward_canvas_draw_over_viewport(Control *p_overlay) override { ray_cast_2d_editor->forward_canvas_draw_over_viewport(p_overlay); } + virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) override { return cast_2d_editor->forward_canvas_gui_input(p_event); } + virtual void forward_canvas_draw_over_viewport(Control *p_overlay) override { cast_2d_editor->forward_canvas_draw_over_viewport(p_overlay); } - virtual String get_name() const override { return "RayCast2D"; } + virtual String get_name() const override { return "Cast2D"; } bool has_main_screen() const override { return false; } virtual void edit(Object *p_object) override; virtual bool handles(Object *p_object) const override; virtual void make_visible(bool visible) override; - RayCast2DEditorPlugin(); + Cast2DEditorPlugin(); }; -#endif // RAY_CAST_2D_EDITOR_PLUGIN_H +#endif // CAST_2D_EDITOR_PLUGIN_H diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index bbf5ffa462..c53ac59c11 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1853,10 +1853,12 @@ void ScriptEditor::_update_members_overview_visibility() { if (members_overview_enabled && se->show_members_overview()) { members_overview_alphabeta_sort_button->set_visible(true); + filter_methods->set_visible(true); members_overview->set_visible(true); overview_vbox->set_visible(true); } else { members_overview_alphabeta_sort_button->set_visible(false); + filter_methods->set_visible(false); members_overview->set_visible(false); overview_vbox->set_visible(false); } @@ -1911,6 +1913,7 @@ void ScriptEditor::_update_help_overview_visibility() { if (help_overview_enabled) { members_overview_alphabeta_sort_button->set_visible(false); + filter_methods->set_visible(false); help_overview->set_visible(true); overview_vbox->set_visible(true); filename->set_text(se->get_name()); diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index b564195911..8de8f94f87 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -42,7 +42,8 @@ const int ERROR_CODE = 77; #include "core/templates/hash_map.h" #include "core/templates/list.h" -const int CONVERSION_MAX_FILE_SIZE = 1024 * 1024 * 4; // 4 MB +const uint64_t CONVERSION_MAX_FILE_SIZE_MB = 4; +const uint64_t CONVERSION_MAX_FILE_SIZE = 1024 * 1024 * CONVERSION_MAX_FILE_SIZE_MB; static const char *enum_renames[][2] = { //// constants @@ -255,6 +256,7 @@ static const char *gdscript_function_renames[][2] = { { "damped_spring_joint_create", "joint_make_damped_spring" }, // PhysicsServer2D { "damped_string_joint_get_param", "damped_spring_joint_get_param" }, // PhysicsServer2D { "damped_string_joint_set_param", "damped_spring_joint_set_param" }, // PhysicsServer2D + { "dectime", "move_toward" }, // GDScript, Math functions { "delete_char_at_cursor", "delete_char_at_caret" }, // LineEdit { "deselect_items", "deselect_all" }, // FileDialog { "disable_plugin", "_disable_plugin" }, // EditorPlugin @@ -427,6 +429,7 @@ static const char *gdscript_function_renames[][2] = { { "joint_create_slider", "joint_make_slider" }, // PhysicsServer3D { "line_intersects_line_2d", "line_intersects_line" }, // Geometry2D { "load_from_globals", "load_from_project_settings" }, // InputMap + { "load_interactive", "load_threaded_request" }, // ResourceLoader - load_threaded_request is alternative, but is used differently { "make_convex_from_brothers", "make_convex_from_siblings" }, // CollisionShape3D { "make_visible", "_make_visible" }, // EditorPlugin { "merge_polygons_2d", "merge_polygons" }, // Geometry2D @@ -484,6 +487,7 @@ static const char *gdscript_function_renames[][2] = { { "set_enabled_focus_mode", "set_focus_mode" }, // BaseButton { "set_endian_swap", "set_big_endian" }, // File { "set_expand_to_text_length", "set_expand_to_text_length_enabled" }, // LineEdit + { "set_filename", "set_scene_file_path" }, // Node, WARNING, this may be used in a lot of other places { "set_focus_neighbour", "set_focus_neighbor" }, // Control { "set_frame_color", "set_color" }, // ColorRect { "set_global_rate_scale", "set_playback_speed_scale" }, // AudioServer @@ -975,6 +979,7 @@ static const char *gdscript_properties_renames[][2] = { // { "wrap_enabled", "wrap_mode" }, // TextEdit // { "zfar", "far" }, // Camera3D // { "znear", "near" }, // Camera3D + // { "filename", "scene_file_path" }, // Node { "as_normalmap", "as_normal_map" }, // NoiseTexture { "bbcode_text", "text" }, // RichTextLabel { "caret_moving_by_right_click", "caret_move_on_right_click" }, // TextEdit @@ -1595,12 +1600,33 @@ static const char *colors_renames[][2] = { { nullptr, nullptr }, }; +class ProjectConverter3To4::RegExContainer { +public: + RegEx reg_is_empty = RegEx("\\bempty\\("); + RegEx reg_super = RegEx("([\t ])\\.([a-zA-Z_])"); + RegEx reg_json_to = RegEx("\\bto_json\\b"); + RegEx reg_json_parse = RegEx("([\t]{0,})([^\n]+)parse_json\\(([^\n]+)"); + RegEx reg_json_non_new = RegEx("([\t]{0,})([^\n]+)JSON\\.parse\\(([^\n]+)"); + RegEx reg_export = RegEx("export\\(([a-zA-Z0-9_]+)\\)[ ]+var[ ]+([a-zA-Z0-9_]+)"); + RegEx reg_export_advanced = RegEx("export\\(([^)^\n]+)\\)[ ]+var[ ]+([a-zA-Z0-9_]+)([^\n]+)"); + RegEx reg_setget_setget = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+([a-zA-Z0-9_]+)[ \t]*,[ \t]*([a-zA-Z0-9_]+)"); + RegEx reg_setget_set = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+([a-zA-Z0-9_]+)[ \t]*[,]*[^a-z^A-Z^0-9^_]*$"); + RegEx reg_setget_get = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+,[ \t]*([a-zA-Z0-9_]+)[ \t]*$"); + RegEx reg_join = RegEx("([\\(\\)a-zA-Z0-9_]+)\\.join\\(([^\n^\\)]+)\\)"); + RegEx reg_mixed_tab_space = RegEx("([\t]+)([ ]+)"); + RegEx reg_image_lock = RegEx("([a-zA-Z0-9_\\.]+)\\.lock\\(\\)"); + RegEx reg_image_unlock = RegEx("([a-zA-Z0-9_\\.]+)\\.unlock\\(\\)"); + RegEx reg_os_fullscreen = RegEx("OS.window_fullscreen[= ]+([^#^\n]+)"); +}; + // Function responsible for converting project int ProjectConverter3To4::convert() { print_line("Starting conversion."); + RegExContainer reg_container = RegExContainer(); + ERR_FAIL_COND_V_MSG(!test_array_names(), ERROR_CODE, "Cannot start converting due to problems with data in arrays."); - ERR_FAIL_COND_V_MSG(!test_conversion(), ERROR_CODE, "Cannot start converting due to problems with converting arrays."); + ERR_FAIL_COND_V_MSG(!test_conversion(reg_container), ERROR_CODE, "Cannot start converting due to problems with converting arrays."); // Checking if folder contains valid Godot 3 project. // Project cannot be converted 2 times @@ -1640,7 +1666,7 @@ int ProjectConverter3To4::convert() { uint64_t start_time = Time::get_singleton()->get_ticks_msec(); if (file_name.ends_with(".shader")) { - DirAccess::remove_file_or_error(file_name); + DirAccess::remove_file_or_error(file_name.trim_prefix("res://")); file_name = file_name.replace(".shader", ".gdshader"); } @@ -1653,7 +1679,7 @@ int ProjectConverter3To4::convert() { rename_enums(file_content); // Require to additional rename rename_common(gdscript_function_renames, file_content); - rename_gdscript_functions(file_content); // Require to additional rename + rename_gdscript_functions(file_content, reg_container, false); // Require to additional rename rename_common(project_settings_renames, file_content); rename_gdscript_keywords(file_content); @@ -1671,7 +1697,7 @@ int ProjectConverter3To4::convert() { rename_enums(file_content); // Require to additional rename rename_common(gdscript_function_renames, file_content); - rename_gdscript_functions(file_content); // Require to additional rename + rename_gdscript_functions(file_content, reg_container, true); // Require to additional rename rename_common(project_settings_renames, file_content); rename_gdscript_keywords(file_content); @@ -1708,7 +1734,7 @@ int ProjectConverter3To4::convert() { continue; } } else { - reason.append(" ERROR: File has exceeded the maximum size allowed - 500 KB"); + reason.append(" ERROR: File has exceeded the maximum size allowed - " + itos(CONVERSION_MAX_FILE_SIZE_MB) + " MB"); is_ignored = true; } @@ -1718,7 +1744,7 @@ int ProjectConverter3To4::convert() { uint64_t hash_after = file_content.hash64(); // Don't need to save file without any changes // Save if this is a shader, because it was renamed - if (hash_before != hash_after || file_name.find(".gdshader") != -1) { + if (hash_before != hash_after || file_name.ends_with(".gdshader")) { converted_files++; Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::WRITE); @@ -1742,8 +1768,10 @@ int ProjectConverter3To4::convert() { int ProjectConverter3To4::validate_conversion() { print_line("Starting checking if project conversion can be done."); + RegExContainer reg_container = RegExContainer(); + ERR_FAIL_COND_V_MSG(!test_array_names(), ERROR_CODE, "Cannot start converting due to problems with data in arrays."); - ERR_FAIL_COND_V_MSG(!test_conversion(), ERROR_CODE, "Cannot start converting due to problems with converting arrays."); + ERR_FAIL_COND_V_MSG(!test_conversion(reg_container), ERROR_CODE, "Cannot start converting due to problems with converting arrays."); // Checking if folder contains valid Godot 3 project. // Project cannot be converted 2 times @@ -1784,7 +1812,7 @@ int ProjectConverter3To4::validate_conversion() { bool is_ignored = false; uint64_t start_time = Time::get_singleton()->get_ticks_msec(); - if (file_name.ends_with(".sader")) { + if (file_name.ends_with(".shader")) { reason.append("\tFile extension will be renamed from `shader` to `gdshader`."); } @@ -1796,7 +1824,7 @@ int ProjectConverter3To4::validate_conversion() { changed_elements.append_array(check_for_rename_enums(file_content)); changed_elements.append_array(check_for_rename_common(gdscript_function_renames, file_content)); - changed_elements.append_array(check_for_rename_gdscript_functions(file_content)); + changed_elements.append_array(check_for_rename_gdscript_functions(file_content, reg_container, false)); changed_elements.append_array(check_for_rename_common(project_settings_renames, file_content)); changed_elements.append_array(check_for_rename_gdscript_keywords(file_content)); @@ -1814,7 +1842,7 @@ int ProjectConverter3To4::validate_conversion() { changed_elements.append_array(check_for_rename_enums(file_content)); changed_elements.append_array(check_for_rename_common(gdscript_function_renames, file_content)); - changed_elements.append_array(check_for_rename_gdscript_functions(file_content)); + changed_elements.append_array(check_for_rename_gdscript_functions(file_content, reg_container, true)); changed_elements.append_array(check_for_rename_common(project_settings_renames, file_content)); changed_elements.append_array(check_for_rename_gdscript_keywords(file_content)); @@ -1851,7 +1879,7 @@ int ProjectConverter3To4::validate_conversion() { continue; } } else { - reason.append("\tERROR: File has exceeded the maximum size allowed - 500 KB"); + reason.append("\tERROR: File has exceeded the maximum size allowed - " + itos(CONVERSION_MAX_FILE_SIZE_MB) + " MB"); is_ignored = true; } @@ -1928,6 +1956,17 @@ bool ProjectConverter3To4::test_conversion_single_additional(String name, String return true; } +bool ProjectConverter3To4::test_conversion_single_additional_builtin(String name, String expected, void (ProjectConverter3To4::*func)(String &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin_script) { + String got = name; + (this->*func)(got, reg_container, builtin_script); + if (expected != got) { + ERR_PRINT("Failed to convert " + what + " `" + name + "` to `" + expected + "`, got instead `" + got + "`"); + return false; + } + + return true; +} + bool ProjectConverter3To4::test_conversion_single_normal(String name, String expected, const char *array[][2], String what) { String got = name; rename_common(array, got); @@ -1939,7 +1978,7 @@ bool ProjectConverter3To4::test_conversion_single_normal(String name, String exp } // Validate if conversions are proper -bool ProjectConverter3To4::test_conversion() { +bool ProjectConverter3To4::test_conversion(const RegExContainer ®_container) { bool valid = true; valid = valid & test_conversion_single_normal("Spatial", "Node3D", class_renames, "class"); @@ -1970,26 +2009,28 @@ bool ProjectConverter3To4::test_conversion() { valid = valid & test_conversion_single_additional("(Disconnect(A,B,C) != OK):", "(Disconnect(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp"); valid = valid & test_conversion_single_additional("(IsConnected(A,B,C) != OK):", "(IsConnected(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename"); - valid = valid & test_conversion_single_additional("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\"display/window/size/fullscreen\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); + valid = valid & test_conversion_single_additional_builtin("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\"display/window/size/fullscreen\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\\\"display/window/size/fullscreen\\\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, true); + valid = valid & test_conversion_single_additional_builtin("OS.get_window_safe_area()", "DisplayServer.get_display_safe_area()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional("\tvar aa = roman(r.move_and_slide( a, b, c, d, e, f )) # Roman", "\tr.set_motion_velocity(a)\n\tr.set_up_direction(b)\n\tr.set_floor_stop_on_slope_enabled(c)\n\tr.set_max_slides(d)\n\tr.set_floor_max_angle(e)\n\t# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `f`\n\tvar aa = roman(r.move_and_slide()) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("\tvar aa = roman(r.move_and_slide_with_snap( a, g, b, c, d, e, f )) # Roman", "\tr.set_motion_velocity(a)\n\t# TODOConverter40 looks that snap in Godot 4.0 is float, not vector like in Godot 3 - previous value `g`\n\tr.set_up_direction(b)\n\tr.set_floor_stop_on_slope_enabled(c)\n\tr.set_max_slides(d)\n\tr.set_floor_max_angle(e)\n\t# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `f`\n\tvar aa = roman(r.move_and_slide()) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); + valid = valid & test_conversion_single_additional_builtin("\tvar aa = roman(r.move_and_slide( a, b, c, d, e, f )) # Roman", "\tr.set_motion_velocity(a)\n\tr.set_up_direction(b)\n\tr.set_floor_stop_on_slope_enabled(c)\n\tr.set_max_slides(d)\n\tr.set_floor_max_angle(e)\n\t# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `f`\n\tvar aa = roman(r.move_and_slide()) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("\tvar aa = roman(r.move_and_slide_with_snap( a, g, b, c, d, e, f )) # Roman", "\tr.set_motion_velocity(a)\n\t# TODOConverter40 looks that snap in Godot 4.0 is float, not vector like in Godot 3 - previous value `g`\n\tr.set_up_direction(b)\n\tr.set_floor_stop_on_slope_enabled(c)\n\tr.set_max_slides(d)\n\tr.set_floor_max_angle(e)\n\t# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `f`\n\tvar aa = roman(r.move_and_slide()) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional("list_dir_begin( a , b )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("list_dir_begin( a )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("list_dir_begin( )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); + valid = valid & test_conversion_single_additional_builtin("list_dir_begin( a , b )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("list_dir_begin( a )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("list_dir_begin( )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional("sort_custom( a , b )", "sort_custom(Callable(a,b))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); + valid = valid & test_conversion_single_additional_builtin("sort_custom( a , b )", "sort_custom(Callable(a,b))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional("func c(var a, var b)", "func c(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); + valid = valid & test_conversion_single_additional_builtin("func c(var a, var b)", "func c(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional("draw_line(1, 2, 3, 4, 5)", "draw_line(1,2,3,4)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); + valid = valid & test_conversion_single_additional_builtin("draw_line(1, 2, 3, 4, 5)", "draw_line(1,2,3,4)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional("\timage.lock()", "\tfalse # image.lock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("\timage.unlock()", "\tfalse # image.unlock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("\troman.image.unlock()", "\tfalse # roman.image.unlock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("\tmtx.lock()", "\tmtx.lock()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("\tmutex.unlock()", "\tmutex.unlock()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); + valid = valid & test_conversion_single_additional_builtin("\timage.lock()", "\tfalse # image.lock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("\timage.unlock()", "\tfalse # image.unlock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("\troman.image.unlock()", "\tfalse # roman.image.unlock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("\tmtx.lock()", "\tmtx.lock()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("\tmutex.unlock()", "\tmutex.unlock()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); valid = valid & test_conversion_single_additional("\nonready", "\n@onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); valid = valid & test_conversion_single_additional("onready", "@onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); @@ -2002,82 +2043,86 @@ bool ProjectConverter3To4::test_conversion() { valid = valid & test_conversion_single_additional("tool", "@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); valid = valid & test_conversion_single_additional("\n tool", "\n tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); valid = valid & test_conversion_single_additional("\n\ntool", "\n\n@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\nmaster func", "\n\n@rpc(any) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\npuppet func", "\n\n@rpc(auth) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\nremote func", "\n\n@rpc(any) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\nremotesync func", "\n\n@rpc(any,sync) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\nsync func", "\n\n@rpc(any,sync) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\npuppetsync func", "\n\n@rpc(auth,sync) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\nmastersync func", "\n\n@rpc(any,sync) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - - valid = valid & test_conversion_single_additional("var size : Vector2 = Vector2() setget set_function , get_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Copy here content of get_function\n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("var size : Vector2 = Vector2() setget set_function , ", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Non existent get function \n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("var size : Vector2 = Vector2() setget set_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Non existent get function \n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("var size : Vector2 = Vector2() setget , get_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Copy here content of get_function \n set(mod_value):\n mod_value # TODOConverter40 Non existent set function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("get_node(@", "get_node(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("yield(this, \"timeout\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional(" Transform.xform(Vector3(a,b,c)) ", " Transform * Vector3(a,b,c) ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional(" Transform.xform_inv(Vector3(a,b,c)) ", " Vector3(a,b,c) * Transform ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("export(float) var lifetime = 3.0", "export var lifetime: float = 3.0", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("export(String, 'AnonymousPro', 'CourierPrime') var _font_name = 'AnonymousPro'", "export var _font_name = 'AnonymousPro' # (String, 'AnonymousPro', 'CourierPrime')", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); // TODO, this is only a workaround - valid = valid & test_conversion_single_additional("export(PackedScene) var mob_scene", "export var mob_scene: PackedScene", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("var d = parse_json(roman(sfs))", "var test_json_conv = JSON.new()\ntest_json_conv.parse(roman(sfs))\nvar d = test_json_conv.get_data()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("to_json( AA ) szon", "JSON.new().stringify( AA ) szon", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("s to_json", "s JSON.new().stringify", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("AF to_json2", "AF to_json2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("var rr = JSON.parse(a)", "var test_json_conv = JSON.new()\ntest_json_conv.parse(a)\nvar rr = test_json_conv.get_data()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("empty()", "is_empty()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional(".empty", ".empty", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional(").roman(", ").roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("\t.roman(", "\tsuper.roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional(" .roman(", " super.roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional(".1", ".1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional(" .1", " .1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("'.'", "'.'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("'.a'", "'.a'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("\t._input(_event)", "\tsuper._input(_event)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("(start(A,B,C,D,E,F,G) != OK):", "(start(A,Callable(B,C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("(connect(A,B,C,D,E,F,G) != OK):", "(connect(A,Callable(B,C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("(connect(A,B,C) != OK):", "(connect(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("disconnect(A,B,C) != OK):", "disconnect(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("is_connected(A,B,C) != OK):", "is_connected(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("is_connected(A,B,C))", "is_connected(A,Callable(B,C)))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("func _init(p_x:int)->void:", "func _init(p_x:int):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("q_PackedDataContainer._iter_init(variable1)", "q_PackedDataContainer._iter_init(variable1)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("assert(speed < 20, str(randi()%10))", "assert(speed < 20) #,str(randi()%10))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("assert(speed < 2)", "assert(speed < 2)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("assert(false, \"Missing type --\" + str(argument.type) + \"--, needs to be added to project\")", "assert(false) #,\"Missing type --\" + str(argument.type) + \"--, needs to be added to project\")", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("create_from_image(aa, bb)", "create_from_image(aa) #,bb", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("q_ImageTexture.create_from_image(variable1, variable2)", "q_ImageTexture.create_from_image(variable1) #,variable2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("set_cell_item(a, b, c, d ,e) # AA", "set_cell_item( Vector3(a,b,c) ,d,e) # AA", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("set_cell_item(a, b)", "set_cell_item(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("get_cell_item_orientation(a, b,c)", "get_cell_item_orientation(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("get_cell_item(a, b,c)", "get_cell_item(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("map_to_world(a, b,c)", "map_to_world(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("PackedStringArray(req_godot).join('.')", "'.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("=PackedStringArray(req_godot).join('.')", "='.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional(" aa", " aa", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("\taa", "\taa", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("\t aa", "\taa", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional(" \taa", " \taa", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("apply_force(position, impulse)", "apply_force(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); - valid = valid & test_conversion_single_additional("apply_impulse(position, impulse)", "apply_impulse(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); + valid = valid & test_conversion_single_additional("\n\nremote func", "\n\n@rpc(any_peer) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); + valid = valid & test_conversion_single_additional("\n\nremotesync func", "\n\n@rpc(any_peer, call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); + valid = valid & test_conversion_single_additional("\n\npuppet func", "\n\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); + valid = valid & test_conversion_single_additional("\n\npuppetsync func", "\n\n@rpc(call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); + valid = valid & test_conversion_single_additional("\n\nmaster func", "\n\nThe master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); + valid = valid & test_conversion_single_additional("\n\nmastersync func", "\n\nThe master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n@rpc(call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); + + valid = valid & test_conversion_single_additional_builtin("var size : Vector2 = Vector2() setget set_function , get_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Copy here content of get_function\n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("var size : Vector2 = Vector2() setget set_function , ", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Non existent get function \n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("var size : Vector2 = Vector2() setget set_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Non existent get function \n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("var size : Vector2 = Vector2() setget , get_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Copy here content of get_function \n set(mod_value):\n mod_value # TODOConverter40 Non existent set function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("get_node(@", "get_node(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("yield(this, \"timeout\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("yield(this, \"timeout\")", "await this.\"timeout\"", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, true); + + valid = valid & test_conversion_single_additional_builtin(" Transform.xform(Vector3(a,b,c)) ", " Transform * Vector3(a,b,c) ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin(" Transform.xform_inv(Vector3(a,b,c)) ", " Vector3(a,b,c) * Transform ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("export(float) var lifetime = 3.0", "export var lifetime: float = 3.0", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("export(String, 'AnonymousPro', 'CourierPrime') var _font_name = 'AnonymousPro'", "export var _font_name = 'AnonymousPro' # (String, 'AnonymousPro', 'CourierPrime')", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); // TODO, this is only a workaround + valid = valid & test_conversion_single_additional_builtin("export(PackedScene) var mob_scene", "export var mob_scene: PackedScene", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("var d = parse_json(roman(sfs))", "var test_json_conv = JSON.new()\ntest_json_conv.parse(roman(sfs))\nvar d = test_json_conv.get_data()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("to_json( AA ) szon", "JSON.new().stringify( AA ) szon", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("s to_json", "s JSON.new().stringify", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("AF to_json2", "AF to_json2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("var rr = JSON.parse(a)", "var test_json_conv = JSON.new()\ntest_json_conv.parse(a)\nvar rr = test_json_conv.get_data()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("empty()", "is_empty()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin(".empty", ".empty", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin(").roman(", ").roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("\t.roman(", "\tsuper.roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin(" .roman(", " super.roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin(".1", ".1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin(" .1", " .1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("'.'", "'.'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("'.a'", "'.a'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("\t._input(_event)", "\tsuper._input(_event)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("(connect(A,B,C) != OK):", "(connect(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("(connect(A,B,C,D) != OK):", "(connect(A,Callable(B,C).bind(D)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("(connect(A,B,C,[D]) != OK):", "(connect(A,Callable(B,C).bind(D)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("(connect(A,B,C,D,E) != OK):", "(connect(A,Callable(B,C).bind(D),E) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("(start(A,B) != OK):", "(start(Callable(A,B)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("(start(A,B,C,D,E,F,G) != OK):", "(start(Callable(A,B).bind(C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("disconnect(A,B,C) != OK):", "disconnect(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("is_connected(A,B,C) != OK):", "is_connected(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("is_connected(A,B,C))", "is_connected(A,Callable(B,C)))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("func _init(p_x:int)->void:", "func _init(p_x:int):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("q_PackedDataContainer._iter_init(variable1)", "q_PackedDataContainer._iter_init(variable1)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("assert(speed < 20, str(randi()%10))", "assert(speed < 20) #,str(randi()%10))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("assert(speed < 2)", "assert(speed < 2)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("assert(false, \"Missing type --\" + str(argument.type) + \"--, needs to be added to project\")", "assert(false) #,\"Missing type --\" + str(argument.type) + \"--, needs to be added to project\")", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("create_from_image(aa, bb)", "create_from_image(aa) #,bb", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("q_ImageTexture.create_from_image(variable1, variable2)", "q_ImageTexture.create_from_image(variable1) #,variable2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("set_cell_item(a, b, c, d ,e) # AA", "set_cell_item( Vector3(a,b,c) ,d,e) # AA", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("set_cell_item(a, b)", "set_cell_item(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("get_cell_item_orientation(a, b,c)", "get_cell_item_orientation(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("get_cell_item(a, b,c)", "get_cell_item(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("map_to_world(a, b,c)", "map_to_world(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("PackedStringArray(req_godot).join('.')", "'.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("=PackedStringArray(req_godot).join('.')", "='.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin(" aa", " aa", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("\taa", "\taa", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("\t aa", "\taa", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin(" \taa", " \taa", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_single_additional_builtin("apply_force(position, impulse)", "apply_force(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_single_additional_builtin("apply_impulse(position, impulse)", "apply_impulse(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); valid = valid & test_conversion_single_additional("AAA Color.white AF", "AAA Color.WHITE AF", &ProjectConverter3To4::rename_enums, "custom rename"); @@ -2535,7 +2580,7 @@ Vector<String> ProjectConverter3To4::check_for_rename_enums(Vector<String> &file void ProjectConverter3To4::rename_classes(String &file_content) { int current_index = 0; - // TODO Maybe it is better way to not rename gd, tscn and other files which are named are classes + // TODO Maybe it is better way to not rename gd, tscn and other files which are named as classes while (class_renames[current_index][0]) { // Begin renaming workaround `Resource.gd` -> `RefCounter.gd` RegEx reg_before = RegEx(String("\\b") + class_renames[current_index][0] + ".tscn\\b"); @@ -2625,432 +2670,11 @@ Vector<String> ProjectConverter3To4::check_for_rename_classes(Vector<String> &fi return found_things; } -void ProjectConverter3To4::rename_gdscript_functions(String &file_content) { - // Custom renaming, each rule needs to be set manually - // Don't forget to put validate each rule in validate_conversion function +void ProjectConverter3To4::rename_gdscript_functions(String &file_content, const RegExContainer ®_container, bool builtin) { Vector<String> lines = file_content.split("\n"); - RegEx reg_is_empty = RegEx("\\bempty\\("); - RegEx reg_super = RegEx("([\t ])\\.([a-zA-Z_])"); - RegEx reg_json_to = RegEx("\\bto_json\\b"); - RegEx reg_json_parse = RegEx("([\t]{0,})([^\n]+)parse_json\\(([^\n]+)"); - RegEx reg_json_non_new = RegEx("([\t]{0,})([^\n]+)JSON\\.parse\\(([^\n]+)"); - RegEx reg_export = RegEx("export\\(([a-zA-Z0-9_]+)\\)[ ]+var[ ]+([a-zA-Z0-9_]+)"); - RegEx reg_export_advanced = RegEx("export\\(([^)^\n]+)\\)[ ]+var[ ]+([a-zA-Z0-9_]+)([^\n]+)"); - RegEx reg_setget_setget = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+([a-zA-Z0-9_]+)[ \t]*,[ \t]*([a-zA-Z0-9_]+)"); - RegEx reg_setget_set = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+([a-zA-Z0-9_]+)[ \t]*[,]*[^a-z^A-Z^0-9^_]*$"); - RegEx reg_setget_get = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+,[ \t]*([a-zA-Z0-9_]+)[ \t]*$"); - RegEx reg_join = RegEx("([\\(\\)a-zA-Z0-9_]+)\\.join\\(([^\n^\\)]+)\\)"); - RegEx reg_mixed_tab_space = RegEx("([\t]+)([ ]+)"); - RegEx reg_image_lock = RegEx("([a-zA-Z0-9_\\.]+)\\.lock\\(\\)"); - RegEx reg_image_unlock = RegEx("([a-zA-Z0-9_\\.]+)\\.unlock\\(\\)"); - RegEx reg_os_fullscreen = RegEx("OS.window_fullscreen[= ]+([^#^\n]+)"); - - CRASH_COND(!reg_is_empty.is_valid()); - CRASH_COND(!reg_super.is_valid()); - CRASH_COND(!reg_json_to.is_valid()); - CRASH_COND(!reg_json_parse.is_valid()); - CRASH_COND(!reg_json_non_new.is_valid()); - CRASH_COND(!reg_export.is_valid()); - CRASH_COND(!reg_export_advanced.is_valid()); - CRASH_COND(!reg_setget_setget.is_valid()); - CRASH_COND(!reg_setget_set.is_valid()); - CRASH_COND(!reg_setget_get.is_valid()); - CRASH_COND(!reg_join.is_valid()); - CRASH_COND(!reg_mixed_tab_space.is_valid()); - CRASH_COND(!reg_image_lock.is_valid()); - CRASH_COND(!reg_image_unlock.is_valid()); - CRASH_COND(!reg_os_fullscreen.is_valid()); - for (String &line : lines) { - if (line.find("mtx") == -1 && line.find("mutex") == -1 && line.find("Mutex") == -1) { - line = reg_image_lock.sub(line, "false # $1.lock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", true); - line = reg_image_unlock.sub(line, "false # $1.unlock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", true); - } - - // Mixed use of spaces and tabs - tabs as first - TODO, this probably is problem problem, but not sure - line = reg_mixed_tab_space.sub(line, "$1", true); - - // PackedStringArray(req_godot).join('.') -> '.'.join(PackedStringArray(req_godot)) PoolStringArray - line = reg_join.sub(line, "$2.join($1)", true); - - // -- empty() -> is_empty() Pool*Array - line = reg_is_empty.sub(line, "is_empty(", true); - - // -- \t.func() -> \tsuper.func() Object - line = reg_super.sub(line, "$1super.$2", true); // TODO, not sure if possible, but for now this brake String text e.g. "Choosen .gitignore" -> "Choosen super.gitignore" - - // -- JSON.parse(a) -> JSON.new().parse(a) etc. JSON - line = reg_json_non_new.sub(line, "$1var test_json_conv = JSON.new()\n$1test_json_conv.parse($3\n$1$2test_json_conv.get_data()", true); - - // -- to_json(a) -> JSON.new().stringify(a) Object - line = reg_json_to.sub(line, "JSON.new().stringify", true); - - // -- parse_json(a) -> JSON.get_data() etc. Object - line = reg_json_parse.sub(line, "$1var test_json_conv = JSON.new()\n$1test_json_conv.parse($3\n$1$2test_json_conv.get_data()", true); - - // -- get_node(@ -> get_node( Node - line = line.replace("get_node(@", "get_node("); - - // export(float) var lifetime = 3.0 -> export var lifetime: float = 3.0 GDScript - line = reg_export.sub(line, "export var $2: $1"); - - // export(String, 'AnonymousPro', 'CourierPrime') var _font_name = 'AnonymousPro' -> export var _font_name = 'AnonymousPro' #(String, 'AnonymousPro', 'CourierPrime') GDScript - line = reg_export_advanced.sub(line, "export var $2$3 # ($1)"); - - // Setget Setget - line = reg_setget_setget.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Copy here content of $4\n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Copy here content of $3", true); - - // Setget set - line = reg_setget_set.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Non existent get function \n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Copy here content of $3", true); - - // Setget get - line = reg_setget_get.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Copy here content of $3 \n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Non existent set function", true); - - // OS.window_fullscreen = true -> ProjectSettings.set("display/window/size/fullscreen",true) - line = reg_os_fullscreen.sub(line, "ProjectSettings.set(\"display/window/size/fullscreen\", $1)", true); - - // -- r.move_and_slide( a, b, c, d, e ) -> r.set_motion_velocity(a) ... r.move_and_slide() KinematicBody - if (line.find("move_and_slide(") != -1) { - int start = line.find("move_and_slide("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - String base_obj = get_object_of_execution(line.substr(0, start)); - String starting_space = get_starting_space(line); - - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() >= 1) { - String line_new; - - // motion_velocity - line_new += starting_space + base_obj + "set_motion_velocity(" + parts[0] + ")\n"; - - // up_direction - if (parts.size() >= 2) { - line_new += starting_space + base_obj + "set_up_direction(" + parts[1] + ")\n"; - } - - // stop_on_slope - if (parts.size() >= 3) { - line_new += starting_space + base_obj + "set_floor_stop_on_slope_enabled(" + parts[2] + ")\n"; - } - - // max_slides - if (parts.size() >= 4) { - line_new += starting_space + base_obj + "set_max_slides(" + parts[3] + ")\n"; - } - - // floor_max_angle - if (parts.size() >= 5) { - line_new += starting_space + base_obj + "set_floor_max_angle(" + parts[4] + ")\n"; - } - - // infiinite_interia - if (parts.size() >= 6) { - line_new += starting_space + "# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `" + parts[5] + "`\n"; - } - - line = line_new + line.substr(0, start) + "move_and_slide()" + line.substr(end + start); - } - } - } - - // -- r.move_and_slide_with_snap( a, b, c, d, e ) -> r.set_motion_velocity(a) ... r.move_and_slide() KinematicBody - if (line.find("move_and_slide_with_snap(") != -1) { - int start = line.find("move_and_slide_with_snap("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - String base_obj = get_object_of_execution(line.substr(0, start)); - String starting_space = get_starting_space(line); - - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() >= 1) { - String line_new; - - // motion_velocity - line_new += starting_space + base_obj + "set_motion_velocity(" + parts[0] + ")\n"; - - // snap - if (parts.size() >= 2) { - line_new += starting_space + "# TODOConverter40 looks that snap in Godot 4.0 is float, not vector like in Godot 3 - previous value `" + parts[1] + "`\n"; - } - - // up_direction - if (parts.size() >= 3) { - line_new += starting_space + base_obj + "set_up_direction(" + parts[2] + ")\n"; - } - - // stop_on_slope - if (parts.size() >= 4) { - line_new += starting_space + base_obj + "set_floor_stop_on_slope_enabled(" + parts[3] + ")\n"; - } - - // max_slides - if (parts.size() >= 5) { - line_new += starting_space + base_obj + "set_max_slides(" + parts[4] + ")\n"; - } - - // floor_max_angle - if (parts.size() >= 6) { - line_new += starting_space + base_obj + "set_floor_max_angle(" + parts[5] + ")\n"; - } - - // infiinite_interia - if (parts.size() >= 7) { - line_new += starting_space + "# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `" + parts[6] + "`\n"; - } - - line = line_new + line.substr(0, start) + "move_and_slide()" + line.substr(end + start); - } - } - } - - // -- sort_custom( a , b ) -> sort_custom(Callable( a , b )) Object - if (line.find("sort_custom(") != -1) { - int start = line.find("sort_custom("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 2) { - line = line.substr(0, start) + "sort_custom(Callable(" + parts[0] + "," + parts[1] + "))" + line.substr(end + start); - } - } - } - - // -- list_dir_begin( ) -> list_dir_begin() Object - if (line.find("list_dir_begin(") != -1) { - int start = line.find("list_dir_begin("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - line = line.substr(0, start) + "list_dir_begin() " + line.substr(end + start) + "# TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547"; - } - } - - // -- draw_line(1,2,3,4,5) -> draw_line(1,2,3,4) CanvasItem - if (line.find("draw_line(") != -1) { - int start = line.find("draw_line("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 5) { - line = line.substr(0, start) + "draw_line(" + parts[0] + "," + parts[1] + "," + parts[2] + "," + parts[3] + ")" + line.substr(end + start); - } - } - } - - // -- func c(var a, var b) -> func c(a, b) - if (line.find("func ") != -1 && line.find("var ") != -1) { - int start = line.find("func "); - start = line.substr(start).find("(") + start; - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - - String start_string = line.substr(0, start) + "("; - for (int i = 0; i < parts.size(); i++) { - start_string += parts[i].strip_edges().trim_prefix("var "); - if (i != parts.size() - 1) { - start_string += ", "; - } - } - line = start_string + ")" + line.substr(end + start); - } - } - - // -- yield(this, \"timeout\") -> await this.timeout GDScript - if (line.find("yield(") != -1) { - int start = line.find("yield("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 2) { - line = line.substr(0, start) + "await " + parts[0] + "." + parts[1].replace("\"", "").replace("\'", "").replace(" ", "") + line.substr(end + start); - } - } - } - - // -- parse_json( AA ) -> TODO Object - if (line.find("parse_json(") != -1) { - int start = line.find("parse_json("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - line = line.substr(0, start) + "JSON.new().stringify(" + connect_arguments(parts, 0) + ")" + line.substr(end + start); - } - } - - // -- .xform(Vector3(a,b,c)) -> * Vector3(a,b,c) Transform - if (line.find(".xform(") != -1) { - int start = line.find(".xform("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 1) { - line = line.substr(0, start) + " * " + parts[0] + line.substr(end + start); - } - } - } - - // -- .xform_inv(Vector3(a,b,c)) -> * Vector3(a,b,c) Transform - if (line.find(".xform_inv(") != -1) { - int start = line.find(".xform_inv("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - String object_exec = get_object_of_execution(line.substr(0, start)); - if (line.find(object_exec + ".xform") != -1) { - int start2 = line.find(object_exec + ".xform"); - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 1) { - line = line.substr(0, start2) + parts[0] + " * " + object_exec + line.substr(end + start); - } - } - } - } - - // -- connect(,,,things) -> connect(,Callable(,),things) Object - if (line.find("connect(") != -1) { - int start = line.find("connect("); - // Protection from disconnect - if (start == 0 || line.get(start - 1) != 's') { - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() >= 3) { - line = line.substr(0, start) + "connect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start); - } - } - } - } - // -- disconnect(a,b,c) -> disconnect(a,Callable(b,c)) Object - if (line.find("disconnect(") != -1) { - int start = line.find("disconnect("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "disconnect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); - } - } - } - // -- is_connected(a,b,c) -> is_connected(a,Callable(b,c)) Object - if (line.find("is_connected(") != -1) { - int start = line.find("is_connected("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "is_connected(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); - } - } - } - // -- start(a,b,c) -> start(a,Callable(b,c)) Thread - if (line.find("start(") != -1) { - int start = line.find("start("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() >= 3) { - line = line.substr(0, start) + "start(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start); - } - } - } - // -- func _init(p_x:int)->void: -> func _init(p_x:int): Object # https://github.com/godotengine/godot/issues/50589 - if (line.find(" _init(") != -1) { - int start = line.find(" _init("); - int end = line.rfind(":") + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - line = line.substr(0, start) + " _init(" + connect_arguments(parts, 0) + "):" + line.substr(end + start); - } - } - // assert(speed < 20, str(randi()%10)) -> assert(speed < 20) #,str(randi()%10)) GDScript - GDScript bug constant message - if (line.find("assert(") != -1) { - int start = line.find("assert("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 2) { - line = line.substr(0, start) + "assert(" + parts[0] + ") " + line.substr(end + start) + "#," + parts[1] + ")"; - } - } - } - // create_from_image(aa, bb) -> create_from_image(aa) #, bb ImageTexture - if (line.find("create_from_image(") != -1) { - int start = line.find("create_from_image("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 2) { - line = line.substr(0, start) + "create_from_image(" + parts[0] + ") " + "#," + parts[1] + line.substr(end + start); - } - } - } - // set_cell_item(a, b, c, d ,e) -> set_cell_item(Vector3(a, b, c), d ,e) - if (line.find("set_cell_item(") != -1) { - int start = line.find("set_cell_item("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() > 2) { - line = line.substr(0, start) + "set_cell_item( Vector3(" + parts[0] + "," + parts[1] + "," + parts[2] + ") " + connect_arguments(parts, 3) + ")" + line.substr(end + start); - } - } - } - // get_cell_item(a, b, c) -> get_cell_item(Vector3i(a, b, c)) - if (line.find("get_cell_item(") != -1) { - int start = line.find("get_cell_item("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "get_cell_item(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start); - } - } - } - // get_cell_item_orientation(a, b, c) -> get_cell_item_orientation(Vector3i(a, b, c)) - if (line.find("get_cell_item_orientation(") != -1) { - int start = line.find("get_cell_item_orientation("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "get_cell_item_orientation(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start); - } - } - } - // apply_impulse(A, B) -> apply_impulse(B, A) - if (line.find("apply_impulse(") != -1) { - int start = line.find("apply_impulse("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 2) { - line = line.substr(0, start) + "apply_impulse(" + parts[1] + ", " + parts[0] + ")" + line.substr(end + start); - } - } - } - // apply_force(A, B) -> apply_force(B, A) - if (line.find("apply_force(") != -1) { - int start = line.find("apply_force("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 2) { - line = line.substr(0, start) + "apply_force(" + parts[1] + ", " + parts[0] + ")" + line.substr(end + start); - } - } - } - // map_to_world(a, b, c) -> map_to_world(Vector3i(a, b, c)) - if (line.find("map_to_world(") != -1) { - int start = line.find("map_to_world("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "map_to_world(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start); - } - } - } + process_gdscript_line(line, reg_container, builtin); } // Collect vector to string @@ -3064,478 +2688,484 @@ void ProjectConverter3To4::rename_gdscript_functions(String &file_content) { } }; -// This is almost 1:1 copy of function which rename gdscript functions -Vector<String> ProjectConverter3To4::check_for_rename_gdscript_functions(Vector<String> &file_content) { +Vector<String> ProjectConverter3To4::check_for_rename_gdscript_functions(Vector<String> &file_content, const RegExContainer ®_container, bool builtin) { int current_line = 1; Vector<String> found_things; - RegEx reg_is_empty = RegEx("\\bempty\\("); - RegEx reg_super = RegEx("([\t ])\\.([a-zA-Z_])"); - RegEx reg_json_to = RegEx("\\bto_json\\b"); - RegEx reg_json_parse = RegEx("([\t]{0,})([^\n]+)parse_json\\(([^\n]+)"); - RegEx reg_json_non_new = RegEx("([\t]{0,})([^\n]+)JSON\\.parse\\(([^\n]+)"); - RegEx reg_export = RegEx("export\\(([a-zA-Z0-9_]+)\\)[ ]+var[ ]+([a-zA-Z0-9_]+)"); - RegEx reg_export_advanced = RegEx("export\\(([^)^\n]+)\\)[ ]+var[ ]+([a-zA-Z0-9_]+)([^\n]+)"); - RegEx reg_setget_setget = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+([a-zA-Z0-9_]+)[ \t]*,[ \t]*([a-zA-Z0-9_]+)"); - RegEx reg_setget_set = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+([a-zA-Z0-9_]+)[ \t]*[,]*[^a-z^A-Z^0-9^_]*$"); - RegEx reg_setget_get = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+,[ \t]*([a-zA-Z0-9_]+)[ \t]*$"); - RegEx reg_join = RegEx("([\\(\\)a-zA-Z0-9_]+)\\.join\\(([^\n^\\)]+)\\)"); - RegEx reg_mixed_tab_space = RegEx("([\t]+)([ ]+)"); - RegEx reg_image_lock = RegEx("([a-zA-Z0-9_\\.]+)\\.lock\\(\\)"); - RegEx reg_image_unlock = RegEx("([a-zA-Z0-9_\\.]+)\\.unlock\\(\\)"); - RegEx reg_os_fullscreen = RegEx("OS.window_fullscreen[= ]+([^#^\n]+)"); - - CRASH_COND(!reg_is_empty.is_valid()); - CRASH_COND(!reg_super.is_valid()); - CRASH_COND(!reg_json_to.is_valid()); - CRASH_COND(!reg_json_parse.is_valid()); - CRASH_COND(!reg_json_non_new.is_valid()); - CRASH_COND(!reg_export.is_valid()); - CRASH_COND(!reg_export_advanced.is_valid()); - CRASH_COND(!reg_setget_setget.is_valid()); - CRASH_COND(!reg_setget_set.is_valid()); - CRASH_COND(!reg_setget_get.is_valid()); - CRASH_COND(!reg_join.is_valid()); - CRASH_COND(!reg_mixed_tab_space.is_valid()); - CRASH_COND(!reg_image_lock.is_valid()); - CRASH_COND(!reg_image_unlock.is_valid()); - CRASH_COND(!reg_os_fullscreen.is_valid()); - for (String &line : file_content) { String old_line = line; - - if (line.find("mtx") == -1 && line.find("mutex") == -1 && line.find("Mutex") == -1) { - line = reg_image_lock.sub(line, "false # $1.lock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", true); - line = reg_image_unlock.sub(line, "false # $1.unlock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", true); + process_gdscript_line(line, reg_container, builtin); + if (old_line != line) { + found_things.append(simple_line_formatter(current_line, old_line, line)); } + } - // Mixed use of spaces and tabs - tabs as first - TODO, this probably is problem problem, but not sure - line = reg_mixed_tab_space.sub(line, "$1", true); + return found_things; +} +void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContainer ®_container, bool builtin) { + if (line.find("mtx") == -1 && line.find("mutex") == -1 && line.find("Mutex") == -1) { + line = reg_container.reg_image_lock.sub(line, "false # $1.lock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", true); + line = reg_container.reg_image_unlock.sub(line, "false # $1.unlock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", true); + } - // PackedStringArray(req_godot).join('.') -> '.'.join(PackedStringArray(req_godot)) PoolStringArray - line = reg_join.sub(line, "$2.join($1)", true); + // Mixed use of spaces and tabs - tabs as first - TODO, this probably is problem problem, but not sure + line = reg_container.reg_mixed_tab_space.sub(line, "$1", true); - // -- empty() -> is_empty() Pool*Array - line = reg_is_empty.sub(line, "is_empty(", true); + // PackedStringArray(req_godot).join('.') -> '.'.join(PackedStringArray(req_godot)) PoolStringArray + line = reg_container.reg_join.sub(line, "$2.join($1)", true); - // -- \t.func() -> \tsuper.func() Object - line = reg_super.sub(line, "$1super.$2", true); // TODO, not sure if possible, but for now this brake String text e.g. "Choosen .gitignore" -> "Choosen super.gitignore" + // -- empty() -> is_empty() Pool*Array + line = reg_container.reg_is_empty.sub(line, "is_empty(", true); - // -- JSON.parse(a) -> JSON.new().parse(a) etc. JSON - line = reg_json_non_new.sub(line, "$1var test_json_conv = JSON.new()\n$1test_json_conv.parse($3\n$1$2test_json_conv.get_data()", true); + // -- \t.func() -> \tsuper.func() Object + line = reg_container.reg_super.sub(line, "$1super.$2", true); // TODO, not sure if possible, but for now this brake String text e.g. "Choosen .gitignore" -> "Choosen super.gitignore" - // -- to_json(a) -> JSON.new().stringify(a) Object - line = reg_json_to.sub(line, "JSON.new().stringify", true); + // -- JSON.parse(a) -> JSON.new().parse(a) etc. JSON + line = reg_container.reg_json_non_new.sub(line, "$1var test_json_conv = JSON.new()\n$1test_json_conv.parse($3\n$1$2test_json_conv.get_data()", true); - // -- parse_json(a) -> JSON.get_data() etc. Object - line = reg_json_parse.sub(line, "$1var test_json_conv = JSON.new()\n$1test_json_conv.parse($3\n$1$2test_json_conv.get_data()", true); + // -- to_json(a) -> JSON.new().stringify(a) Object + line = reg_container.reg_json_to.sub(line, "JSON.new().stringify", true); - // -- get_node(@ -> get_node( Node - line = line.replace("get_node(@", "get_node("); + // -- parse_json(a) -> JSON.get_data() etc. Object + line = reg_container.reg_json_parse.sub(line, "$1var test_json_conv = JSON.new()\n$1test_json_conv.parse($3\n$1$2test_json_conv.get_data()", true); - // export(float) var lifetime = 3.0 -> export var lifetime: float = 3.0 GDScript - line = reg_export.sub(line, "export var $2: $1"); + // -- get_node(@ -> get_node( Node + line = line.replace("get_node(@", "get_node("); - // export(String, 'AnonymousPro', 'CourierPrime') var _font_name = 'AnonymousPro' -> export var _font_name = 'AnonymousPro' #(String, 'AnonymousPro', 'CourierPrime') GDScript - line = reg_export_advanced.sub(line, "export var $2$3 # ($1)"); + // export(float) var lifetime = 3.0 -> export var lifetime: float = 3.0 GDScript + line = reg_container.reg_export.sub(line, "export var $2: $1"); - // Setget Setget - line = reg_setget_setget.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Copy here content of $4\n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Copy here content of $3", true); + // export(String, 'AnonymousPro', 'CourierPrime') var _font_name = 'AnonymousPro' -> export var _font_name = 'AnonymousPro' #(String, 'AnonymousPro', 'CourierPrime') GDScript + line = reg_container.reg_export_advanced.sub(line, "export var $2$3 # ($1)"); - // Setget set - line = reg_setget_set.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Non existent get function \n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Copy here content of $3", true); + // Setget Setget + line = reg_container.reg_setget_setget.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Copy here content of $4\n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Copy here content of $3", true); - // Setget get - line = reg_setget_get.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Copy here content of $3 \n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Non existent set function", true); + // Setget set + line = reg_container.reg_setget_set.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Non existent get function \n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Copy here content of $3", true); - // OS.window_fullscreen = true -> ProjectSettings.set("display/window/size/fullscreen",true) - line = reg_os_fullscreen.sub(line, "ProjectSettings.set(\"display/window/size/fullscreen\", $1)", true); + // Setget get + line = reg_container.reg_setget_get.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Copy here content of $3 \n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Non existent set function", true); - // -- r.move_and_slide( a, b, c, d, e ) -> r.set_motion_velocity(a) ... r.move_and_slide() KinematicBody - if (line.find("move_and_slide(") != -1) { - int start = line.find("move_and_slide("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - String base_obj = get_object_of_execution(line.substr(0, start)); - String starting_space = get_starting_space(line); + // OS.window_fullscreen = true -> ProjectSettings.set("display/window/size/fullscreen",true) + if (builtin) { + line = reg_container.reg_os_fullscreen.sub(line, "ProjectSettings.set(\\\"display/window/size/fullscreen\\\", $1)", true); + } else { + line = reg_container.reg_os_fullscreen.sub(line, "ProjectSettings.set(\"display/window/size/fullscreen\", $1)", true); + } - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() >= 1) { - String line_new; + // -- r.move_and_slide( a, b, c, d, e ) -> r.set_motion_velocity(a) ... r.move_and_slide() KinematicBody + if (line.find("move_and_slide(") != -1) { + int start = line.find("move_and_slide("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + String base_obj = get_object_of_execution(line.substr(0, start)); + String starting_space = get_starting_space(line); - // motion_velocity - line_new += starting_space + base_obj + "set_motion_velocity(" + parts[0] + ")\n"; + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() >= 1) { + String line_new; - // up_direction - if (parts.size() >= 2) { - line_new += starting_space + base_obj + "set_up_direction(" + parts[1] + ")\n"; - } + // motion_velocity + line_new += starting_space + base_obj + "set_motion_velocity(" + parts[0] + ")\n"; - // stop_on_slope - if (parts.size() >= 3) { - line_new += starting_space + base_obj + "set_floor_stop_on_slope_enabled(" + parts[2] + ")\n"; - } + // up_direction + if (parts.size() >= 2) { + line_new += starting_space + base_obj + "set_up_direction(" + parts[1] + ")\n"; + } - // max_slides - if (parts.size() >= 4) { - line_new += starting_space + base_obj + "set_max_slides(" + parts[3] + ")\n"; - } + // stop_on_slope + if (parts.size() >= 3) { + line_new += starting_space + base_obj + "set_floor_stop_on_slope_enabled(" + parts[2] + ")\n"; + } - // floor_max_angle - if (parts.size() >= 5) { - line_new += starting_space + base_obj + "set_floor_max_angle(" + parts[4] + ")\n"; - } + // max_slides + if (parts.size() >= 4) { + line_new += starting_space + base_obj + "set_max_slides(" + parts[3] + ")\n"; + } - // infiinite_interia - if (parts.size() >= 6) { - line_new += starting_space + "# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `" + parts[5] + "`\n"; - } + // floor_max_angle + if (parts.size() >= 5) { + line_new += starting_space + base_obj + "set_floor_max_angle(" + parts[4] + ")\n"; + } - line = line_new + line.substr(0, start) + "move_and_slide()" + line.substr(end + start); + // infiinite_interia + if (parts.size() >= 6) { + line_new += starting_space + "# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `" + parts[5] + "`\n"; } + + line = line_new + line.substr(0, start) + "move_and_slide()" + line.substr(end + start); } } + } - // -- r.move_and_slide_with_snap( a, b, c, d, e ) -> r.set_motion_velocity(a) ... r.move_and_slide() KinematicBody - if (line.find("move_and_slide_with_snap(") != -1) { - int start = line.find("move_and_slide_with_snap("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - String base_obj = get_object_of_execution(line.substr(0, start)); - String starting_space = get_starting_space(line); - - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() >= 1) { - String line_new; + // -- r.move_and_slide_with_snap( a, b, c, d, e ) -> r.set_motion_velocity(a) ... r.move_and_slide() KinematicBody + if (line.find("move_and_slide_with_snap(") != -1) { + int start = line.find("move_and_slide_with_snap("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + String base_obj = get_object_of_execution(line.substr(0, start)); + String starting_space = get_starting_space(line); - // motion_velocity - line_new += starting_space + base_obj + "set_motion_velocity(" + parts[0] + ")\n"; + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() >= 1) { + String line_new; - // snap - if (parts.size() >= 2) { - line_new += starting_space + "# TODOConverter40 looks that snap in Godot 4.0 is float, not vector like in Godot 3 - previous value `" + parts[1] + "`\n"; - } + // motion_velocity + line_new += starting_space + base_obj + "set_motion_velocity(" + parts[0] + ")\n"; - // up_direction - if (parts.size() >= 3) { - line_new += starting_space + base_obj + "set_up_direction(" + parts[2] + ")\n"; - } + // snap + if (parts.size() >= 2) { + line_new += starting_space + "# TODOConverter40 looks that snap in Godot 4.0 is float, not vector like in Godot 3 - previous value `" + parts[1] + "`\n"; + } - // stop_on_slope - if (parts.size() >= 4) { - line_new += starting_space + base_obj + "set_floor_stop_on_slope_enabled(" + parts[3] + ")\n"; - } + // up_direction + if (parts.size() >= 3) { + line_new += starting_space + base_obj + "set_up_direction(" + parts[2] + ")\n"; + } - // max_slides - if (parts.size() >= 5) { - line_new += starting_space + base_obj + "set_max_slides(" + parts[4] + ")\n"; - } + // stop_on_slope + if (parts.size() >= 4) { + line_new += starting_space + base_obj + "set_floor_stop_on_slope_enabled(" + parts[3] + ")\n"; + } - // floor_max_angle - if (parts.size() >= 6) { - line_new += starting_space + base_obj + "set_floor_max_angle(" + parts[5] + ")\n"; - } + // max_slides + if (parts.size() >= 5) { + line_new += starting_space + base_obj + "set_max_slides(" + parts[4] + ")\n"; + } - // infiinite_interia - if (parts.size() >= 7) { - line_new += starting_space + "# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `" + parts[6] + "`\n"; - } + // floor_max_angle + if (parts.size() >= 6) { + line_new += starting_space + base_obj + "set_floor_max_angle(" + parts[5] + ")\n"; + } - line = line_new + line.substr(0, start) + "move_and_slide()" + line.substr(end + start); + // infiinite_interia + if (parts.size() >= 7) { + line_new += starting_space + "# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `" + parts[6] + "`\n"; } + + line = line_new + line.substr(0, start) + "move_and_slide()" + line.substr(end + start); } } + } - // -- sort_custom( a , b ) -> sort_custom(Callable( a , b )) Object - if (line.find("sort_custom(") != -1) { - int start = line.find("sort_custom("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 2) { - line = line.substr(0, start) + "sort_custom(Callable(" + parts[0] + "," + parts[1] + "))" + line.substr(end + start); - } + // -- sort_custom( a , b ) -> sort_custom(Callable( a , b )) Object + if (line.find("sort_custom(") != -1) { + int start = line.find("sort_custom("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 2) { + line = line.substr(0, start) + "sort_custom(Callable(" + parts[0] + "," + parts[1] + "))" + line.substr(end + start); } } + } - // -- draw_line(1,2,3,4,5) -> draw_line(1,2,3,4) CanvasItem - if (line.find("draw_line(") != -1) { - int start = line.find("draw_line("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 5) { - line = line.substr(0, start) + "draw_line(" + parts[0] + "," + parts[1] + "," + parts[2] + "," + parts[3] + ")" + line.substr(end + start); - } - } + // -- list_dir_begin( ) -> list_dir_begin() Object + if (line.find("list_dir_begin(") != -1) { + int start = line.find("list_dir_begin("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + line = line.substr(0, start) + "list_dir_begin() " + line.substr(end + start) + "# TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547"; } + } - // -- func c(var a, var b) -> func c(a, b) - if (line.find("func ") != -1 && line.find("var ") != -1) { - int start = line.find("func "); - start = line.substr(start).find("(") + start; - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); + // -- draw_line(1,2,3,4,5) -> draw_line(1,2,3,4) CanvasItem + if (line.find("draw_line(") != -1) { + int start = line.find("draw_line("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 5) { + line = line.substr(0, start) + "draw_line(" + parts[0] + "," + parts[1] + "," + parts[2] + "," + parts[3] + ")" + line.substr(end + start); + } + } + } - String start_string = line.substr(0, start) + "("; - for (int i = 0; i < parts.size(); i++) { - start_string += parts[i].strip_edges().trim_prefix("var "); - if (i != parts.size() - 1) { - start_string += ", "; - } + // -- func c(var a, var b) -> func c(a, b) + if (line.find("func ") != -1 && line.find("var ") != -1) { + int start = line.find("func "); + start = line.substr(start).find("(") + start; + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + + String start_string = line.substr(0, start) + "("; + for (int i = 0; i < parts.size(); i++) { + start_string += parts[i].strip_edges().trim_prefix("var "); + if (i != parts.size() - 1) { + start_string += ", "; } - line = start_string + ")" + line.substr(end + start); } + line = start_string + ")" + line.substr(end + start); } + } - // -- yield(this, \"timeout\") -> await this.timeout GDScript - if (line.find("yield(") != -1) { - int start = line.find("yield("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 2) { + // -- yield(this, \"timeout\") -> await this.timeout GDScript + if (line.find("yield(") != -1) { + int start = line.find("yield("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 2) { + if (builtin) { + line = line.substr(0, start) + "await " + parts[0] + "." + parts[1].replace(" ", "") + line.substr(end + start); + } else { line = line.substr(0, start) + "await " + parts[0] + "." + parts[1].replace("\"", "").replace("\'", "").replace(" ", "") + line.substr(end + start); } } } + } - // -- parse_json( AA ) -> TODO Object - if (line.find("parse_json(") != -1) { - int start = line.find("parse_json("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - line = line.substr(0, start) + "JSON.new().stringify(" + connect_arguments(parts, 0) + ")" + line.substr(end + start); - } + // -- parse_json( AA ) -> TODO Object + if (line.find("parse_json(") != -1) { + int start = line.find("parse_json("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + line = line.substr(0, start) + "JSON.new().stringify(" + connect_arguments(parts, 0) + ")" + line.substr(end + start); } + } - // -- .xform(Vector3(a,b,c)) -> * Vector3(a,b,c) Transform - if (line.find(".xform(") != -1) { - int start = line.find(".xform("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 1) { - line = line.substr(0, start) + " * " + parts[0] + line.substr(end + start); - } + // -- .xform(Vector3(a,b,c)) -> * Vector3(a,b,c) Transform + if (line.find(".xform(") != -1) { + int start = line.find(".xform("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 1) { + line = line.substr(0, start) + " * " + parts[0] + line.substr(end + start); } } + } - // -- .xform_inv(Vector3(a,b,c)) -> / Vector3(a,b,c) Transform - if (line.find(".xform_inv(") != -1) { - int start = line.find(".xform_inv("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { + // -- .xform_inv(Vector3(a,b,c)) -> * Vector3(a,b,c) Transform + if (line.find(".xform_inv(") != -1) { + int start = line.find(".xform_inv("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + String object_exec = get_object_of_execution(line.substr(0, start)); + if (line.find(object_exec + ".xform") != -1) { + int start2 = line.find(object_exec + ".xform"); Vector<String> parts = parse_arguments(line.substr(start, end)); if (parts.size() == 1) { - line = line.substr(0, start) + " / " + parts[0] + line.substr(end + start); + line = line.substr(0, start2) + parts[0] + " * " + object_exec + line.substr(end + start); } } } + } - // -- connect(,,,things) -> connect(,Callable(,),things) Object - if (line.find("connect(") != -1) { - int start = line.find("connect("); - // Protection from disconnect - if (start == 0 || line.get(start - 1) != 's') { - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() >= 3) { - line = line.substr(0, start) + "connect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start); - } - } - } - } - // -- disconnect(a,b,c) -> disconnect(a,Callable(b,c)) Object - if (line.find("disconnect(") != -1) { - int start = line.find("disconnect("); + // -- "(connect(A,B,C,D,E) != OK):", "(connect(A,Callable(B,C).bind(D),E) Object + if (line.find("connect(") != -1) { + int start = line.find("connect("); + // Protection from disconnect + if (start == 0 || line.get(start - 1) != 's') { int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { Vector<String> parts = parse_arguments(line.substr(start, end)); if (parts.size() == 3) { - line = line.substr(0, start) + "disconnect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); + line = line.substr(0, start) + "connect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); + } else if (parts.size() >= 4) { + line = line.substr(0, start) + "connect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + ").bind(" + parts[3].lstrip("[").rstrip("]") + ")" + connect_arguments(parts, 4) + ")" + line.substr(end + start); } } } - // -- is_connected(a,b,c) -> is_connected(a,Callable(b,c)) Object - if (line.find("is_connected(") != -1) { - int start = line.find("is_connected("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "is_connected(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); - } + } + // -- disconnect(a,b,c) -> disconnect(a,Callable(b,c)) Object + if (line.find("disconnect(") != -1) { + int start = line.find("disconnect("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 3) { + line = line.substr(0, start) + "disconnect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); } } - // -- start(a,b,c) -> start(a,Callable(b,c)) Thread - if (line.find("start(") != -1) { - int start = line.find("start("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() >= 3) { - line = line.substr(0, start) + "start(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start); - } + } + // -- is_connected(a,b,c) -> is_connected(a,Callable(b,c)) Object + if (line.find("is_connected(") != -1) { + int start = line.find("is_connected("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 3) { + line = line.substr(0, start) + "is_connected(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); } } - // -- func _init(p_x:int)->void: -> func _init(p_x:int): Object # https://github.com/godotengine/godot/issues/50589 - if (line.find(" _init(") != -1) { - int start = line.find(" _init("); - int end = line.rfind(":") + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - line = line.substr(0, start) + " _init(" + connect_arguments(parts, 0) + "):" + line.substr(end + start); + } + // -- start(a,b) -> start(Callable(a,b)) Thread + // -- start(a,b,c,d) -> start(Callable(a,b).bind(c),d) Thread + if (line.find("start(") != -1) { + int start = line.find("start("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 2) { + line = line.substr(0, start) + "start(Callable(" + parts[0] + "," + parts[1] + "))" + line.substr(end + start); + } else if (parts.size() >= 3) { + line = line.substr(0, start) + "start(Callable(" + parts[0] + "," + parts[1] + ").bind(" + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start); } } - // assert(speed < 20, str(randi()%10)) -> assert(speed < 20) #,str(randi()%10)) GDScript - GDScript bug constant message - if (line.find("assert(") != -1) { - int start = line.find("assert("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 2) { - line = line.substr(0, start) + "assert(" + parts[0] + ") " + line.substr(end + start) + "#," + parts[1] + ")"; - } + } + // -- func _init(p_x:int)->void: -> func _init(p_x:int): Object # https://github.com/godotengine/godot/issues/50589 + if (line.find(" _init(") != -1) { + int start = line.find(" _init("); + int end = line.rfind(":") + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + line = line.substr(0, start) + " _init(" + connect_arguments(parts, 0) + "):" + line.substr(end + start); + } + } + // assert(speed < 20, str(randi()%10)) -> assert(speed < 20) #,str(randi()%10)) GDScript - GDScript bug constant message + if (line.find("assert(") != -1) { + int start = line.find("assert("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 2) { + line = line.substr(0, start) + "assert(" + parts[0] + ") " + line.substr(end + start) + "#," + parts[1] + ")"; } } - // create_from_image(aa, bb) -> create_from_image(aa) #, bb ImageTexture - if (line.find("create_from_image(") != -1) { - int start = line.find("create_from_image("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 2) { - line = line.substr(0, start) + "create_from_image(" + parts[0] + ") " + "#," + parts[1] + line.substr(end + start); - } + } + // create_from_image(aa, bb) -> create_from_image(aa) #, bb ImageTexture + if (line.find("create_from_image(") != -1) { + int start = line.find("create_from_image("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 2) { + line = line.substr(0, start) + "create_from_image(" + parts[0] + ") " + "#," + parts[1] + line.substr(end + start); } } - // set_cell_item(a, b, c, d ,e) -> set_cell_item(Vector3(a, b, c), d ,e) - if (line.find("set_cell_item(") != -1) { - int start = line.find("set_cell_item("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() > 2) { - line = line.substr(0, start) + "set_cell_item( Vector3(" + parts[0] + "," + parts[1] + "," + parts[2] + ") " + connect_arguments(parts, 3) + ")" + line.substr(end + start); - } + } + // set_cell_item(a, b, c, d ,e) -> set_cell_item(Vector3(a, b, c), d ,e) + if (line.find("set_cell_item(") != -1) { + int start = line.find("set_cell_item("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() > 2) { + line = line.substr(0, start) + "set_cell_item( Vector3(" + parts[0] + "," + parts[1] + "," + parts[2] + ") " + connect_arguments(parts, 3) + ")" + line.substr(end + start); } } - // get_cell_item(a, b, c) -> get_cell_item(Vector3i(a, b, c)) - if (line.find("get_cell_item(") != -1) { - int start = line.find("get_cell_item("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "get_cell_item(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start); - } + } + // get_cell_item(a, b, c) -> get_cell_item(Vector3i(a, b, c)) + if (line.find("get_cell_item(") != -1) { + int start = line.find("get_cell_item("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 3) { + line = line.substr(0, start) + "get_cell_item(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start); } } - // get_cell_item_orientation(a, b, c) -> get_cell_item_orientation(Vector3i(a, b, c)) - if (line.find("get_cell_item_orientation(") != -1) { - int start = line.find("get_cell_item_orientation("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "get_cell_item_orientation(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start); - } + } + // get_cell_item_orientation(a, b, c) -> get_cell_item_orientation(Vector3i(a, b, c)) + if (line.find("get_cell_item_orientation(") != -1) { + int start = line.find("get_cell_item_orientation("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 3) { + line = line.substr(0, start) + "get_cell_item_orientation(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start); } } - - // apply_impulse(A, B) -> apply_impulse(B, A) - if (line.find("apply_impulse(") != -1) { - int start = line.find("apply_impulse("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 2) { - line = line.substr(0, start) + "apply_impulse(" + parts[1] + ", " + parts[0] + ")" + line.substr(end + start); - } + } + // apply_impulse(A, B) -> apply_impulse(B, A) + if (line.find("apply_impulse(") != -1) { + int start = line.find("apply_impulse("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 2) { + line = line.substr(0, start) + "apply_impulse(" + parts[1] + ", " + parts[0] + ")" + line.substr(end + start); } } - // apply_force(A, B) -> apply_force(B, A) - if (line.find("apply_force(") != -1) { - int start = line.find("apply_force("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 2) { - line = line.substr(0, start) + "apply_force(" + parts[1] + ", " + parts[0] + ")" + line.substr(end + start); - } + } + // apply_force(A, B) -> apply_force(B, A) + if (line.find("apply_force(") != -1) { + int start = line.find("apply_force("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 2) { + line = line.substr(0, start) + "apply_force(" + parts[1] + ", " + parts[0] + ")" + line.substr(end + start); } } - // map_to_world(a, b, c) -> map_to_world(Vector3i(a, b, c)) - if (line.find("map_to_world(") != -1) { - int start = line.find("get_cell_item_orientation("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "map_to_world(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start); - } + } + // map_to_world(a, b, c) -> map_to_world(Vector3i(a, b, c)) + if (line.find("map_to_world(") != -1) { + int start = line.find("map_to_world("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 3) { + line = line.substr(0, start) + "map_to_world(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start); } } - - if (old_line != line) { - found_things.append(simple_line_formatter(current_line, old_line, line)); + } + // OS.get_window_safe_area() -> DisplayServer.get_display_safe_area() + if (line.find("OS.get_window_safe_area(") != -1) { + int start = line.find("OS.get_window_safe_area("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 0) { + line = line.substr(0, start) + "DisplayServer.get_display_safe_area()" + line.substr(end + start); + } } } - - return found_things; } -void ProjectConverter3To4::rename_csharp_functions(String &file_content) { - // Custom renaming, each rule needs to be set manually - // Don't forget to put validate each rule in validate_conversion function - Vector<String> lines = file_content.split("\n"); +void ProjectConverter3To4::process_csharp_line(String &line) { + // TODO maybe this can be changed to normal rule + line = line.replace("OS.GetWindowSafeArea()", "DisplayServer.ScreenGetUsableRect()"); - for (String &line : lines) { - // TODO maybe this can be changed to normal rule - line = line.replace("OS.GetWindowSafeArea()", "DisplayServer.ScreenGetUsableRect()"); - - // -- Connect(,,,things) -> Connect(,Callable(,),things) Object - if (line.find("Connect(") != -1) { - int start = line.find("Connect("); - // Protection from disconnect - if (start == 0 || line.get(start - 1) != 's') { - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() >= 3) { - line = line.substr(0, start) + "Connect(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start); - } - } - } - } - // -- Disconnect(a,b,c) -> Disconnect(a,Callable(b,c)) Object - if (line.find("Disconnect(") != -1) { - int start = line.find("Disconnect("); + // -- Connect(,,,things) -> Connect(,Callable(,),things) Object + if (line.find("Connect(") != -1) { + int start = line.find("Connect("); + // Protection from disconnect + if (start == 0 || line.get(start - 1) != 's') { int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "Disconnect(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); + if (parts.size() >= 3) { + line = line.substr(0, start) + "Connect(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start); } } } - // -- IsConnected(a,b,c) -> IsConnected(a,Callable(b,c)) Object - if (line.find("IsConnected(") != -1) { - int start = line.find("IsConnected("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "IsConnected(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); - } + } + // -- Disconnect(a,b,c) -> Disconnect(a,Callable(b,c)) Object + if (line.find("Disconnect(") != -1) { + int start = line.find("Disconnect("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 3) { + line = line.substr(0, start) + "Disconnect(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); + } + } + } + // -- IsConnected(a,b,c) -> IsConnected(a,Callable(b,c)) Object + if (line.find("IsConnected(") != -1) { + int start = line.find("IsConnected("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 3) { + line = line.substr(0, start) + "IsConnected(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); } } } +} + +void ProjectConverter3To4::rename_csharp_functions(String &file_content) { + Vector<String> lines = file_content.split("\n"); + + for (String &line : lines) { + process_csharp_line(line); + } // Collect vector to string file_content = ""; @@ -3556,47 +3186,7 @@ Vector<String> ProjectConverter3To4::check_for_rename_csharp_functions(Vector<St for (String &line : file_content) { String old_line = line; - - // TODO maybe this can be changed to normal rule - line = line.replace("OS.GetWindowSafeArea()", "DisplayServer.ScreenGetUsableRect()"); - - // -- Connect(,,,things) -> connect(,Callable(,),things) Object - if (line.find("Connect(") != -1) { - int start = line.find("Connect("); - // Protection from disconnect - if (start == 0 || line.get(start - 1) != 's') { - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() >= 3) { - line = line.substr(0, start) + "Connect(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start); - } - } - } - } - // -- Disconnect(a,b,c) -> Disconnect(a,Callable(b,c)) Object - if (line.find("Disconnect(") != -1) { - int start = line.find("Disconnect("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "Disconnect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); - } - } - } - // -- IsConnected(a,b,c) -> IsConnected(a,Callable(b,c)) Object - if (line.find("IsConnected(") != -1) { - int start = line.find("IsConnected("); - int end = get_end_parenthess(line.substr(start)) + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - if (parts.size() == 3) { - line = line.substr(0, start) + "IsConnected(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start); - } - } - } - + process_csharp_line(line); if (old_line != line) { found_things.append(simple_line_formatter(current_line, old_line, line)); } @@ -3605,88 +3195,81 @@ Vector<String> ProjectConverter3To4::check_for_rename_csharp_functions(Vector<St return found_things; } -void ProjectConverter3To4::rename_gdscript_keywords(String &file_content){ - { RegEx reg_tool = RegEx("([\n]+)tool"); -CRASH_COND(!reg_tool.is_valid()); -file_content = reg_tool.sub(file_content, "$1@tool", true); -RegEx reg_tool2 = RegEx("^tool"); -CRASH_COND(!reg_tool2.is_valid()); -file_content = reg_tool2.sub(file_content, "@tool", true); -} -{ - RegEx reg_export = RegEx("([\n\t]+)export\\b"); - CRASH_COND(!reg_export.is_valid()); - file_content = reg_export.sub(file_content, "$1@export", true); - RegEx reg_export2 = RegEx("^export"); - CRASH_COND(!reg_export2.is_valid()); - file_content = reg_export2.sub(file_content, "@export", true); -} -{ - RegEx reg_onready = RegEx("([\n]+)onready"); - CRASH_COND(!reg_onready.is_valid()); - file_content = reg_onready.sub(file_content, "$1@onready", true); - RegEx reg_onready2 = RegEx("^onready"); - CRASH_COND(!reg_onready2.is_valid()); - file_content = reg_onready2.sub(file_content, "@onready", true); -} -{ - RegEx reg_master = RegEx("([\n]+)master func"); - CRASH_COND(!reg_master.is_valid()); - file_content = reg_master.sub(file_content, "$1@rpc(any) func", true); - RegEx reg_master2 = RegEx("^master func"); - CRASH_COND(!reg_master2.is_valid()); - file_content = reg_master2.sub(file_content, "@rpc(any) func", true); -} -{ - RegEx reg_puppet = RegEx("([\n]+)puppet func"); - CRASH_COND(!reg_puppet.is_valid()); - file_content = reg_puppet.sub(file_content, "$1@rpc(auth) func", true); - RegEx reg_puppet2 = RegEx("^puppet func"); - CRASH_COND(!reg_puppet2.is_valid()); - file_content = reg_puppet2.sub(file_content, "@rpc(auth) func", true); -} -{ - RegEx reg_remote = RegEx("([\n]+)remote func"); - CRASH_COND(!reg_remote.is_valid()); - file_content = reg_remote.sub(file_content, "$1@rpc(any) func", true); - RegEx reg_remote2 = RegEx("^remote func"); - CRASH_COND(!reg_remote2.is_valid()); - file_content = reg_remote2.sub(file_content, "@rpc(any) func", true); -} -{ - RegEx reg_remotesync = RegEx("([\n]+)remotesync func"); - CRASH_COND(!reg_remotesync.is_valid()); - file_content = reg_remotesync.sub(file_content, "$1@rpc(any,sync) func", true); - RegEx reg_remotesync2 = RegEx("^remotesync func"); - CRASH_COND(!reg_remotesync2.is_valid()); - file_content = reg_remotesync2.sub(file_content, "@rpc(any,sync) func", true); -} -{ - RegEx reg_sync = RegEx("([\n]+)sync func"); - CRASH_COND(!reg_sync.is_valid()); - file_content = reg_sync.sub(file_content, "$1@rpc(any,sync) func", true); - RegEx reg_sync2 = RegEx("^sync func"); - CRASH_COND(!reg_sync2.is_valid()); - file_content = reg_sync2.sub(file_content, "@rpc(any,sync) func", true); -} -{ - RegEx reg_puppetsync = RegEx("([\n]+)puppetsync func"); - CRASH_COND(!reg_puppetsync.is_valid()); - file_content = reg_puppetsync.sub(file_content, "$1@rpc(auth,sync) func", true); - RegEx reg_puppetsync2 = RegEx("^puppetsync func"); - CRASH_COND(!reg_puppetsync2.is_valid()); - file_content = reg_puppetsync2.sub(file_content, "@rpc(auth,sync) func", true); -} -{ - RegEx reg_mastersync = RegEx("([\n]+)mastersync func"); - CRASH_COND(!reg_mastersync.is_valid()); - file_content = reg_mastersync.sub(file_content, "$1@rpc(any,sync) func", true); - RegEx reg_mastersync2 = RegEx("^mastersync func"); - CRASH_COND(!reg_mastersync2.is_valid()); - file_content = reg_mastersync2.sub(file_content, "@rpc(any,sync) func", true); -} +void ProjectConverter3To4::rename_gdscript_keywords(String &file_content) { + { + RegEx reg_first = RegEx("([\n]+)tool"); + CRASH_COND(!reg_first.is_valid()); + file_content = reg_first.sub(file_content, "$1@tool", true); + RegEx reg_second = RegEx("^tool"); + CRASH_COND(!reg_second.is_valid()); + file_content = reg_second.sub(file_content, "@tool", true); + } + { + RegEx reg_first = RegEx("([\n\t]+)export\\b"); + CRASH_COND(!reg_first.is_valid()); + file_content = reg_first.sub(file_content, "$1@export", true); + RegEx reg_second = RegEx("^export"); + CRASH_COND(!reg_second.is_valid()); + file_content = reg_second.sub(file_content, "@export", true); + } + { + RegEx reg_first = RegEx("([\n]+)onready"); + CRASH_COND(!reg_first.is_valid()); + file_content = reg_first.sub(file_content, "$1@onready", true); + RegEx reg_second = RegEx("^onready"); + CRASH_COND(!reg_second.is_valid()); + file_content = reg_second.sub(file_content, "@onready", true); + } + { + RegEx reg_first = RegEx("([\n]+)remote func"); + CRASH_COND(!reg_first.is_valid()); + file_content = reg_first.sub(file_content, "$1@rpc(any_peer) func", true); + RegEx reg_second = RegEx("^remote func"); + CRASH_COND(!reg_second.is_valid()); + file_content = reg_second.sub(file_content, "@rpc(any_peer) func", true); + } + { + RegEx reg_first = RegEx("([\n]+)remotesync func"); + CRASH_COND(!reg_first.is_valid()); + file_content = reg_first.sub(file_content, "$1@rpc(any_peer, call_local) func", true); + RegEx reg_second = RegEx("^remotesync func"); + CRASH_COND(!reg_second.is_valid()); + file_content = reg_second.sub(file_content, "@rpc(any_peer, call_local) func", true); + } + { + RegEx reg_first = RegEx("([\n]+)puppet func"); + CRASH_COND(!reg_first.is_valid()); + file_content = reg_first.sub(file_content, "$1@rpc func", true); + RegEx reg_second = RegEx("^puppet func"); + CRASH_COND(!reg_second.is_valid()); + file_content = reg_second.sub(file_content, "@rpc func", true); + } + { + RegEx reg_first = RegEx("([\n]+)puppetsync func"); + CRASH_COND(!reg_first.is_valid()); + file_content = reg_first.sub(file_content, "$1@rpc(call_local) func", true); + RegEx reg_second = RegEx("^puppetsync func"); + CRASH_COND(!reg_second.is_valid()); + file_content = reg_second.sub(file_content, "@rpc(call_local) func", true); + } + String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n"; + { + RegEx reg_first = RegEx("([\n]+)master func"); + CRASH_COND(!reg_first.is_valid()); + file_content = reg_first.sub(file_content, "$1" + error_message + "@rpc func", true); + RegEx reg_second = RegEx("^master func"); + CRASH_COND(!reg_second.is_valid()); + file_content = reg_second.sub(file_content, error_message + "@rpc func", true); + } + { + RegEx reg_first = RegEx("([\n]+)mastersync func"); + CRASH_COND(!reg_first.is_valid()); + file_content = reg_first.sub(file_content, "$1" + error_message + "@rpc(call_local) func", true); + RegEx reg_second = RegEx("^mastersync func"); + CRASH_COND(!reg_second.is_valid()); + file_content = reg_second.sub(file_content, error_message + "@rpc(call_local) func", true); + } } -; Vector<String> ProjectConverter3To4::check_for_rename_gdscript_keywords(Vector<String> &file_content) { Vector<String> found_things; @@ -3697,96 +3280,87 @@ Vector<String> ProjectConverter3To4::check_for_rename_gdscript_keywords(Vector<S String old; old = line; { - RegEx reg_tool2 = RegEx("^tool"); - CRASH_COND(!reg_tool2.is_valid()); - line = reg_tool2.sub(line, "@tool", true); + RegEx reg_first = RegEx("^tool"); + CRASH_COND(!reg_first.is_valid()); + line = reg_first.sub(line, "@tool", true); } if (old != line) { found_things.append(line_formatter(current_line, "tool", "@tool", line)); } old = line; { - RegEx reg_export = RegEx("([\t]+)export\\b"); - CRASH_COND(!reg_export.is_valid()); - line = reg_export.sub(line, "$1@export", true); - RegEx reg_export2 = RegEx("^export"); - CRASH_COND(!reg_export2.is_valid()); - line = reg_export2.sub(line, "@export", true); + RegEx reg_first = RegEx("([\t]+)export\\b"); + CRASH_COND(!reg_first.is_valid()); + line = reg_first.sub(line, "$1@export", true); + RegEx reg_second = RegEx("^export"); + CRASH_COND(!reg_second.is_valid()); + line = reg_second.sub(line, "@export", true); } if (old != line) { found_things.append(line_formatter(current_line, "export", "@export", line)); } old = line; { - RegEx reg_onready2 = RegEx("^onready"); - CRASH_COND(!reg_onready2.is_valid()); - line = reg_onready2.sub(line, "@onready", true); + RegEx reg_first = RegEx("^onready"); + CRASH_COND(!reg_first.is_valid()); + line = reg_first.sub(line, "@onready", true); } if (old != line) { found_things.append(line_formatter(current_line, "onready", "@onready", line)); } old = line; { - RegEx reg_master2 = RegEx("^master func"); - CRASH_COND(!reg_master2.is_valid()); - line = reg_master2.sub(line, "@rpc(any) func", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "master func", "@rpc(any) func", line)); - } - old = line; - { - RegEx reg_puppet2 = RegEx("^puppet func"); - CRASH_COND(!reg_puppet2.is_valid()); - line = reg_puppet2.sub(line, "@rpc(auth) func", true); + RegEx regex = RegEx("^remote func"); + CRASH_COND(!regex.is_valid()); + line = regex.sub(line, "@rpc(any_peer) func", true); } if (old != line) { - found_things.append(line_formatter(current_line, "puppet func", "@rpc(auth) func", line)); + found_things.append(line_formatter(current_line, "remote func", "@rpc(any_peer) func", line)); } old = line; { - RegEx reg_remote2 = RegEx("^remote func"); - CRASH_COND(!reg_remote2.is_valid()); - line = reg_remote2.sub(line, "@rpc(any) func", true); + RegEx regex = RegEx("^remotesync func"); + CRASH_COND(!regex.is_valid()); + line = regex.sub(line, "@rpc(any_peer, call_local)) func", true); } if (old != line) { - found_things.append(line_formatter(current_line, "remote func", "@rpc(any) func", line)); + found_things.append(line_formatter(current_line, "remotesync func", "@rpc(any_peer, call_local)) func", line)); } old = line; { - RegEx reg_remotesync2 = RegEx("^remotesync func"); - CRASH_COND(!reg_remotesync2.is_valid()); - line = reg_remotesync2.sub(line, "@rpc(any,sync) func", true); + RegEx regex = RegEx("^puppet func"); + CRASH_COND(!regex.is_valid()); + line = regex.sub(line, "@rpc func", true); } if (old != line) { - found_things.append(line_formatter(current_line, "remotesync func", "@rpc(any,sync) func", line)); + found_things.append(line_formatter(current_line, "puppet func", "@rpc func", line)); } old = line; { - RegEx reg_sync2 = RegEx("^sync func"); - CRASH_COND(!reg_sync2.is_valid()); - line = reg_sync2.sub(line, "@rpc(any,sync) func", true); + RegEx regex = RegEx("^puppetsync func"); + CRASH_COND(!regex.is_valid()); + line = regex.sub(line, "@rpc(call_local) func", true); } if (old != line) { - found_things.append(line_formatter(current_line, "sync func", "@rpc(any,sync) func", line)); + found_things.append(line_formatter(current_line, "puppetsync func", "@rpc(call_local) func", line)); } old = line; { - RegEx reg_puppetsync2 = RegEx("^puppetsync func"); - CRASH_COND(!reg_puppetsync2.is_valid()); - line = reg_puppetsync2.sub(line, "@rpc(auth,sync) func", true); + RegEx regex = RegEx("^master func"); + CRASH_COND(!regex.is_valid()); + line = regex.sub(line, "@rpc func", true); } if (old != line) { - found_things.append(line_formatter(current_line, "puppetsync func", "@rpc(any,sync) func", line)); + found_things.append(line_formatter(current_line, "master func", "@rpc func", line)); } old = line; { - RegEx reg_mastersync2 = RegEx("^mastersync func"); - CRASH_COND(!reg_mastersync2.is_valid()); - line = reg_mastersync2.sub(line, "@rpc(any,sync) func", true); + RegEx regex = RegEx("^mastersync func"); + CRASH_COND(!regex.is_valid()); + line = regex.sub(line, "@rpc(call_local) func", true); } if (old != line) { - found_things.append(line_formatter(current_line, "mastersync", "@rpc(any,sync) func", line)); + found_things.append(line_formatter(current_line, "mastersync func", "@rpc(call_local) func", line)); } old = line; diff --git a/editor/project_converter_3_to_4.h b/editor/project_converter_3_to_4.h index 95239666e0..a58bb2767a 100644 --- a/editor/project_converter_3_to_4.h +++ b/editor/project_converter_3_to_4.h @@ -37,17 +37,23 @@ #include "core/string/ustring.h" class ProjectConverter3To4 { +public: + class RegExContainer; + +private: void rename_enums(String &file_content); Vector<String> check_for_rename_enums(Vector<String> &file_content); void rename_classes(String &file_content); Vector<String> check_for_rename_classes(Vector<String> &file_content); - void rename_gdscript_functions(String &file_content); - Vector<String> check_for_rename_gdscript_functions(Vector<String> &file_content); + void rename_gdscript_functions(String &file_content, const RegExContainer ®_container, bool builtin); + Vector<String> check_for_rename_gdscript_functions(Vector<String> &file_content, const RegExContainer ®_container, bool builtin); + void process_gdscript_line(String &line, const RegExContainer ®_container, bool builtin); void rename_csharp_functions(String &file_content); Vector<String> check_for_rename_csharp_functions(Vector<String> &file_content); + void process_csharp_line(String &line); void rename_gdscript_keywords(String &file_content); Vector<String> check_for_rename_gdscript_keywords(Vector<String> &file_content); @@ -71,9 +77,10 @@ class ProjectConverter3To4 { bool test_single_array(const char *array[][2], bool ignore_second_check = false); bool test_conversion_single_additional(String name, String expected, void (ProjectConverter3To4::*func)(String &), String what); + bool test_conversion_single_additional_builtin(String name, String expected, void (ProjectConverter3To4::*func)(String &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin); bool test_conversion_single_normal(String name, String expected, const char *array[][2], String what); bool test_array_names(); - bool test_conversion(); + bool test_conversion(const RegExContainer ®_container); public: int validate_conversion(); diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index 4b2ea6faa5..8efcd72fb6 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -58,22 +58,23 @@ if env["builtin_freetype"]: ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - thirdparty_brotli_dir = "#thirdparty/brotli/" - thirdparty_brotli_sources = [ - "common/constants.c", - "common/context.c", - "common/dictionary.c", - "common/platform.c", - "common/shared_dictionary.c", - "common/transform.c", - "dec/bit_reader.c", - "dec/decode.c", - "dec/huffman.c", - "dec/state.c", - ] - thirdparty_sources += [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources] - env_freetype.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"]) - env_freetype.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"]) + if env["brotli"]: + thirdparty_brotli_dir = "#thirdparty/brotli/" + thirdparty_brotli_sources = [ + "common/constants.c", + "common/context.c", + "common/dictionary.c", + "common/platform.c", + "common/shared_dictionary.c", + "common/transform.c", + "dec/bit_reader.c", + "dec/decode.c", + "dec/huffman.c", + "dec/state.c", + ] + thirdparty_sources += [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources] + env_freetype.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"]) + env_freetype.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"]) if env.get("use_ubsan") or env.get("use_asan") or env.get("use_tsan") or env.get("use_lsan") or env.get("use_msan"): env_freetype.Append(CPPDEFINES=["BROTLI_BUILD_PORTABLE"]) diff --git a/modules/freetype/config.py b/modules/freetype/config.py index d22f9454ed..c0586d5536 100644 --- a/modules/freetype/config.py +++ b/modules/freetype/config.py @@ -2,5 +2,13 @@ def can_build(env, platform): return True +def get_opts(platform): + from SCons.Variables import BoolVariable + + return [ + BoolVariable("brotli", "Enable Brotli decompressor for WOFF2 fonts support", True), + ] + + def configure(env): pass diff --git a/modules/mono/config.py b/modules/mono/config.py index 3e6584590c..d895d2d92d 100644 --- a/modules/mono/config.py +++ b/modules/mono/config.py @@ -5,52 +5,44 @@ def can_build(env, platform): return not env["arch"].startswith("rv") -def configure(env): - platform = env["platform"] - - if platform not in supported_platforms: - raise RuntimeError("This module does not currently support building for this platform") - - env.add_module_version_string("mono") - - from SCons.Script import BoolVariable, PathVariable, Variables, Help +def get_opts(platform): + from SCons.Variables import BoolVariable, PathVariable default_mono_static = platform in ["ios", "javascript"] default_mono_bundles_zlib = platform in ["javascript"] - envvars = Variables() - envvars.Add( + return [ PathVariable( "mono_prefix", "Path to the Mono installation directory for the target platform and architecture", "", PathVariable.PathAccept, - ) - ) - envvars.Add( + ), PathVariable( "mono_bcl", "Path to a custom Mono BCL (Base Class Library) directory for the target platform", "", PathVariable.PathAccept, - ) - ) - envvars.Add(BoolVariable("mono_static", "Statically link Mono", default_mono_static)) - envvars.Add(BoolVariable("mono_glue", "Build with the Mono glue sources", True)) - envvars.Add(BoolVariable("build_cil", "Build C# solutions", True)) - envvars.Add( - BoolVariable("copy_mono_root", "Make a copy of the Mono installation directory to bundle with the editor", True) - ) - - # TODO: It would be great if this could be detected automatically instead - envvars.Add( + ), + BoolVariable("mono_static", "Statically link Mono", default_mono_static), + BoolVariable("mono_glue", "Build with the Mono glue sources", True), + BoolVariable("build_cil", "Build C# solutions", True), + BoolVariable( + "copy_mono_root", "Make a copy of the Mono installation directory to bundle with the editor", True + ), BoolVariable( "mono_bundles_zlib", "Specify if the Mono runtime was built with bundled zlib", default_mono_bundles_zlib - ) - ) + ), + ] + + +def configure(env): + platform = env["platform"] - envvars.Update(env) - Help(envvars.GenerateHelpText(env)) + if platform not in supported_platforms: + raise RuntimeError("This module does not currently support building for this platform") + + env.add_module_version_string("mono") if env["mono_bundles_zlib"]: # Mono may come with zlib bundled for WASM or on newer version when built with MinGW. diff --git a/modules/text_server_adv/SCsub b/modules/text_server_adv/SCsub index 73e5c2bf74..81b8e1ea5d 100644 --- a/modules/text_server_adv/SCsub +++ b/modules/text_server_adv/SCsub @@ -113,8 +113,11 @@ if env["builtin_harfbuzz"]: if freetype_enabled: thirdparty_sources += [ "src/hb-ft.cc", - "src/hb-graphite2.cc", ] + if env["graphite"]: + thirdparty_sources += [ + "src/hb-graphite2.cc", + ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] env_harfbuzz.Prepend(CPPPATH=["#thirdparty/harfbuzz/src"]) @@ -133,7 +136,7 @@ if env["builtin_harfbuzz"]: ) if env["builtin_freetype"]: env_harfbuzz.Prepend(CPPPATH=["#thirdparty/freetype/include"]) - if env["builtin_graphite"]: + if env["builtin_graphite"] and env["graphite"]: env_harfbuzz.Prepend(CPPPATH=["#thirdparty/graphite/include"]) env_harfbuzz.Append(CCFLAGS=["-DGRAPHITE2_STATIC"]) @@ -165,7 +168,7 @@ if env["builtin_harfbuzz"]: env.Append(LIBS=[lib]) -if env["builtin_graphite"] and freetype_enabled: +if env["builtin_graphite"] and freetype_enabled and env["graphite"]: env_graphite = env_modules.Clone() env_graphite.disable_warnings() @@ -512,9 +515,10 @@ if env["builtin_msdfgen"] and msdfgen_enabled: env_text_server_adv.Prepend(CPPPATH=["#thirdparty/msdfgen"]) if env["builtin_freetype"] and freetype_enabled: + env_text_server_adv.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"]) env_text_server_adv.Prepend(CPPPATH=["#thirdparty/freetype/include"]) -if env["builtin_graphite"] and freetype_enabled: +if env["builtin_graphite"] and freetype_enabled and env["graphite"]: env_text_server_adv.Prepend(CPPPATH=["#thirdparty/graphite/include"]) env_text_server_adv.add_source_files(module_obj, "*.cpp") diff --git a/modules/text_server_adv/config.py b/modules/text_server_adv/config.py index 8c8df9b05e..179a2ff378 100644 --- a/modules/text_server_adv/config.py +++ b/modules/text_server_adv/config.py @@ -2,6 +2,14 @@ def can_build(env, platform): return True +def get_opts(platform): + from SCons.Variables import BoolVariable + + return [ + BoolVariable("graphite", "Enable SIL Graphite smart fonts support", True), + ] + + def configure(env): pass diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 21e1bfaa5c..73dbf2f443 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -4706,7 +4706,7 @@ bool TextServerAdvanced::shaped_text_update_justification_ops(const RID &p_shape for (int i = 0; i < sd_size; i++) { if (sd_glyphs[i].count > 0) { char32_t c = sd->text[sd_glyphs[i].start - sd->start]; - if (c == 0x0640) { + if (c == 0x0640 && sd_glyphs[i].start == sd_glyphs[i].end - 1) { sd_glyphs[i].flags |= GRAPHEME_IS_ELONGATION; } if (sd->jstops.has(sd_glyphs[i].start)) { diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h index b337abea7a..7ae329d616 100644 --- a/modules/text_server_adv/text_server_adv.h +++ b/modules/text_server_adv/text_server_adv.h @@ -113,7 +113,10 @@ using namespace godot; #include FT_ADVANCES_H #include FT_MULTIPLE_MASTERS_H #include FT_BBOX_H - +#include FT_CONFIG_OPTIONS_H +#if !defined(FT_CONFIG_OPTION_USE_BROTLI) && !defined(_MSC_VER) +#warning FreeType is configured without Brotli support, built-in fonts will not be available. +#endif #include <hb-ft.h> #include <hb-ot.h> #endif diff --git a/modules/text_server_fb/SCsub b/modules/text_server_fb/SCsub index ca9322e450..8f626f02b8 100644 --- a/modules/text_server_fb/SCsub +++ b/modules/text_server_fb/SCsub @@ -12,6 +12,7 @@ if env["builtin_msdfgen"] and msdfgen_enabled: env_text_server_fb.Prepend(CPPPATH=["#thirdparty/msdfgen"]) if env["builtin_freetype"] and freetype_enabled: + env_text_server_fb.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"]) env_text_server_fb.Prepend(CPPPATH=["#thirdparty/freetype/include"]) env_text_server_fb.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/text_server_fb/text_server_fb.h b/modules/text_server_fb/text_server_fb.h index adb5cbb817..fef19d442b 100644 --- a/modules/text_server_fb/text_server_fb.h +++ b/modules/text_server_fb/text_server_fb.h @@ -98,6 +98,10 @@ using namespace godot; #include FT_ADVANCES_H #include FT_MULTIPLE_MASTERS_H #include FT_BBOX_H +#include FT_CONFIG_OPTIONS_H +#if !defined(FT_CONFIG_OPTION_USE_BROTLI) && !defined(_MSC_VER) +#warning FreeType is configured without Brotli support, built-in fonts will not be available. +#endif #endif /*************************************************************************/ diff --git a/platform/macos/display_server_macos.h b/platform/macos/display_server_macos.h index 65f9a3d4b8..54c479fc81 100644 --- a/platform/macos/display_server_macos.h +++ b/platform/macos/display_server_macos.h @@ -303,6 +303,7 @@ public: virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; virtual float screen_get_refresh_rate(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; virtual void screen_set_keep_on(bool p_enable) override; + virtual bool screen_is_kept_on() const override; virtual Vector<int> get_window_list() const override; diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index 2f5efae69e..e228007246 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -1892,6 +1892,10 @@ float DisplayServerMacOS::screen_get_refresh_rate(int p_screen) const { return SCREEN_REFRESH_RATE_FALLBACK; } +bool DisplayServerMacOS::screen_is_kept_on() const { + return (screen_keep_on_assertion); +} + void DisplayServerMacOS::screen_set_keep_on(bool p_enable) { if (screen_keep_on_assertion) { IOPMAssertionRelease(screen_keep_on_assertion); diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index f6baab1644..a975d09a9d 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -531,10 +531,43 @@ DisplayServer::ScreenOrientation DisplayServerWindows::screen_get_orientation(in } void DisplayServerWindows::screen_set_keep_on(bool p_enable) { + if (keep_screen_on == p_enable) { + return; + } + + if (p_enable) { + const String reason = "Godot Engine running with display/window/energy_saving/keep_screen_on = true"; + Char16String reason_utf16 = reason.utf16(); + + REASON_CONTEXT context; + context.Version = POWER_REQUEST_CONTEXT_VERSION; + context.Flags = POWER_REQUEST_CONTEXT_SIMPLE_STRING; + context.Reason.SimpleReasonString = (LPWSTR)(reason_utf16.ptrw()); + power_request = PowerCreateRequest(&context); + if (power_request == INVALID_HANDLE_VALUE) { + print_error("Failed to enable screen_keep_on."); + return; + } + if (PowerSetRequest(power_request, POWER_REQUEST_TYPE::PowerRequestSystemRequired) == 0) { + print_error("Failed to request system sleep override."); + return; + } + if (PowerSetRequest(power_request, POWER_REQUEST_TYPE::PowerRequestDisplayRequired) == 0) { + print_error("Failed to request display timeout override."); + return; + } + } else { + PowerClearRequest(power_request, POWER_REQUEST_TYPE::PowerRequestSystemRequired); + PowerClearRequest(power_request, POWER_REQUEST_TYPE::PowerRequestDisplayRequired); + CloseHandle(power_request); + power_request = nullptr; + } + + keep_screen_on = p_enable; } bool DisplayServerWindows::screen_is_kept_on() const { - return false; + return keep_screen_on; } Vector<DisplayServer::WindowID> DisplayServerWindows::get_window_list() const { @@ -3619,6 +3652,9 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win // Init TTS tts = memnew(TTS_Windows); + // Enforce default keep screen on value. + screen_set_keep_on(GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true)); + // Note: Wacom WinTab driver API for pen input, for devices incompatible with Windows Ink. HMODULE wintab_lib = LoadLibraryW(L"wintab32.dll"); if (wintab_lib) { @@ -3822,6 +3858,9 @@ DisplayServerWindows::~DisplayServerWindows() { SetWindowLongPtr(windows[MAIN_WINDOW_ID].hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc); } + // Close power request handle. + screen_set_keep_on(false); + #ifdef GLES3_ENABLED // destroy windows .. NYI? // FIXME wglDeleteContext is never called diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index ddbf674c64..db9b589304 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -331,6 +331,8 @@ class DisplayServerWindows : public DisplayServer { HINSTANCE hInstance; // Holds The Instance Of The Application String rendering_driver; bool app_focused = false; + bool keep_screen_on = false; + HANDLE power_request; TTS_Windows *tts = nullptr; diff --git a/scene/2d/shape_cast_2d.cpp b/scene/2d/shape_cast_2d.cpp index 7589af0924..316988d298 100644 --- a/scene/2d/shape_cast_2d.cpp +++ b/scene/2d/shape_cast_2d.cpp @@ -217,7 +217,7 @@ void ShapeCast2D::_notification(int p_what) { if (shape.is_null()) { break; } - Color draw_col = get_tree()->get_debug_collisions_color(); + Color draw_col = collided ? Color(1.0, 0.01, 0) : get_tree()->get_debug_collisions_color(); if (!enabled) { float g = draw_col.get_v(); draw_col.r = g; @@ -235,18 +235,25 @@ void ShapeCast2D::_notification(int p_what) { // Draw an arrow indicating where the ShapeCast is pointing to. if (target_position != Vector2()) { - Transform2D xf; - xf.rotate(target_position.angle()); - xf.translate_local(Vector2(target_position.length(), 0)); + const real_t max_arrow_size = 6; + const real_t line_width = 1.4; + bool no_line = target_position.length() < line_width; + real_t arrow_size = CLAMP(target_position.length() * 2 / 3, line_width, max_arrow_size); - draw_line(Vector2(), target_position, draw_col, 2); + if (no_line) { + arrow_size = target_position.length(); + } else { + draw_line(Vector2(), target_position - target_position.normalized() * arrow_size, draw_col, line_width); + } - float tsize = 8; + Transform2D xf; + xf.rotate(target_position.angle()); + xf.translate_local(Vector2(no_line ? 0 : target_position.length() - arrow_size, 0)); Vector<Vector2> pts = { - xf.xform(Vector2(tsize, 0)), - xf.xform(Vector2(0, Math_SQRT12 * tsize)), - xf.xform(Vector2(0, -Math_SQRT12 * tsize)) + xf.xform(Vector2(arrow_size, 0)), + xf.xform(Vector2(0, 0.5 * arrow_size)), + xf.xform(Vector2(0, -0.5 * arrow_size)) }; Vector<Color> cols = { draw_col, draw_col, draw_col }; @@ -291,6 +298,8 @@ void ShapeCast2D::_update_shapecast_state() { collision_safe_fraction = 0.0; collision_unsafe_fraction = 0.0; + bool prev_collision_state = collided; + if (target_position != Vector2()) { dss->cast_motion(params, collision_safe_fraction, collision_unsafe_fraction); if (collision_unsafe_fraction < 1.0) { @@ -314,6 +323,10 @@ void ShapeCast2D::_update_shapecast_state() { } } collided = !result.is_empty(); + + if (prev_collision_state != collided) { + update(); + } } void ShapeCast2D::force_shapecast_update() { diff --git a/scene/gui/color_mode.cpp b/scene/gui/color_mode.cpp index af78d67e5a..ebd86e0937 100644 --- a/scene/gui/color_mode.cpp +++ b/scene/gui/color_mode.cpp @@ -159,7 +159,7 @@ void ColorModeHSV::slider_draw(int p_which) { } else if (p_which == 0) { Ref<Texture2D> hue = color_picker->get_theme_icon(SNAME("color_hue"), SNAME("ColorPicker")); slider->draw_set_transform(Point2(), -Math_PI / 2, Size2(1.0, 1.0)); - slider->draw_texture_rect(hue, Rect2(Vector2(margin * -2, 0), Vector2(slider->get_size().x, margin)), false, Color(1, 1, 1), true); + slider->draw_texture_rect(hue, Rect2(Vector2(margin * -2, 0), Vector2(margin, size.x)), false); return; } else { Color s_col; @@ -306,7 +306,7 @@ void ColorModeOKHSL::slider_draw(int p_which) { } else if (p_which == 0) { Ref<Texture2D> hue = color_picker->get_theme_icon(SNAME("color_hue"), SNAME("ColorPicker")); slider->draw_set_transform(Point2(), -Math_PI / 2, Size2(1.0, 1.0)); - slider->draw_texture_rect(hue, Rect2(Vector2(margin * -2, 0), Vector2(slider->get_size().x, margin)), false, Color(1, 1, 1), true); + slider->draw_texture_rect(hue, Rect2(Vector2(margin * -2, 0), Vector2(margin, size.x)), false); return; } else { Color s_col; diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index c5054525a7..112b8c74af 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -450,7 +450,7 @@ void GraphNode::_validate_property(PropertyInfo &property) const { Control::_validate_property(property); GraphEdit *graph = Object::cast_to<GraphEdit>(get_parent()); if (graph) { - if (property.name == "rect_position") { + if (property.name == "position") { property.usage |= PROPERTY_USAGE_READ_ONLY; } } diff --git a/tests/servers/test_text_server.h b/tests/servers/test_text_server.h index 57a2cae37f..9ebd0f34b4 100644 --- a/tests/servers/test_text_server.h +++ b/tests/servers/test_text_server.h @@ -44,7 +44,7 @@ TEST_SUITE("[TextServer]") { SUBCASE("[TextServer] Loading fonts") { for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); - TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + CHECK_FALSE_MESSAGE(ts.is_null(), "Invalid TS interface."); if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC)) { continue; @@ -52,7 +52,7 @@ TEST_SUITE("[TextServer]") { RID font = ts->create_font(); ts->font_set_data_ptr(font, _font_NotoSans_Regular, _font_NotoSans_Regular_size); - TEST_FAIL_COND(font == RID(), "Loading font failed."); + CHECK_FALSE_MESSAGE(font == RID(), "Loading font failed."); ts->free_rid(font); } } @@ -60,7 +60,7 @@ TEST_SUITE("[TextServer]") { SUBCASE("[TextServer] Text layout: Font fallback") { for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); - TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + CHECK_FALSE_MESSAGE(ts.is_null(), "Invalid TS interface."); if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { continue; @@ -79,26 +79,26 @@ TEST_SUITE("[TextServer]") { // 6^ 17^ RID ctx = ts->create_shaped_text(); - TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); + CHECK_FALSE_MESSAGE(ctx == RID(), "Creating text buffer failed."); bool ok = ts->shaped_text_add_string(ctx, test, font, 16); - TEST_FAIL_COND(!ok, "Adding text to the buffer failed."); + CHECK_FALSE_MESSAGE(!ok, "Adding text to the buffer failed."); const Glyph *glyphs = ts->shaped_text_get_glyphs(ctx); int gl_size = ts->shaped_text_get_glyph_count(ctx); - TEST_FAIL_COND(gl_size == 0, "Shaping failed"); + CHECK_FALSE_MESSAGE(gl_size == 0, "Shaping failed"); for (int j = 0; j < gl_size; j++) { if (glyphs[j].start < 6) { - TEST_FAIL_COND(glyphs[j].font_rid != font[1], "Incorrect font selected."); + CHECK_FALSE_MESSAGE(glyphs[j].font_rid != font[1], "Incorrect font selected."); } if ((glyphs[j].start > 6) && (glyphs[j].start < 16)) { - TEST_FAIL_COND(glyphs[j].font_rid != font[0], "Incorrect font selected."); + CHECK_FALSE_MESSAGE(glyphs[j].font_rid != font[0], "Incorrect font selected."); } if (glyphs[j].start > 16) { - TEST_FAIL_COND(glyphs[j].font_rid != RID(), "Incorrect font selected."); - TEST_FAIL_COND(glyphs[j].index != test[glyphs[j].start], "Incorrect glyph index."); + CHECK_FALSE_MESSAGE(glyphs[j].font_rid != RID(), "Incorrect font selected."); + CHECK_FALSE_MESSAGE(glyphs[j].index != test[glyphs[j].start], "Incorrect glyph index."); } - TEST_FAIL_COND((glyphs[j].start < 0 || glyphs[j].end > test.length()), "Incorrect glyph range."); - TEST_FAIL_COND(glyphs[j].font_size != 16, "Incorrect glyph font size."); + CHECK_FALSE_MESSAGE((glyphs[j].start < 0 || glyphs[j].end > test.length()), "Incorrect glyph range."); + CHECK_FALSE_MESSAGE(glyphs[j].font_size != 16, "Incorrect glyph font size."); } ts->free_rid(ctx); @@ -113,7 +113,7 @@ TEST_SUITE("[TextServer]") { SUBCASE("[TextServer] Text layout: BiDi") { for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); - TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + CHECK_FALSE_MESSAGE(ts.is_null(), "Invalid TS interface."); if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_BIDI_LAYOUT)) { continue; @@ -132,23 +132,23 @@ TEST_SUITE("[TextServer]") { // 7^ 26^ RID ctx = ts->create_shaped_text(); - TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); + CHECK_FALSE_MESSAGE(ctx == RID(), "Creating text buffer failed."); bool ok = ts->shaped_text_add_string(ctx, test, font, 16); - TEST_FAIL_COND(!ok, "Adding text to the buffer failed."); + CHECK_FALSE_MESSAGE(!ok, "Adding text to the buffer failed."); const Glyph *glyphs = ts->shaped_text_get_glyphs(ctx); int gl_size = ts->shaped_text_get_glyph_count(ctx); - TEST_FAIL_COND(gl_size == 0, "Shaping failed"); + CHECK_FALSE_MESSAGE(gl_size == 0, "Shaping failed"); for (int j = 0; j < gl_size; j++) { if (glyphs[j].count > 0) { if (glyphs[j].start < 7) { - TEST_FAIL_COND(((glyphs[j].flags & TextServer::GRAPHEME_IS_RTL) == TextServer::GRAPHEME_IS_RTL), "Incorrect direction."); + CHECK_FALSE_MESSAGE(((glyphs[j].flags & TextServer::GRAPHEME_IS_RTL) == TextServer::GRAPHEME_IS_RTL), "Incorrect direction."); } if ((glyphs[j].start > 8) && (glyphs[j].start < 23)) { - TEST_FAIL_COND(((glyphs[j].flags & TextServer::GRAPHEME_IS_RTL) != TextServer::GRAPHEME_IS_RTL), "Incorrect direction."); + CHECK_FALSE_MESSAGE(((glyphs[j].flags & TextServer::GRAPHEME_IS_RTL) != TextServer::GRAPHEME_IS_RTL), "Incorrect direction."); } if (glyphs[j].start > 26) { - TEST_FAIL_COND(((glyphs[j].flags & TextServer::GRAPHEME_IS_RTL) == TextServer::GRAPHEME_IS_RTL), "Incorrect direction."); + CHECK_FALSE_MESSAGE(((glyphs[j].flags & TextServer::GRAPHEME_IS_RTL) == TextServer::GRAPHEME_IS_RTL), "Incorrect direction."); } } } @@ -165,7 +165,7 @@ TEST_SUITE("[TextServer]") { SUBCASE("[TextServer] Text layout: Line break and align points") { for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); - TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + CHECK_FALSE_MESSAGE(ts.is_null(), "Invalid TS interface."); if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { continue; @@ -186,16 +186,16 @@ TEST_SUITE("[TextServer]") { { String test = U"Test test long text long text\n"; RID ctx = ts->create_shaped_text(); - TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); + CHECK_FALSE_MESSAGE(ctx == RID(), "Creating text buffer failed."); bool ok = ts->shaped_text_add_string(ctx, test, font, 16); - TEST_FAIL_COND(!ok, "Adding text to the buffer failed."); + CHECK_FALSE_MESSAGE(!ok, "Adding text to the buffer failed."); ts->shaped_text_update_breaks(ctx); ts->shaped_text_update_justification_ops(ctx); const Glyph *glyphs = ts->shaped_text_get_glyphs(ctx); int gl_size = ts->shaped_text_get_glyph_count(ctx); - TEST_FAIL_COND(gl_size != 30, "Invalid glyph count."); + CHECK_FALSE_MESSAGE(gl_size != 30, "Invalid glyph count."); for (int j = 0; j < gl_size; j++) { bool hard = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_HARD) == TextServer::GRAPHEME_IS_BREAK_HARD; bool soft = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_SOFT) == TextServer::GRAPHEME_IS_BREAK_SOFT; @@ -203,11 +203,11 @@ TEST_SUITE("[TextServer]") { bool virt = (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL; bool elo = (glyphs[j].flags & TextServer::GRAPHEME_IS_ELONGATION) == TextServer::GRAPHEME_IS_ELONGATION; if (j == 4 || j == 9 || j == 14 || j == 19 || j == 24) { - TEST_FAIL_COND((!soft || !space || hard || virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((!soft || !space || hard || virt || elo), "Invalid glyph flags."); } else if (j == 29) { - TEST_FAIL_COND((soft || !space || !hard || virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((soft || !space || !hard || virt || elo), "Invalid glyph flags."); } else { - TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((soft || space || hard || virt || elo), "Invalid glyph flags."); } } ts->free_rid(ctx); @@ -216,21 +216,63 @@ TEST_SUITE("[TextServer]") { { String test = U"الحمـد"; RID ctx = ts->create_shaped_text(); - TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); + CHECK_FALSE_MESSAGE(ctx == RID(), "Creating text buffer failed."); bool ok = ts->shaped_text_add_string(ctx, test, font, 16); - TEST_FAIL_COND(!ok, "Adding text to the buffer failed."); + CHECK_FALSE_MESSAGE(!ok, "Adding text to the buffer failed."); ts->shaped_text_update_breaks(ctx); const Glyph *glyphs = ts->shaped_text_get_glyphs(ctx); int gl_size = ts->shaped_text_get_glyph_count(ctx); - TEST_FAIL_COND(gl_size != 6, "Invalid glyph count."); + CHECK_FALSE_MESSAGE(gl_size != 6, "Invalid glyph count."); for (int j = 0; j < gl_size; j++) { bool hard = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_HARD) == TextServer::GRAPHEME_IS_BREAK_HARD; bool soft = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_SOFT) == TextServer::GRAPHEME_IS_BREAK_SOFT; bool space = (glyphs[j].flags & TextServer::GRAPHEME_IS_SPACE) == TextServer::GRAPHEME_IS_SPACE; bool virt = (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL; bool elo = (glyphs[j].flags & TextServer::GRAPHEME_IS_ELONGATION) == TextServer::GRAPHEME_IS_ELONGATION; - TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((soft || space || hard || virt || elo), "Invalid glyph flags."); + } + if (ts->has_feature(TextServer::FEATURE_KASHIDA_JUSTIFICATION)) { + ts->shaped_text_update_justification_ops(ctx); + + glyphs = ts->shaped_text_get_glyphs(ctx); + gl_size = ts->shaped_text_get_glyph_count(ctx); + + CHECK_FALSE_MESSAGE(gl_size != 6, "Invalid glyph count."); + for (int j = 0; j < gl_size; j++) { + bool hard = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_HARD) == TextServer::GRAPHEME_IS_BREAK_HARD; + bool soft = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_SOFT) == TextServer::GRAPHEME_IS_BREAK_SOFT; + bool space = (glyphs[j].flags & TextServer::GRAPHEME_IS_SPACE) == TextServer::GRAPHEME_IS_SPACE; + bool virt = (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL; + bool elo = (glyphs[j].flags & TextServer::GRAPHEME_IS_ELONGATION) == TextServer::GRAPHEME_IS_ELONGATION; + if (j == 1) { + CHECK_FALSE_MESSAGE((soft || space || hard || virt || !elo), "Invalid glyph flags."); + } else { + CHECK_FALSE_MESSAGE((soft || space || hard || virt || elo), "Invalid glyph flags."); + } + } + } + ts->free_rid(ctx); + } + + { + String test = U"الحمد"; + RID ctx = ts->create_shaped_text(); + CHECK_FALSE_MESSAGE(ctx == RID(), "Creating text buffer failed."); + bool ok = ts->shaped_text_add_string(ctx, test, font, 16); + CHECK_FALSE_MESSAGE(!ok, "Adding text to the buffer failed."); + ts->shaped_text_update_breaks(ctx); + + const Glyph *glyphs = ts->shaped_text_get_glyphs(ctx); + int gl_size = ts->shaped_text_get_glyph_count(ctx); + CHECK_FALSE_MESSAGE(gl_size != 5, "Invalid glyph count."); + for (int j = 0; j < gl_size; j++) { + bool hard = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_HARD) == TextServer::GRAPHEME_IS_BREAK_HARD; + bool soft = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_SOFT) == TextServer::GRAPHEME_IS_BREAK_SOFT; + bool space = (glyphs[j].flags & TextServer::GRAPHEME_IS_SPACE) == TextServer::GRAPHEME_IS_SPACE; + bool virt = (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL; + bool elo = (glyphs[j].flags & TextServer::GRAPHEME_IS_ELONGATION) == TextServer::GRAPHEME_IS_ELONGATION; + CHECK_FALSE_MESSAGE((soft || space || hard || virt || elo), "Invalid glyph flags."); } if (ts->has_feature(TextServer::FEATURE_KASHIDA_JUSTIFICATION)) { @@ -239,7 +281,7 @@ TEST_SUITE("[TextServer]") { glyphs = ts->shaped_text_get_glyphs(ctx); gl_size = ts->shaped_text_get_glyph_count(ctx); - TEST_FAIL_COND(gl_size != 6, "Invalid glyph count."); + CHECK_FALSE_MESSAGE(gl_size != 6, "Invalid glyph count."); for (int j = 0; j < gl_size; j++) { bool hard = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_HARD) == TextServer::GRAPHEME_IS_BREAK_HARD; bool soft = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_SOFT) == TextServer::GRAPHEME_IS_BREAK_SOFT; @@ -247,9 +289,9 @@ TEST_SUITE("[TextServer]") { bool virt = (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL; bool elo = (glyphs[j].flags & TextServer::GRAPHEME_IS_ELONGATION) == TextServer::GRAPHEME_IS_ELONGATION; if (j == 1) { - TEST_FAIL_COND((soft || space || hard || virt || !elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((soft || space || hard || !virt || !elo), "Invalid glyph flags."); } else { - TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((soft || space || hard || virt || elo), "Invalid glyph flags."); } } } @@ -259,15 +301,15 @@ TEST_SUITE("[TextServer]") { { String test = U"الحمـد الرياضي العربي"; RID ctx = ts->create_shaped_text(); - TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); + CHECK_FALSE_MESSAGE(ctx == RID(), "Creating text buffer failed."); bool ok = ts->shaped_text_add_string(ctx, test, font, 16); - TEST_FAIL_COND(!ok, "Adding text to the buffer failed."); + CHECK_FALSE_MESSAGE(!ok, "Adding text to the buffer failed."); ts->shaped_text_update_breaks(ctx); const Glyph *glyphs = ts->shaped_text_get_glyphs(ctx); int gl_size = ts->shaped_text_get_glyph_count(ctx); - TEST_FAIL_COND(gl_size != 21, "Invalid glyph count."); + CHECK_FALSE_MESSAGE(gl_size != 21, "Invalid glyph count."); for (int j = 0; j < gl_size; j++) { bool hard = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_HARD) == TextServer::GRAPHEME_IS_BREAK_HARD; bool soft = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_SOFT) == TextServer::GRAPHEME_IS_BREAK_SOFT; @@ -275,9 +317,9 @@ TEST_SUITE("[TextServer]") { bool virt = (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL; bool elo = (glyphs[j].flags & TextServer::GRAPHEME_IS_ELONGATION) == TextServer::GRAPHEME_IS_ELONGATION; if (j == 6 || j == 14) { - TEST_FAIL_COND((!soft || !space || hard || virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((!soft || !space || hard || virt || elo), "Invalid glyph flags."); } else { - TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((soft || space || hard || virt || elo), "Invalid glyph flags."); } } @@ -287,7 +329,7 @@ TEST_SUITE("[TextServer]") { glyphs = ts->shaped_text_get_glyphs(ctx); gl_size = ts->shaped_text_get_glyph_count(ctx); - TEST_FAIL_COND(gl_size != 23, "Invalid glyph count."); + CHECK_FALSE_MESSAGE(gl_size != 23, "Invalid glyph count."); for (int j = 0; j < gl_size; j++) { bool hard = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_HARD) == TextServer::GRAPHEME_IS_BREAK_HARD; bool soft = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_SOFT) == TextServer::GRAPHEME_IS_BREAK_SOFT; @@ -295,13 +337,13 @@ TEST_SUITE("[TextServer]") { bool virt = (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL; bool elo = (glyphs[j].flags & TextServer::GRAPHEME_IS_ELONGATION) == TextServer::GRAPHEME_IS_ELONGATION; if (j == 7 || j == 16) { - TEST_FAIL_COND((!soft || !space || hard || virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((!soft || !space || hard || virt || elo), "Invalid glyph flags."); } else if (j == 3 || j == 9) { - TEST_FAIL_COND((soft || space || hard || !virt || !elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((soft || space || hard || !virt || !elo), "Invalid glyph flags."); } else if (j == 18) { - TEST_FAIL_COND((soft || space || hard || virt || !elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((soft || space || hard || virt || !elo), "Invalid glyph flags."); } else { - TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((soft || space || hard || virt || elo), "Invalid glyph flags."); } } } @@ -312,16 +354,16 @@ TEST_SUITE("[TextServer]") { { String test = U"เป็น ภาษา ราชการ และ ภาษา"; RID ctx = ts->create_shaped_text(); - TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); + CHECK_FALSE_MESSAGE(ctx == RID(), "Creating text buffer failed."); bool ok = ts->shaped_text_add_string(ctx, test, font, 16); - TEST_FAIL_COND(!ok, "Adding text to the buffer failed."); + CHECK_FALSE_MESSAGE(!ok, "Adding text to the buffer failed."); ts->shaped_text_update_breaks(ctx); ts->shaped_text_update_justification_ops(ctx); const Glyph *glyphs = ts->shaped_text_get_glyphs(ctx); int gl_size = ts->shaped_text_get_glyph_count(ctx); - TEST_FAIL_COND(gl_size != 25, "Invalid glyph count."); + CHECK_FALSE_MESSAGE(gl_size != 25, "Invalid glyph count."); for (int j = 0; j < gl_size; j++) { bool hard = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_HARD) == TextServer::GRAPHEME_IS_BREAK_HARD; bool soft = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_SOFT) == TextServer::GRAPHEME_IS_BREAK_SOFT; @@ -329,9 +371,9 @@ TEST_SUITE("[TextServer]") { bool virt = (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL; bool elo = (glyphs[j].flags & TextServer::GRAPHEME_IS_ELONGATION) == TextServer::GRAPHEME_IS_ELONGATION; if (j == 4 || j == 9 || j == 16 || j == 20) { - TEST_FAIL_COND((!soft || !space || hard || virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((!soft || !space || hard || virt || elo), "Invalid glyph flags."); } else { - TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((soft || space || hard || virt || elo), "Invalid glyph flags."); } } ts->free_rid(ctx); @@ -340,16 +382,16 @@ TEST_SUITE("[TextServer]") { if (ts->has_feature(TextServer::FEATURE_BREAK_ITERATORS)) { String test = U"เป็นภาษาราชการและภาษา"; RID ctx = ts->create_shaped_text(); - TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); + CHECK_FALSE_MESSAGE(ctx == RID(), "Creating text buffer failed."); bool ok = ts->shaped_text_add_string(ctx, test, font, 16); - TEST_FAIL_COND(!ok, "Adding text to the buffer failed."); + CHECK_FALSE_MESSAGE(!ok, "Adding text to the buffer failed."); ts->shaped_text_update_breaks(ctx); ts->shaped_text_update_justification_ops(ctx); const Glyph *glyphs = ts->shaped_text_get_glyphs(ctx); int gl_size = ts->shaped_text_get_glyph_count(ctx); - TEST_FAIL_COND(gl_size != 25, "Invalid glyph count."); + CHECK_FALSE_MESSAGE(gl_size != 25, "Invalid glyph count."); for (int j = 0; j < gl_size; j++) { bool hard = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_HARD) == TextServer::GRAPHEME_IS_BREAK_HARD; bool soft = (glyphs[j].flags & TextServer::GRAPHEME_IS_BREAK_SOFT) == TextServer::GRAPHEME_IS_BREAK_SOFT; @@ -357,9 +399,9 @@ TEST_SUITE("[TextServer]") { bool virt = (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL; bool elo = (glyphs[j].flags & TextServer::GRAPHEME_IS_ELONGATION) == TextServer::GRAPHEME_IS_ELONGATION; if (j == 4 || j == 9 || j == 16 || j == 20) { - TEST_FAIL_COND((!soft || !space || hard || !virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((!soft || !space || hard || !virt || elo), "Invalid glyph flags."); } else { - TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); + CHECK_FALSE_MESSAGE((soft || space || hard || virt || elo), "Invalid glyph flags."); } } ts->free_rid(ctx); @@ -375,7 +417,7 @@ TEST_SUITE("[TextServer]") { SUBCASE("[TextServer] Text layout: Line breaking") { for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); - TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + CHECK_FALSE_MESSAGE(ts.is_null(), "Invalid TS interface."); if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { continue; @@ -394,21 +436,21 @@ TEST_SUITE("[TextServer]") { font.push_back(font2); RID ctx = ts->create_shaped_text(); - TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); + CHECK_FALSE_MESSAGE(ctx == RID(), "Creating text buffer failed."); bool ok = ts->shaped_text_add_string(ctx, test_1, font, 16); - TEST_FAIL_COND(!ok, "Adding text to the buffer failed."); + CHECK_FALSE_MESSAGE(!ok, "Adding text to the buffer failed."); PackedInt32Array brks = ts->shaped_text_get_line_breaks(ctx, 1); - TEST_FAIL_COND(brks.size() != 6, "Invalid line breaks number."); + CHECK_FALSE_MESSAGE(brks.size() != 6, "Invalid line breaks number."); if (brks.size() == 6) { - TEST_FAIL_COND(brks[0] != 0, "Invalid line break position."); - TEST_FAIL_COND(brks[1] != 5, "Invalid line break position."); + CHECK_FALSE_MESSAGE(brks[0] != 0, "Invalid line break position."); + CHECK_FALSE_MESSAGE(brks[1] != 5, "Invalid line break position."); - TEST_FAIL_COND(brks[2] != 5, "Invalid line break position."); - TEST_FAIL_COND(brks[3] != 10, "Invalid line break position."); + CHECK_FALSE_MESSAGE(brks[2] != 5, "Invalid line break position."); + CHECK_FALSE_MESSAGE(brks[3] != 10, "Invalid line break position."); - TEST_FAIL_COND(brks[4] != 10, "Invalid line break position."); - TEST_FAIL_COND(brks[5] != 14, "Invalid line break position."); + CHECK_FALSE_MESSAGE(brks[4] != 10, "Invalid line break position."); + CHECK_FALSE_MESSAGE(brks[5] != 14, "Invalid line break position."); } ts->free_rid(ctx); @@ -423,7 +465,7 @@ TEST_SUITE("[TextServer]") { SUBCASE("[TextServer] Text layout: Justification") { for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); - TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + CHECK_FALSE_MESSAGE(ts.is_null(), "Invalid TS interface."); if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { continue; @@ -448,40 +490,40 @@ TEST_SUITE("[TextServer]") { float width_old, width; if (ts->has_feature(TextServer::FEATURE_KASHIDA_JUSTIFICATION)) { ctx = ts->create_shaped_text(); - TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); + CHECK_FALSE_MESSAGE(ctx == RID(), "Creating text buffer failed."); ok = ts->shaped_text_add_string(ctx, test_1, font, 16); - TEST_FAIL_COND(!ok, "Adding text to the buffer failed."); + CHECK_FALSE_MESSAGE(!ok, "Adding text to the buffer failed."); width_old = ts->shaped_text_get_width(ctx); width = ts->shaped_text_fit_to_width(ctx, 100, TextServer::JUSTIFICATION_WORD_BOUND); - TEST_FAIL_COND((width != width_old), "Invalid fill width."); + CHECK_FALSE_MESSAGE((width != width_old), "Invalid fill width."); width = ts->shaped_text_fit_to_width(ctx, 100, TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA); - TEST_FAIL_COND((width <= width_old || width > 100), "Invalid fill width."); + CHECK_FALSE_MESSAGE((width <= width_old || width > 100), "Invalid fill width."); ts->free_rid(ctx); ctx = ts->create_shaped_text(); - TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); + CHECK_FALSE_MESSAGE(ctx == RID(), "Creating text buffer failed."); ok = ts->shaped_text_add_string(ctx, test_2, font, 16); - TEST_FAIL_COND(!ok, "Adding text to the buffer failed."); + CHECK_FALSE_MESSAGE(!ok, "Adding text to the buffer failed."); width_old = ts->shaped_text_get_width(ctx); width = ts->shaped_text_fit_to_width(ctx, 100, TextServer::JUSTIFICATION_WORD_BOUND); - TEST_FAIL_COND((width <= width_old || width > 100), "Invalid fill width."); + CHECK_FALSE_MESSAGE((width <= width_old || width > 100), "Invalid fill width."); width = ts->shaped_text_fit_to_width(ctx, 100, TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA); - TEST_FAIL_COND((width <= width_old || width > 100), "Invalid fill width."); + CHECK_FALSE_MESSAGE((width <= width_old || width > 100), "Invalid fill width."); ts->free_rid(ctx); } ctx = ts->create_shaped_text(); - TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); + CHECK_FALSE_MESSAGE(ctx == RID(), "Creating text buffer failed."); ok = ts->shaped_text_add_string(ctx, test_3, font, 16); - TEST_FAIL_COND(!ok, "Adding text to the buffer failed."); + CHECK_FALSE_MESSAGE(!ok, "Adding text to the buffer failed."); width_old = ts->shaped_text_get_width(ctx); width = ts->shaped_text_fit_to_width(ctx, 100, TextServer::JUSTIFICATION_WORD_BOUND); - TEST_FAIL_COND((width <= width_old || width > 100), "Invalid fill width."); + CHECK_FALSE_MESSAGE((width <= width_old || width > 100), "Invalid fill width."); ts->free_rid(ctx); @@ -495,7 +537,7 @@ TEST_SUITE("[TextServer]") { SUBCASE("[TextServer] Unicode identifiers") { for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); - TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + CHECK_FALSE_MESSAGE(ts.is_null(), "Invalid TS interface."); static const char32_t *data[19] = { U"-30", U"100", U"10.1", U"10,1", U"1e2", U"1e-2", U"1e2e3", U"0xAB", U"AB", U"Test1", U"1Test", U"Test*1", U"test_testeT", U"test_tes teT", U"عَلَيْكُمْ", U"عَلَيْكُمْTest", U"ӒӖӚӜ", U"_test", U"ÂÃÄÅĀĂĄÇĆĈĊ" }; static bool isid[19] = { false, false, false, false, false, false, false, false, true, true, false, false, true, false, true, true, true, true, true }; @@ -516,7 +558,7 @@ TEST_SUITE("[TextServer]") { SUBCASE("[TextServer] Strip Diacritics") { for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); - TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + CHECK_FALSE_MESSAGE(ts.is_null(), "Invalid TS interface."); if (ts->has_feature(TextServer::FEATURE_SHAPING)) { CHECK(ts->strip_diacritics(U"ٱلسَّلَامُ عَلَيْكُمْ") == U"ٱلسلام عليكم"); @@ -544,7 +586,7 @@ TEST_SUITE("[TextServer]") { continue; } - TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + CHECK_FALSE_MESSAGE(ts.is_null(), "Invalid TS interface."); { String text1 = U"linguistically similar and effectively form"; // 14^ 22^ 26^ 38^ |