diff options
285 files changed, 4120 insertions, 3346 deletions
diff --git a/.gitignore b/.gitignore index 0ef640bd2f..539003ca6b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ ########################### /custom.py +misc/hooks/pre-commit-custom-* ############################# ### Godot generated files ### diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index d46e242610..74c06123e1 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -72,7 +72,7 @@ String ProjectSettings::get_safe_project_name() const { } String ProjectSettings::get_imported_files_path() const { - return get_project_data_path().plus_file("imported"); + return get_project_data_path().path_join("imported"); } // Returns the features that a project must have when opened with this build of Godot. @@ -157,12 +157,12 @@ String ProjectSettings::localize_path(const String &p_path) const { // in an absolute path that just happens to contain this string but points to a // different folder (e.g. "/my/project" as resource_path would be contained in // "/my/project_data", even though the latter is not part of res://. - // `plus_file("")` is an easy way to ensure we have a trailing '/'. - const String res_path = resource_path.plus_file(""); + // `path_join("")` is an easy way to ensure we have a trailing '/'. + const String res_path = resource_path.path_join(""); // DirAccess::get_current_dir() is not guaranteed to return a path that with a trailing '/', // so we must make sure we have it as well in order to compare with 'res_path'. - cwd = cwd.plus_file(""); + cwd = cwd.path_join(""); if (!cwd.begins_with(res_path)) { return p_path; @@ -472,7 +472,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b if (err == OK && !p_ignore_override) { // Load override from location of the main pack // Optional, we don't mind if it fails - _load_settings_text(p_main_pack.get_base_dir().plus_file("override.cfg")); + _load_settings_text(p_main_pack.get_base_dir().path_join("override.cfg")); } return err; } @@ -500,14 +500,14 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b #ifdef MACOS_ENABLED if (!found) { // Attempt to load PCK from macOS .app bundle resources. - found = _load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().plus_file(exec_basename + ".pck")) || _load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().plus_file(exec_filename + ".pck")); + found = _load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().path_join(exec_basename + ".pck")) || _load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().path_join(exec_filename + ".pck")); } #endif if (!found) { // Try to load data pack at the location of the executable. // As mentioned above, we have two potential names to attempt. - found = _load_resource_pack(exec_dir.plus_file(exec_basename + ".pck")) || _load_resource_pack(exec_dir.plus_file(exec_filename + ".pck")); + found = _load_resource_pack(exec_dir.path_join(exec_basename + ".pck")) || _load_resource_pack(exec_dir.path_join(exec_filename + ".pck")); } if (!found) { @@ -523,7 +523,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b // Load overrides from the PCK and the executable location. // Optional, we don't mind if either fails. _load_settings_text("res://override.cfg"); - _load_settings_text(exec_path.get_base_dir().plus_file("override.cfg")); + _load_settings_text(exec_path.get_base_dir().path_join("override.cfg")); } return err; } @@ -556,10 +556,10 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b // Set the resource path early so things can be resolved when loading. resource_path = current_dir; resource_path = resource_path.replace("\\", "/"); // Windows path to Unix path just in case. - err = _load_settings_text_or_binary(current_dir.plus_file("project.godot"), current_dir.plus_file("project.binary")); + err = _load_settings_text_or_binary(current_dir.path_join("project.godot"), current_dir.path_join("project.binary")); if (err == OK && !p_ignore_override) { // Optional, we don't mind if it fails. - _load_settings_text(current_dir.plus_file("override.cfg")); + _load_settings_text(current_dir.path_join("override.cfg")); found = true; break; } @@ -685,7 +685,7 @@ Error ProjectSettings::_load_settings_text(const String &p_path) { // If we're loading a project.godot from source code, we can operate some // ProjectSettings conversions if need be. _convert_to_last_version(config_version); - last_save_time = FileAccess::get_modified_time(get_resource_path().plus_file("project.godot")); + last_save_time = FileAccess::get_modified_time(get_resource_path().path_join("project.godot")); return OK; } ERR_FAIL_COND_V_MSG(err != OK, err, "Error parsing " + p_path + " at line " + itos(lines) + ": " + error_text + " File might be corrupted."); @@ -764,9 +764,9 @@ void ProjectSettings::clear(const String &p_name) { } Error ProjectSettings::save() { - Error error = save_custom(get_resource_path().plus_file("project.godot")); + Error error = save_custom(get_resource_path().path_join("project.godot")); if (error == OK) { - last_save_time = FileAccess::get_modified_time(get_resource_path().plus_file("project.godot")); + last_save_time = FileAccess::get_modified_time(get_resource_path().path_join("project.godot")); } return error; } @@ -911,7 +911,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust } } // Check for the existence of a csproj file. - if (FileAccess::exists(get_resource_path().plus_file(get_safe_project_name() + ".csproj"))) { + if (FileAccess::exists(get_resource_path().path_join(get_safe_project_name() + ".csproj"))) { // If there is a csproj file, add the C# feature if it doesn't already exist. if (!project_features.has("C#")) { project_features.append("C#"); diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index fdb4e50d90..6418da2235 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -36,7 +36,7 @@ #include "core/os/os.h" String NativeExtension::get_extension_list_config_file() { - return ProjectSettings::get_singleton()->get_project_data_path().plus_file("extension_list.cfg"); + return ProjectSettings::get_singleton()->get_project_data_path().path_join("extension_list.cfg"); } class NativeExtensionMethodBind : public MethodBind { @@ -421,7 +421,7 @@ Ref<Resource> NativeExtensionResourceLoader::load(const String &p_path, const St } if (!library_path.is_resource_file() && !library_path.is_absolute_path()) { - library_path = p_path.get_base_dir().plus_file(library_path); + library_path = p_path.get_base_dir().path_join(library_path); } Ref<NativeExtension> lib; diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp index f82d6f077f..bed41b8d89 100644 --- a/core/io/dir_access.cpp +++ b/core/io/dir_access.cpp @@ -106,7 +106,7 @@ static Error _erase_recursive(DirAccess *da) { if (err) { return err; } - err = da->remove(da->get_current_dir().plus_file(E)); + err = da->remove(da->get_current_dir().path_join(E)); if (err) { return err; } @@ -116,7 +116,7 @@ static Error _erase_recursive(DirAccess *da) { } for (const String &E : files) { - Error err = da->remove(da->get_current_dir().plus_file(E)); + Error err = da->remove(da->get_current_dir().path_join(E)); if (err) { return err; } @@ -138,7 +138,7 @@ Error DirAccess::make_dir_recursive(String p_dir) { if (p_dir.is_relative_path()) { //append current - full_dir = get_current_dir().plus_file(p_dir); + full_dir = get_current_dir().path_join(p_dir); } else { full_dir = p_dir; @@ -172,7 +172,7 @@ Error DirAccess::make_dir_recursive(String p_dir) { String curpath = base; for (int i = 0; i < subdirs.size(); i++) { - curpath = curpath.plus_file(subdirs[i]); + curpath = curpath.path_join(subdirs[i]); Error err = make_dir(curpath); if (err != OK && err != ERR_ALREADY_EXISTS) { ERR_FAIL_V_MSG(err, "Could not create directory: " + curpath); @@ -354,8 +354,8 @@ Error DirAccess::_copy_dir(Ref<DirAccess> &p_target_da, String p_to, int p_chmod String n = get_next(); while (!n.is_empty()) { if (n != "." && n != "..") { - if (p_copy_links && is_link(get_current_dir().plus_file(n))) { - create_link(read_link(get_current_dir().plus_file(n)), p_to + n); + if (p_copy_links && is_link(get_current_dir().path_join(n))) { + create_link(read_link(get_current_dir().path_join(n)), p_to + n); } else if (current_is_dir()) { dirs.push_back(n); } else { @@ -364,7 +364,7 @@ Error DirAccess::_copy_dir(Ref<DirAccess> &p_target_da, String p_to, int p_chmod list_dir_end(); return ERR_BUG; } - Error err = copy(get_current_dir().plus_file(n), p_to + rel_path, p_chmod_flags); + Error err = copy(get_current_dir().path_join(n), p_to + rel_path, p_chmod_flags); if (err) { list_dir_end(); return err; diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 595a6e9873..adae0db0f4 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -520,7 +520,7 @@ String DirAccessPack::get_current_dir(bool p_include_drive) const { while (pd->parent) { pd = pd->parent; - p = pd->name.plus_file(p); + p = pd->name.path_join(p); } return "res://" + p; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index b731608b4f..4f1204fc48 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -421,7 +421,7 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) { if (!path.contains("://") && path.is_relative_path()) { // path is relative to file being loaded, so convert to a resource path - path = ProjectSettings::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path)); + path = ProjectSettings::get_singleton()->localize_path(res_path.get_base_dir().path_join(path)); } if (remaps.find(path)) { @@ -683,7 +683,7 @@ Error ResourceLoaderBinary::load() { if (!path.contains("://") && path.is_relative_path()) { // path is relative to file being loaded, so convert to a resource path - path = ProjectSettings::get_singleton()->localize_path(path.get_base_dir().plus_file(external_resources[i].path)); + path = ProjectSettings::get_singleton()->localize_path(path.get_base_dir().path_join(external_resources[i].path)); } external_resources.write[i].path = path; //remap happens here, not on load because on load it can actually be used for filesystem dock resource remap @@ -1329,7 +1329,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons bool relative = false; if (!path.begins_with("res://")) { - path = local_path.plus_file(path).simplify_path(); + path = local_path.path_join(path).simplify_path(); relative = true; } diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index e059fc842b..aa7f96a047 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -421,7 +421,7 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const St } String ResourceFormatImporter::get_import_base_path(const String &p_for_file) const { - return ProjectSettings::get_singleton()->get_imported_files_path().plus_file(p_for_file.get_file() + "-" + p_for_file.md5_text()); + return ProjectSettings::get_singleton()->get_imported_files_path().path_join(p_for_file.get_file() + "-" + p_for_file.md5_text()); } bool ResourceFormatImporter::are_import_settings_valid(const String &p_path) const { diff --git a/core/io/resource_uid.cpp b/core/io/resource_uid.cpp index fc324a26da..5324c5dd84 100644 --- a/core/io/resource_uid.cpp +++ b/core/io/resource_uid.cpp @@ -39,7 +39,7 @@ static constexpr uint32_t char_count = ('z' - 'a'); static constexpr uint32_t base = char_count + ('9' - '0'); String ResourceUID::get_cache_file() { - return ProjectSettings::get_singleton()->get_project_data_path().plus_file("uid_cache.bin"); + return ProjectSettings::get_singleton()->get_project_data_path().path_join("uid_cache.bin"); } String ResourceUID::id_to_text(ID p_id) const { diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 0c43ba9ccc..d8b93998af 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -970,62 +970,71 @@ const char32_t *String::get_data() const { return size() ? &operator[](0) : &zero; } -String String::capitalize() const { - String aux = this->camelcase_to_underscore(true).replace("_", " ").strip_edges(); - String cap; - for (int i = 0; i < aux.get_slice_count(" "); i++) { - String slice = aux.get_slicec(' ', i); - if (slice.length() > 0) { - slice[0] = _find_upper(slice[0]); - if (i > 0) { - cap += " "; - } - cap += slice; - } - } - - return cap; -} - -String String::camelcase_to_underscore(bool lowercase) const { +String String::_camelcase_to_underscore() const { const char32_t *cstr = get_data(); String new_string; int start_index = 0; for (int i = 1; i < this->size(); i++) { - bool is_upper = is_ascii_upper_case(cstr[i]); - bool is_number = is_digit(cstr[i]); + bool is_prev_upper = is_ascii_upper_case(cstr[i - 1]); + bool is_prev_lower = is_ascii_lower_case(cstr[i - 1]); + bool is_prev_digit = is_digit(cstr[i - 1]); - bool are_next_2_lower = false; - bool is_next_lower = false; - bool is_next_number = false; - bool was_precedent_upper = is_ascii_upper_case(cstr[i - 1]); - bool was_precedent_number = is_digit(cstr[i - 1]); - - if (i + 2 < this->size()) { - are_next_2_lower = is_ascii_lower_case(cstr[i + 1]) && is_ascii_lower_case(cstr[i + 2]); - } + bool is_curr_upper = is_ascii_upper_case(cstr[i]); + bool is_curr_lower = is_ascii_lower_case(cstr[i]); + bool is_curr_digit = is_digit(cstr[i]); + bool is_next_lower = false; if (i + 1 < this->size()) { is_next_lower = is_ascii_lower_case(cstr[i + 1]); - is_next_number = is_digit(cstr[i + 1]); } - const bool cond_a = is_upper && !was_precedent_upper && !was_precedent_number; - const bool cond_b = was_precedent_upper && is_upper && are_next_2_lower; - const bool cond_c = is_number && !was_precedent_number; - const bool can_break_number_letter = is_number && !was_precedent_number && is_next_lower; - const bool can_break_letter_number = !is_number && was_precedent_number && (is_next_lower || is_next_number); + const bool cond_a = is_prev_lower && is_curr_upper; // aA + const bool cond_b = (is_prev_upper || is_prev_digit) && is_curr_upper && is_next_lower; // AAa, 2Aa + const bool cond_c = is_prev_digit && is_curr_lower && is_next_lower; // 2aa + const bool cond_d = (is_prev_upper || is_prev_lower) && is_curr_digit; // A2, a2 - bool should_split = cond_a || cond_b || cond_c || can_break_number_letter || can_break_letter_number; - if (should_split) { + if (cond_a || cond_b || cond_c || cond_d) { new_string += this->substr(start_index, i - start_index) + "_"; start_index = i; } } new_string += this->substr(start_index, this->size() - start_index); - return lowercase ? new_string.to_lower() : new_string; + return new_string.to_lower(); +} + +String String::capitalize() const { + String aux = this->_camelcase_to_underscore().replace("_", " ").strip_edges(); + String cap; + for (int i = 0; i < aux.get_slice_count(" "); i++) { + String slice = aux.get_slicec(' ', i); + if (slice.length() > 0) { + slice[0] = _find_upper(slice[0]); + if (i > 0) { + cap += " "; + } + cap += slice; + } + } + + return cap; +} + +String String::to_camel_case() const { + String s = this->to_pascal_case(); + if (!s.is_empty()) { + s[0] = _find_lower(s[0]); + } + return s; +} + +String String::to_pascal_case() const { + return this->capitalize().replace(" ", ""); +} + +String String::to_snake_case() const { + return this->_camelcase_to_underscore().replace(" ", "_").strip_edges(); } String String::get_with_code_lines() const { @@ -4451,7 +4460,7 @@ String String::get_extension() const { return substr(pos + 1, length()); } -String String::plus_file(const String &p_file) const { +String String::path_join(const String &p_file) const { if (is_empty()) { return p_file; } diff --git a/core/string/ustring.h b/core/string/ustring.h index 6c3169f136..31de7cc464 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -196,6 +196,7 @@ class String { bool _base_is_subsequence_of(const String &p_string, bool case_insensitive) const; int _count(const String &p_string, int p_from, int p_to, bool p_case_insensitive) const; + String _camelcase_to_underscore() const; public: enum { @@ -335,7 +336,9 @@ public: static double to_float(const char32_t *p_str, const char32_t **r_end = nullptr); String capitalize() const; - String camelcase_to_underscore(bool lowercase = true) const; + String to_camel_case() const; + String to_pascal_case() const; + String to_snake_case() const; String get_with_code_lines() const; int get_slice_count(String p_splitter) const; @@ -370,7 +373,7 @@ public: String rstrip(const String &p_chars) const; String get_extension() const; String get_basename() const; - String plus_file(const String &p_file) const; + String path_join(const String &p_file) const; char32_t unicode_at(int p_idx) const; void erase(int p_pos, int p_chars); diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 9b7dc5012b..8af2a09111 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1506,6 +1506,9 @@ static void _register_variant_builtin_methods() { bind_method(String, repeat, sarray("count"), varray()); bind_method(String, insert, sarray("position", "what"), varray()); bind_method(String, capitalize, sarray(), varray()); + bind_method(String, to_camel_case, sarray(), varray()); + bind_method(String, to_pascal_case, sarray(), varray()); + bind_method(String, to_snake_case, sarray(), varray()); bind_method(String, split, sarray("delimiter", "allow_empty", "maxsplit"), varray(true, 0)); bind_method(String, rsplit, sarray("delimiter", "allow_empty", "maxsplit"), varray(true, 0)); bind_method(String, split_floats, sarray("delimiter", "allow_empty"), varray(true)); @@ -1523,7 +1526,7 @@ static void _register_variant_builtin_methods() { bind_method(String, rstrip, sarray("chars"), varray()); bind_method(String, get_extension, sarray(), varray()); bind_method(String, get_basename, sarray(), varray()); - bind_method(String, plus_file, sarray("file"), varray()); + bind_method(String, path_join, sarray("file"), varray()); bind_method(String, unicode_at, sarray("at"), varray()); bind_method(String, indent, sarray("prefix"), varray()); bind_method(String, dedent, sarray(), varray()); diff --git a/doc/classes/BaseMaterial3D.xml b/doc/classes/BaseMaterial3D.xml index 33a129a48e..2262c4fe47 100644 --- a/doc/classes/BaseMaterial3D.xml +++ b/doc/classes/BaseMaterial3D.xml @@ -82,7 +82,7 @@ The hashing scale for Alpha Hash. Recommended values between [code]0[/code] and [code]2[/code]. </member> <member name="alpha_scissor_threshold" type="float" setter="set_alpha_scissor_threshold" getter="get_alpha_scissor_threshold"> - Threshold at which the alpha scissor will discard values. + Threshold at which the alpha scissor will discard values. Higher values will result in more pixels being discarded. If the material becomes too opaque at a distance, try increasing [member alpha_scissor_threshold]. If the material disappears at a distance, try decreasing [member alpha_scissor_threshold]. </member> <member name="anisotropy" type="float" setter="set_anisotropy" getter="get_anisotropy" default="0.0"> The strength of the anisotropy effect. This is multiplied by [member anisotropy_flowmap]'s alpha channel if a texture is defined there and the texture contains an alpha channel. diff --git a/doc/classes/CPUParticles3D.xml b/doc/classes/CPUParticles3D.xml index 99fd0501fc..6b39c08b3f 100644 --- a/doc/classes/CPUParticles3D.xml +++ b/doc/classes/CPUParticles3D.xml @@ -123,13 +123,16 @@ Minimum particle animation speed. </member> <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> - Each particle's initial color. To have particle display color in a [BaseMaterial3D] make sure to set [member BaseMaterial3D.vertex_color_use_as_albedo] to [code]true[/code]. + Each particle's initial color. + [b]Note:[/b] [member color] multiplies the particle mesh's vertex colors. To have a visible effect on a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color] will have no visible effect. </member> <member name="color_initial_ramp" type="Gradient" setter="set_color_initial_ramp" getter="get_color_initial_ramp"> Each particle's initial color will vary along this [GradientTexture1D] (multiplied with [member color]). + [b]Note:[/b] [member color_initial_ramp] multiplies the particle mesh's vertex colors. To have a visible effect on a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color_initial_ramp] will have no visible effect. </member> <member name="color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp"> Each particle's color will vary along this [GradientTexture1D] over its lifetime (multiplied with [member color]). + [b]Note:[/b] [member color_ramp] multiplies the particle mesh's vertex colors. To have a visible effect on a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color_ramp] will have no visible effect. </member> <member name="damping_curve" type="Curve" setter="set_param_curve" getter="get_param_curve"> Damping will vary along this [Curve]. @@ -151,6 +154,7 @@ </member> <member name="emission_colors" type="PackedColorArray" setter="set_emission_colors" getter="get_emission_colors" default="PackedColorArray()"> Sets the [Color]s to modulate particles by when using [constant EMISSION_SHAPE_POINTS] or [constant EMISSION_SHAPE_DIRECTED_POINTS]. + [b]Note:[/b] [member emission_colors] multiplies the particle mesh's vertex colors. To have a visible effect on a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member emission_colors] will have no visible effect. </member> <member name="emission_normals" type="PackedVector3Array" setter="set_emission_normals" getter="get_emission_normals"> Sets the direction the particles will be emitted in when using [constant EMISSION_SHAPE_DIRECTED_POINTS]. diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml index d1fdca5814..d8c1af0b3c 100644 --- a/doc/classes/CanvasItem.xml +++ b/doc/classes/CanvasItem.xml @@ -5,7 +5,7 @@ </brief_description> <description> Base class of anything 2D. Canvas items are laid out in a tree; children inherit and extend their parent's transform. [CanvasItem] is extended by [Control] for anything GUI-related, and by [Node2D] for anything related to the 2D engine. - Any [CanvasItem] can draw. For this, [method update] is called by the engine, then [constant NOTIFICATION_DRAW] will be received on idle time to request redraw. Because of this, canvas items don't need to be redrawn on every frame, improving the performance significantly. Several functions for drawing on the [CanvasItem] are provided (see [code]draw_*[/code] functions). However, they can only be used inside [method _draw], its corresponding [method Object._notification] or methods connected to the [signal draw] signal. + Any [CanvasItem] can draw. For this, [method queue_redraw] is called by the engine, then [constant NOTIFICATION_DRAW] will be received on idle time to request redraw. Because of this, canvas items don't need to be redrawn on every frame, improving the performance significantly. Several functions for drawing on the [CanvasItem] are provided (see [code]draw_*[/code] functions). However, they can only be used inside [method _draw], its corresponding [method Object._notification] or methods connected to the [signal draw] signal. Canvas items are drawn in tree order. By default, children are on top of their parents so a root [CanvasItem] will be drawn behind everything. This behavior can be changed on a per-item basis. A [CanvasItem] can also be hidden, which will also hide its children. It provides many ways to change parameters such as modulation (for itself and its children) and self modulation (only for itself), as well as its blend mode. Ultimately, a transform notification can be requested, which will notify the node that its global position changed in case the parent tree changed. @@ -20,7 +20,7 @@ <method name="_draw" qualifiers="virtual"> <return type="void" /> <description> - Called when [CanvasItem] has been requested to redraw (when [method update] is called, either manually or by the engine). + Called when [CanvasItem] has been requested to redraw (after [method queue_redraw] is called, either manually or by the engine). Corresponds to the [constant NOTIFICATION_DRAW] notification in [method Object._notification]. </description> </method> @@ -500,6 +500,12 @@ Transformations issued by [param event]'s inputs are applied in local space instead of global space. </description> </method> + <method name="queue_redraw"> + <return type="void" /> + <description> + Queues the [CanvasItem] to redraw. During idle time, if [CanvasItem] is visible, [constant NOTIFICATION_DRAW] is sent and [method _draw] is called. This only occurs [b]once[/b] per frame, even if this method has been called multiple times. + </description> + </method> <method name="set_notify_local_transform"> <return type="void" /> <param index="0" name="enable" type="bool" /> @@ -520,12 +526,6 @@ Show the [CanvasItem] if it's currently hidden. This is equivalent to setting [member visible] to [code]true[/code]. For controls that inherit [Popup], the correct way to make them visible is to call one of the multiple [code]popup*()[/code] functions instead. </description> </method> - <method name="update"> - <return type="void" /> - <description> - Queues the [CanvasItem] to redraw. During idle time, if [CanvasItem] is visible, [constant NOTIFICATION_DRAW] is sent and [method _draw] is called. This only occurs [b]once[/b] per frame, even if this method has been called multiple times. - </description> - </method> </methods> <members> <member name="clip_children" type="bool" setter="set_clip_children" getter="is_clipping_children" default="false"> diff --git a/doc/classes/EditorProperty.xml b/doc/classes/EditorProperty.xml index 67204f2a15..7bac4bf7ac 100644 --- a/doc/classes/EditorProperty.xml +++ b/doc/classes/EditorProperty.xml @@ -105,6 +105,8 @@ <signal name="property_changed"> <param index="0" name="property" type="StringName" /> <param index="1" name="value" type="Variant" /> + <param index="2" name="field" type="StringName" /> + <param index="3" name="changing" type="bool" /> <description> Do not emit this manually, use the [method emit_changed] method instead. </description> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index b882425960..87edc7de0a 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -856,8 +856,8 @@ <constant name="NOTIFICATION_UNPARENTED" value="19"> Notification received when a node is unparented (parent removed it from the list of children). </constant> - <constant name="NOTIFICATION_INSTANCED" value="20"> - Notification received when the node is instantiated. + <constant name="NOTIFICATION_SCENE_INSTANTIATED" value="20"> + Notification received by scene owner when its scene is instantiated. </constant> <constant name="NOTIFICATION_DRAG_BEGIN" value="21"> Notification received when a drag operation begins. All nodes receive this notification, not only the dragged one. diff --git a/doc/classes/PackedScene.xml b/doc/classes/PackedScene.xml index 754d3ac73d..97595a6984 100644 --- a/doc/classes/PackedScene.xml +++ b/doc/classes/PackedScene.xml @@ -92,7 +92,7 @@ <return type="Node" /> <param index="0" name="edit_state" type="int" enum="PackedScene.GenEditState" default="0" /> <description> - Instantiates the scene's node hierarchy. Triggers child scene instantiation(s). Triggers a [constant Node.NOTIFICATION_INSTANCED] notification on the root node. + Instantiates the scene's node hierarchy. Triggers child scene instantiation(s). Triggers a [constant Node.NOTIFICATION_SCENE_INSTANTIATED] notification on the root node. </description> </method> <method name="pack"> diff --git a/doc/classes/ParticleProcessMaterial.xml b/doc/classes/ParticleProcessMaterial.xml index 1526658eed..a41207e9b3 100644 --- a/doc/classes/ParticleProcessMaterial.xml +++ b/doc/classes/ParticleProcessMaterial.xml @@ -129,13 +129,16 @@ Should collision take scale into account. </member> <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> - Each particle's initial color. If the [GPUParticles2D]'s [code]texture[/code] is defined, it will be multiplied by this color. To have particle display color in a [BaseMaterial3D] make sure to set [member BaseMaterial3D.vertex_color_use_as_albedo] to [code]true[/code]. + Each particle's initial color. If the [GPUParticles2D]'s [code]texture[/code] is defined, it will be multiplied by this color. + [b]Note:[/b] [member color] multiplies the particle mesh's vertex colors. To have a visible effect on a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color] will have no visible effect. </member> <member name="color_initial_ramp" type="Texture2D" setter="set_color_initial_ramp" getter="get_color_initial_ramp"> Each particle's initial color will vary along this [GradientTexture1D] (multiplied with [member color]). + [b]Note:[/b] [member color_initial_ramp] multiplies the particle mesh's vertex colors. To have a visible effect on a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color_initial_ramp] will have no visible effect. </member> <member name="color_ramp" type="Texture2D" setter="set_color_ramp" getter="get_color_ramp"> Each particle's color will vary along this [GradientTexture1D] over its lifetime (multiplied with [member color]). + [b]Note:[/b] [member color_ramp] multiplies the particle mesh's vertex colors. To have a visible effect on a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color_ramp] will have no visible effect. </member> <member name="damping_curve" type="Texture2D" setter="set_param_texture" getter="get_param_texture"> Damping will vary along this [CurveTexture]. @@ -154,6 +157,7 @@ </member> <member name="emission_color_texture" type="Texture2D" setter="set_emission_color_texture" getter="get_emission_color_texture"> Particle color will be modulated by color determined by sampling this texture at the same point as the [member emission_point_texture]. + [b]Note:[/b] [member emission_color_texture] multiplies the particle mesh's vertex colors. To have a visible effect on a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member emission_color_texture] will have no visible effect. </member> <member name="emission_normal_texture" type="Texture2D" setter="set_emission_normal_texture" getter="get_emission_normal_texture"> Particle velocity and rotation will be set by sampling this texture at the same point as the [member emission_point_texture]. Used only in [constant EMISSION_SHAPE_DIRECTED_POINTS]. Can be created automatically from mesh or node by selecting "Create Emission Points from Mesh/Node" under the "Particles" tool in the toolbar. diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 8f749f3a37..e8e8ca3725 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -100,7 +100,7 @@ # `path` will contain the absolute path to `hello.txt` next to the executable. # This is *not* identical to using `ProjectSettings.globalize_path()` with a `res://` path, # but is close enough in spirit. - path = OS.get_executable_path().get_base_dir().plus_file("hello.txt") + path = OS.get_executable_path().get_base_dir().path_join("hello.txt") [/codeblock] </description> </method> @@ -1639,8 +1639,11 @@ </member> <member name="rendering/2d/snap/snap_2d_vertices_to_pixel" type="bool" setter="" getter="" default="false"> </member> - <member name="rendering/anti_aliasing/quality/msaa" type="int" setter="" getter="" default="0"> - Sets the number of MSAA samples to use (as a power of two). MSAA is used to reduce aliasing around the edges of polygons. A higher MSAA value results in smoother edges but can be significantly slower on some hardware. See also bilinear scaling 3d [member rendering/scaling_3d/mode] for supersampling, which provides higher quality but is much more expensive. + <member name="rendering/anti_aliasing/quality/msaa_2d" type="int" setter="" getter="" default="0"> + Sets the number of MSAA samples to use for 2D/Canvas rendering (as a power of two). MSAA is used to reduce aliasing around the edges of polygons. A higher MSAA value results in smoother edges but can be significantly slower on some hardware. This has no effect on shader-induced aliasing or texture aliasing. + </member> + <member name="rendering/anti_aliasing/quality/msaa_3d" type="int" setter="" getter="" default="0"> + Sets the number of MSAA samples to use for 3D rendering (as a power of two). MSAA is used to reduce aliasing around the edges of polygons. A higher MSAA value results in smoother edges but can be significantly slower on some hardware. See also bilinear scaling 3d [member rendering/scaling_3d/mode] for supersampling, which provides higher quality but is much more expensive. This has no effect on shader-induced aliasing or texture aliasing. </member> <member name="rendering/anti_aliasing/quality/screen_space_aa" type="int" setter="" getter="" default="0"> Sets the screen-space antialiasing mode for the default screen [Viewport]. Screen-space antialiasing works by selectively blurring edges in a post-process shader. It differs from MSAA which takes multiple coverage samples while rendering objects. Screen-space AA methods are typically faster than MSAA and will smooth out specular aliasing, but tend to make scenes appear blurry. The blurriness is partially counteracted by automatically using a negative mipmap LOD bias (see [member rendering/textures/default_filters/texture_mipmap_bias]). @@ -1874,7 +1877,7 @@ Sets the scaling 3D mode. Bilinear scaling renders at different resolution to either undersample or supersample the viewport. FidelityFX Super Resolution 1.0, abbreviated to FSR, is an upscaling technology that produces high quality images at fast framerates by using a spatially aware upscaling algorithm. FSR is slightly more expensive than bilinear, but it produces significantly higher image quality. FSR should be used where possible. </member> <member name="rendering/scaling_3d/scale" type="float" setter="" getter="" default="1.0"> - Scales the 3D render buffer based on the viewport size uses an image filter specified in [member rendering/scaling_3d/mode] to scale the output image to the full viewport size. Values lower than [code]1.0[/code] can be used to speed up 3D rendering at the cost of quality (undersampling). Values greater than [code]1.0[/code] are only valid for bilinear mode and can be used to improve 3D rendering quality at a high performance cost (supersampling). See also [member rendering/anti_aliasing/quality/msaa] for multi-sample antialiasing, which is significantly cheaper but only smoothens the edges of polygons. + Scales the 3D render buffer based on the viewport size uses an image filter specified in [member rendering/scaling_3d/mode] to scale the output image to the full viewport size. Values lower than [code]1.0[/code] can be used to speed up 3D rendering at the cost of quality (undersampling). Values greater than [code]1.0[/code] are only valid for bilinear mode and can be used to improve 3D rendering quality at a high performance cost (supersampling). See also [member rendering/anti_aliasing/quality/msaa_3d] for multi-sample antialiasing, which is significantly cheaper but only smooths the edges of polygons. </member> <member name="rendering/shader_compiler/shader_cache/compress" type="bool" setter="" getter="" default="true"> </member> diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index 639db6b3b5..755e8a5839 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -3208,12 +3208,20 @@ <description> </description> </method> - <method name="viewport_set_msaa"> + <method name="viewport_set_msaa_2d"> <return type="void" /> <param index="0" name="viewport" type="RID" /> <param index="1" name="msaa" type="int" enum="RenderingServer.ViewportMSAA" /> <description> - Sets the anti-aliasing mode. See [enum ViewportMSAA] for options. + Sets the multisample anti-aliasing mode for 2D/Canvas. See [enum ViewportMSAA] for options. + </description> + </method> + <method name="viewport_set_msaa_3d"> + <return type="void" /> + <param index="0" name="viewport" type="RID" /> + <param index="1" name="msaa" type="int" enum="RenderingServer.ViewportMSAA" /> + <description> + Sets the multisample anti-aliasing mode for 3D. See [enum ViewportMSAA] for options. </description> </method> <method name="viewport_set_occlusion_culling_build_quality"> diff --git a/doc/classes/String.xml b/doc/classes/String.xml index f1cd4d72f7..316bb923b7 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -566,11 +566,11 @@ Formats a number to have an exact number of [param digits] before the decimal point. </description> </method> - <method name="plus_file" qualifiers="const"> + <method name="path_join" qualifiers="const"> <return type="String" /> <param index="0" name="file" type="String" /> <description> - If the string is a path, this concatenates [param file] at the end of the string as a subpath. E.g. [code]"this/is".plus_file("path") == "this/is/path"[/code]. + If the string is a path, this concatenates [param file] at the end of the string as a subpath. E.g. [code]"this/is".path_join("path") == "this/is/path"[/code]. </description> </method> <method name="repeat" qualifiers="const"> @@ -775,6 +775,12 @@ Converts the String (which is a character array) to ASCII/Latin-1 encoded [PackedByteArray] (which is an array of bytes). The conversion is faster compared to [method to_utf8_buffer], as this method assumes that all the characters in the String are ASCII/Latin-1 characters, unsupported characters are replaced with spaces. </description> </method> + <method name="to_camel_case" qualifiers="const"> + <return type="String" /> + <description> + Returns the string converted to [code]camelCase[/code]. + </description> + </method> <method name="to_float" qualifiers="const"> <return type="float" /> <description> @@ -804,6 +810,18 @@ Returns the string converted to lowercase. </description> </method> + <method name="to_pascal_case" qualifiers="const"> + <return type="String" /> + <description> + Returns the string converted to [code]PascalCase[/code]. + </description> + </method> + <method name="to_snake_case" qualifiers="const"> + <return type="String" /> + <description> + Returns the string converted to [code]snake_case[/code]. + </description> + </method> <method name="to_upper" qualifiers="const"> <return type="String" /> <description> diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml index 74f258072c..302f9b329b 100644 --- a/doc/classes/TabContainer.xml +++ b/doc/classes/TabContainer.xml @@ -258,5 +258,8 @@ <theme_item name="tab_unselected" data_type="style" type="StyleBox"> The style of the other, unselected tabs. </theme_item> + <theme_item name="tabbar_background" data_type="style" type="StyleBox"> + The style for the background fill of the [TabBar] area. + </theme_item> </theme_items> </class> diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml index 6d4408cf61..fdae6d205d 100644 --- a/doc/classes/TreeItem.xml +++ b/doc/classes/TreeItem.xml @@ -16,9 +16,9 @@ <param index="1" name="button" type="Texture2D" /> <param index="2" name="id" type="int" default="-1" /> <param index="3" name="disabled" type="bool" default="false" /> - <param index="4" name="tooltip" type="String" default="""" /> + <param index="4" name="tooltip_text" type="String" default="""" /> <description> - Adds a button with [Texture2D] [param button] at column [param column]. The [param id] is used to identify the button. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately before this method. Optionally, the button can be [param disabled] and have a [param tooltip]. + Adds a button with [Texture2D] [param button] at column [param column]. The [param id] is used to identify the button. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately before this method. Optionally, the button can be [param disabled] and have a [param tooltip_text]. </description> </method> <method name="call_recursive" qualifiers="vararg"> @@ -96,12 +96,12 @@ Returns the id for the button at index [param button_idx] in column [param column]. </description> </method> - <method name="get_button_tooltip" qualifiers="const"> + <method name="get_button_tooltip_text" qualifiers="const"> <return type="String" /> <param index="0" name="column" type="int" /> <param index="1" name="button_idx" type="int" /> <description> - Returns the tooltip string for the button at index [param button_idx] in column [param column]. + Returns the tooltip text for the button at index [param button_idx] in column [param column]. </description> </method> <method name="get_cell_mode" qualifiers="const"> @@ -308,11 +308,11 @@ Returns item's text base writing direction. </description> </method> - <method name="get_tooltip" qualifiers="const"> + <method name="get_tooltip_text" qualifiers="const"> <return type="String" /> <param index="0" name="column" type="int" /> <description> - Returns the given column's tooltip. + Returns the given column's tooltip text. </description> </method> <method name="get_tree" qualifiers="const"> @@ -639,7 +639,7 @@ Sets item's text base writing direction. </description> </method> - <method name="set_tooltip"> + <method name="set_tooltip_text"> <return type="void" /> <param index="0" name="column" type="int" /> <param index="1" name="tooltip" type="String" /> diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index 0071834ccd..87ee26fa32 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -218,8 +218,11 @@ To control this property on the root viewport, set the [member ProjectSettings.rendering/mesh_lod/lod_change/threshold_pixels] project setting. [b]Note:[/b] [member mesh_lod_threshold] does not affect [GeometryInstance3D] visibility ranges (also known as "manual" LOD or hierarchical LOD). </member> - <member name="msaa" type="int" setter="set_msaa" getter="get_msaa" enum="Viewport.MSAA" default="0"> - The multisample anti-aliasing mode. A higher number results in smoother edges at the cost of significantly worse performance. A value of 2 or 4 is best unless targeting very high-end systems. See also bilinear scaling 3d [member scaling_3d_mode] for supersampling, which provides higher quality but is much more expensive. + <member name="msaa_2d" type="int" setter="set_msaa_2d" getter="get_msaa_2d" enum="Viewport.MSAA" default="0"> + The multisample anti-aliasing mode for 2D/Canvas rendering. A higher number results in smoother edges at the cost of significantly worse performance. A value of 2 or 4 is best unless targeting very high-end systems. This has no effect on shader-induced aliasing or texture aliasing. + </member> + <member name="msaa_3d" type="int" setter="set_msaa_3d" getter="get_msaa_3d" enum="Viewport.MSAA" default="0"> + The multisample anti-aliasing mode for 3D rendering. A higher number results in smoother edges at the cost of significantly worse performance. A value of 2 or 4 is best unless targeting very high-end systems. See also bilinear scaling 3d [member scaling_3d_mode] for supersampling, which provides higher quality but is much more expensive. This has no effect on shader-induced aliasing or texture aliasing. </member> <member name="own_world_3d" type="bool" setter="set_use_own_world_3d" getter="is_using_own_world_3d" default="false"> If [code]true[/code], the viewport will use a unique copy of the [World3D] defined in [member world_3d]. @@ -250,7 +253,7 @@ To control this property on the root viewport, set the [member ProjectSettings.rendering/scaling_3d/mode] project setting. </member> <member name="scaling_3d_scale" type="float" setter="set_scaling_3d_scale" getter="get_scaling_3d_scale" default="1.0"> - Scales the 3D render buffer based on the viewport size uses an image filter specified in [member ProjectSettings.rendering/scaling_3d/mode] to scale the output image to the full viewport size. Values lower than [code]1.0[/code] can be used to speed up 3D rendering at the cost of quality (undersampling). Values greater than [code]1.0[/code] are only valid for bilinear mode and can be used to improve 3D rendering quality at a high performance cost (supersampling). See also [member ProjectSettings.rendering/anti_aliasing/quality/msaa] for multi-sample antialiasing, which is significantly cheaper but only smoothens the edges of polygons. + Scales the 3D render buffer based on the viewport size uses an image filter specified in [member ProjectSettings.rendering/scaling_3d/mode] to scale the output image to the full viewport size. Values lower than [code]1.0[/code] can be used to speed up 3D rendering at the cost of quality (undersampling). Values greater than [code]1.0[/code] are only valid for bilinear mode and can be used to improve 3D rendering quality at a high performance cost (supersampling). See also [member ProjectSettings.rendering/anti_aliasing/quality/msaa_3d] for multi-sample antialiasing, which is significantly cheaper but only smooths the edges of polygons. When using FSR upscaling, AMD recommends exposing the following values as preset options to users "Ultra Quality: 0.77", "Quality: 0.67", "Balanced: 0.59", "Performance: 0.5" instead of exposing the entire scale. To control this property on the root viewport, set the [member ProjectSettings.rendering/scaling_3d/scale] project setting. </member> diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 21ccef3518..033f10dbc5 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -472,7 +472,7 @@ String ShaderGLES3::_version_get_sha1(Version *p_version) const { bool ShaderGLES3::_load_from_cache(Version *p_version) { #if 0 String sha1 = _version_get_sha1(p_version); - String path = shader_cache_dir.plus_file(name).plus_file(base_sha256).plus_file(sha1) + ".cache"; + String path = shader_cache_dir.path_join(name).path_join(base_sha256).path_join(sha1) + ".cache"; Ref<FileAccess> f = FileAccess::open(path, FileAccess::READ); if (f.is_null()) { @@ -538,7 +538,7 @@ bool ShaderGLES3::_load_from_cache(Version *p_version) { void ShaderGLES3::_save_to_cache(Version *p_version) { #if 0 String sha1 = _version_get_sha1(p_version); - String path = shader_cache_dir.plus_file(name).plus_file(base_sha256).plus_file(sha1) + ".cache"; + String path = shader_cache_dir.path_join(name).path_join(base_sha256).path_join(sha1) + ".cache"; Ref<FileAccess> f = FileAccess::open(path, FileAccess::WRITE); ERR_FAIL_COND(f.is_null()); diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index 543638e8ff..b8ab4d6839 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -1564,6 +1564,19 @@ void TextureStorage::render_target_clear_used(RID p_render_target) { rt->used_in_frame = false; } +void TextureStorage::render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) { + RenderTarget *rt = render_target_owner.get_or_null(p_render_target); + ERR_FAIL_COND(!rt); + if (p_msaa == rt->msaa) { + return; + } + + WARN_PRINT("2D MSAA is not yet supported for GLES3."); + _clear_render_target(rt); + rt->msaa = p_msaa; + _update_render_target(rt); +} + void TextureStorage::render_target_request_clear(RID p_render_target, const Color &p_clear_color) { RenderTarget *rt = render_target_owner.get_or_null(p_render_target); ERR_FAIL_COND(!rt); diff --git a/drivers/gles3/storage/texture_storage.h b/drivers/gles3/storage/texture_storage.h index 71f713bc9f..4f4032723b 100644 --- a/drivers/gles3/storage/texture_storage.h +++ b/drivers/gles3/storage/texture_storage.h @@ -528,6 +528,7 @@ public: virtual void render_target_set_direct_to_screen(RID p_render_target, bool p_direct_to_screen) override; virtual bool render_target_was_used(RID p_render_target) override; void render_target_clear_used(RID p_render_target); + virtual void render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) override; // new void render_target_set_as_unused(RID p_render_target) override { diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index b8b72b8d30..55ea952696 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -69,7 +69,7 @@ bool DirAccessUnix::file_exists(String p_file) { GLOBAL_LOCK_FUNCTION if (p_file.is_relative_path()) { - p_file = current_dir.plus_file(p_file); + p_file = current_dir.path_join(p_file); } p_file = fix_path(p_file); @@ -88,7 +88,7 @@ bool DirAccessUnix::dir_exists(String p_dir) { GLOBAL_LOCK_FUNCTION if (p_dir.is_relative_path()) { - p_dir = get_current_dir().plus_file(p_dir); + p_dir = get_current_dir().path_join(p_dir); } p_dir = fix_path(p_dir); @@ -103,7 +103,7 @@ bool DirAccessUnix::is_readable(String p_dir) { GLOBAL_LOCK_FUNCTION if (p_dir.is_relative_path()) { - p_dir = get_current_dir().plus_file(p_dir); + p_dir = get_current_dir().path_join(p_dir); } p_dir = fix_path(p_dir); @@ -114,7 +114,7 @@ bool DirAccessUnix::is_writable(String p_dir) { GLOBAL_LOCK_FUNCTION if (p_dir.is_relative_path()) { - p_dir = get_current_dir().plus_file(p_dir); + p_dir = get_current_dir().path_join(p_dir); } p_dir = fix_path(p_dir); @@ -123,7 +123,7 @@ bool DirAccessUnix::is_writable(String p_dir) { uint64_t DirAccessUnix::get_modified_time(String p_file) { if (p_file.is_relative_path()) { - p_file = current_dir.plus_file(p_file); + p_file = current_dir.path_join(p_file); } p_file = fix_path(p_file); @@ -159,7 +159,7 @@ String DirAccessUnix::get_next() { // known if it points to a directory. stat() will resolve the link // for us. if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK) { - String f = current_dir.plus_file(fname); + String f = current_dir.path_join(fname); struct stat flags; if (stat(f.utf8().get_data(), &flags) == 0) { @@ -315,7 +315,7 @@ Error DirAccessUnix::make_dir(String p_dir) { GLOBAL_LOCK_FUNCTION if (p_dir.is_relative_path()) { - p_dir = get_current_dir().plus_file(p_dir); + p_dir = get_current_dir().path_join(p_dir); } p_dir = fix_path(p_dir); @@ -350,7 +350,7 @@ Error DirAccessUnix::change_dir(String p_dir) { // try_dir is the directory we are trying to change into String try_dir = ""; if (p_dir.is_relative_path()) { - String next_dir = current_dir.plus_file(p_dir); + String next_dir = current_dir.path_join(p_dir); next_dir = next_dir.simplify_path(); try_dir = next_dir; } else { @@ -394,13 +394,13 @@ String DirAccessUnix::get_current_dir(bool p_include_drive) const { Error DirAccessUnix::rename(String p_path, String p_new_path) { if (p_path.is_relative_path()) { - p_path = get_current_dir().plus_file(p_path); + p_path = get_current_dir().path_join(p_path); } p_path = fix_path(p_path); if (p_new_path.is_relative_path()) { - p_new_path = get_current_dir().plus_file(p_new_path); + p_new_path = get_current_dir().path_join(p_new_path); } p_new_path = fix_path(p_new_path); @@ -410,7 +410,7 @@ Error DirAccessUnix::rename(String p_path, String p_new_path) { Error DirAccessUnix::remove(String p_path) { if (p_path.is_relative_path()) { - p_path = get_current_dir().plus_file(p_path); + p_path = get_current_dir().path_join(p_path); } p_path = fix_path(p_path); @@ -429,7 +429,7 @@ Error DirAccessUnix::remove(String p_path) { bool DirAccessUnix::is_link(String p_file) { if (p_file.is_relative_path()) { - p_file = get_current_dir().plus_file(p_file); + p_file = get_current_dir().path_join(p_file); } p_file = fix_path(p_file); @@ -444,7 +444,7 @@ bool DirAccessUnix::is_link(String p_file) { String DirAccessUnix::read_link(String p_file) { if (p_file.is_relative_path()) { - p_file = get_current_dir().plus_file(p_file); + p_file = get_current_dir().path_join(p_file); } p_file = fix_path(p_file); @@ -461,7 +461,7 @@ String DirAccessUnix::read_link(String p_file) { Error DirAccessUnix::create_link(String p_source, String p_target) { if (p_target.is_relative_path()) { - p_target = get_current_dir().plus_file(p_target); + p_target = get_current_dir().path_join(p_target); } p_source = fix_path(p_source); diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 0fbd9f7b8f..384f46c8df 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -454,12 +454,12 @@ Error OS_Unix::open_dynamic_library(const String p_path, void *&p_library_handle if (!FileAccess::exists(path)) { // This code exists so GDExtension can load .so files from within the executable path. - path = get_executable_path().get_base_dir().plus_file(p_path.get_file()); + path = get_executable_path().get_base_dir().path_join(p_path.get_file()); } if (!FileAccess::exists(path)) { // This code exists so GDExtension can load .so files from a standard unix location. - path = get_executable_path().get_base_dir().plus_file("../lib").plus_file(p_path.get_file()); + path = get_executable_path().get_base_dir().path_join("../lib").path_join(p_path.get_file()); } p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW); @@ -526,13 +526,13 @@ String OS_Unix::get_user_data_dir() const { if (custom_dir.is_empty()) { custom_dir = appname; } - return get_data_path().plus_file(custom_dir); + return get_data_path().path_join(custom_dir); } else { - return get_data_path().plus_file(get_godot_dir_name()).plus_file("app_userdata").plus_file(appname); + return get_data_path().path_join(get_godot_dir_name()).path_join("app_userdata").path_join(appname); } } - return get_data_path().plus_file(get_godot_dir_name()).plus_file("app_userdata").plus_file("[unnamed project]"); + return get_data_path().path_join(get_godot_dir_name()).path_join("app_userdata").path_join("[unnamed project]"); } String OS_Unix::get_executable_path() const { diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index f2d78636d7..6a88f2c442 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -1733,7 +1733,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T ERR_FAIL_INDEX_V(p_format.samples, TEXTURE_SAMPLES_MAX, RID()); - image_create_info.samples = rasterization_sample_count[p_format.samples]; + image_create_info.samples = _ensure_supported_sample_count(p_format.samples); image_create_info.tiling = (p_format.usage_bits & TEXTURE_USAGE_CPU_READ_BIT) ? VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL; // Usage. @@ -1884,6 +1884,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T texture.mipmaps = image_create_info.mipLevels; texture.base_mipmap = 0; texture.base_layer = 0; + texture.is_resolve_buffer = p_format.is_resolve_buffer; texture.usage_flags = p_format.usage_bits; texture.samples = p_format.samples; texture.allowed_shared_formats = p_format.shareable_formats; @@ -3425,7 +3426,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF description.pNext = nullptr; description.flags = 0; description.format = vulkan_formats[p_attachments[i].format]; - description.samples = rasterization_sample_count[p_attachments[i].samples]; + description.samples = _ensure_supported_sample_count(p_attachments[i].samples); bool is_sampled = p_attachments[i].usage_flags & TEXTURE_USAGE_SAMPLING_BIT; bool is_storage = p_attachments[i].usage_flags & TEXTURE_USAGE_STORAGE_BIT; @@ -3546,7 +3547,8 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF break; } } - } else { + } + if (!used_last) { for (int j = 0; j < p_passes[last_pass].color_attachments.size(); j++) { if (p_passes[last_pass].color_attachments[j] == i) { used_last = true; @@ -4116,7 +4118,11 @@ RID RenderingDeviceVulkan::framebuffer_create(const Vector<RID> &p_texture_attac } else if (texture && texture->usage_flags & TEXTURE_USAGE_VRS_ATTACHMENT_BIT) { pass.vrs_attachment = i; } else { - pass.color_attachments.push_back(texture ? i : FramebufferPass::ATTACHMENT_UNUSED); + if (texture && texture->is_resolve_buffer) { + pass.resolve_attachments.push_back(i); + } else { + pass.color_attachments.push_back(texture ? i : FramebufferPass::ATTACHMENT_UNUSED); + } } } @@ -6567,7 +6573,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma multisample_state_create_info.pNext = nullptr; multisample_state_create_info.flags = 0; - multisample_state_create_info.rasterizationSamples = rasterization_sample_count[p_multisample_state.sample_count]; + multisample_state_create_info.rasterizationSamples = _ensure_supported_sample_count(p_multisample_state.sample_count); multisample_state_create_info.sampleShadingEnable = p_multisample_state.enable_sample_shading; multisample_state_create_info.minSampleShading = p_multisample_state.min_sample_shading; Vector<VkSampleMask> sample_mask; @@ -7353,7 +7359,9 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebu // If it is the first we're likely populating our VRS texture. // Bit dirty but... if (!texture || (!(texture->usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) && !(i != 0 && texture->usage_flags & TEXTURE_USAGE_VRS_ATTACHMENT_BIT))) { - color_count++; + if (!texture || !texture->is_resolve_buffer) { + color_count++; + } } } ERR_FAIL_COND_V_MSG(p_clear_color_values.size() != color_count, INVALID_ID, "Clear color values supplied (" + itos(p_clear_color_values.size()) + ") differ from the amount required for framebuffer color attachments (" + itos(color_count) + ")."); @@ -8993,6 +9001,25 @@ void RenderingDeviceVulkan::_begin_frame() { frames[frame].index = Engine::get_singleton()->get_frames_drawn(); } +VkSampleCountFlagBits RenderingDeviceVulkan::_ensure_supported_sample_count(TextureSamples p_requested_sample_count) const { + VkSampleCountFlags sample_count_flags = limits.framebufferColorSampleCounts & limits.framebufferDepthSampleCounts; + + if (sample_count_flags & rasterization_sample_count[p_requested_sample_count]) { + // The requested sample count is supported. + return rasterization_sample_count[p_requested_sample_count]; + } else { + // Find the closest lower supported sample count. + VkSampleCountFlagBits sample_count = rasterization_sample_count[p_requested_sample_count]; + while (sample_count > VK_SAMPLE_COUNT_1_BIT) { + if (sample_count_flags & rasterization_sample_count[sample_count]) { + return sample_count; + } + sample_count = (VkSampleCountFlagBits)(sample_count >> 1); + } + } + return VK_SAMPLE_COUNT_1_BIT; +} + void RenderingDeviceVulkan::swap_buffers() { ERR_FAIL_COND_MSG(local_device.is_valid(), "Local devices can't swap buffers."); _THREAD_SAFE_METHOD_ diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h index 6007e1ab4d..abec1b0e1b 100644 --- a/drivers/vulkan/rendering_device_vulkan.h +++ b/drivers/vulkan/rendering_device_vulkan.h @@ -150,6 +150,8 @@ class RenderingDeviceVulkan : public RenderingDevice { bool used_in_raster = false; bool used_in_compute = false; + bool is_resolve_buffer = false; + uint32_t read_aspect_mask = 0; uint32_t barrier_aspect_mask = 0; bool bound = false; // Bound to framebffer. @@ -1042,6 +1044,8 @@ class RenderingDeviceVulkan : public RenderingDevice { HashMap<RID, String> resource_names; #endif + VkSampleCountFlagBits _ensure_supported_sample_count(TextureSamples p_requested_sample_count) const; + public: virtual RID texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t>> &p_data = Vector<Vector<uint8_t>>()); virtual RID texture_create_shared(const TextureView &p_view, RID p_with_texture); diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index afc3e78372..b52179b4f3 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -1436,6 +1436,24 @@ bool VulkanContext::_use_validation_layers() { return Engine::get_singleton()->is_validation_layers_enabled(); } +VkExtent2D VulkanContext::_compute_swapchain_extent(const VkSurfaceCapabilitiesKHR &p_surf_capabilities, int *p_window_width, int *p_window_height) const { + // Width and height are either both 0xFFFFFFFF, or both not 0xFFFFFFFF. + if (p_surf_capabilities.currentExtent.width == 0xFFFFFFFF) { + // If the surface size is undefined, the size is set to the size + // of the images requested, which must fit within the minimum and + // maximum values. + VkExtent2D extent = {}; + extent.width = CLAMP((uint32_t)(*p_window_width), p_surf_capabilities.minImageExtent.width, p_surf_capabilities.maxImageExtent.width); + extent.height = CLAMP((uint32_t)(*p_window_height), p_surf_capabilities.minImageExtent.height, p_surf_capabilities.maxImageExtent.height); + return extent; + } else { + // If the surface size is defined, the swap chain size must match. + *p_window_width = p_surf_capabilities.currentExtent.width; + *p_window_height = p_surf_capabilities.currentExtent.height; + return p_surf_capabilities.currentExtent; + } +} + Error VulkanContext::_window_create(DisplayServer::WindowID p_window_id, DisplayServer::VSyncMode p_vsync_mode, VkSurfaceKHR p_surface, int p_width, int p_height) { ERR_FAIL_COND_V(windows.has(p_window_id), ERR_INVALID_PARAMETER); @@ -1576,32 +1594,7 @@ Error VulkanContext::_update_swap_chain(Window *window) { ERR_FAIL_V(ERR_CANT_CREATE); } - VkExtent2D swapchainExtent; - // Width and height are either both 0xFFFFFFFF, or both not 0xFFFFFFFF. - if (surfCapabilities.currentExtent.width == 0xFFFFFFFF) { - // If the surface size is undefined, the size is set to the size - // of the images requested, which must fit within the minimum and - // maximum values. - swapchainExtent.width = window->width; - swapchainExtent.height = window->height; - - if (swapchainExtent.width < surfCapabilities.minImageExtent.width) { - swapchainExtent.width = surfCapabilities.minImageExtent.width; - } else if (swapchainExtent.width > surfCapabilities.maxImageExtent.width) { - swapchainExtent.width = surfCapabilities.maxImageExtent.width; - } - - if (swapchainExtent.height < surfCapabilities.minImageExtent.height) { - swapchainExtent.height = surfCapabilities.minImageExtent.height; - } else if (swapchainExtent.height > surfCapabilities.maxImageExtent.height) { - swapchainExtent.height = surfCapabilities.maxImageExtent.height; - } - } else { - // If the surface size is defined, the swap chain size must match. - swapchainExtent = surfCapabilities.currentExtent; - window->width = surfCapabilities.currentExtent.width; - window->height = surfCapabilities.currentExtent.height; - } + VkExtent2D swapchainExtent = _compute_swapchain_extent(surfCapabilities, &window->width, &window->height); if (window->width == 0 || window->height == 0) { free(presentModes); diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h index 5cc3b515d9..9889cf336b 100644 --- a/drivers/vulkan/vulkan_context.h +++ b/drivers/vulkan/vulkan_context.h @@ -266,6 +266,8 @@ protected: Error _get_preferred_validation_layers(uint32_t *count, const char *const **names); + virtual VkExtent2D _compute_swapchain_extent(const VkSurfaceCapabilitiesKHR &p_surf_capabilities, int *p_window_width, int *p_window_height) const; + public: // Extension calls. VkResult vkCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass); diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 2125709b32..11fd29c8f5 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -157,7 +157,7 @@ Error DirAccessWindows::make_dir(String p_dir) { p_dir = fix_path(p_dir); if (p_dir.is_relative_path()) { - p_dir = current_dir.plus_file(p_dir); + p_dir = current_dir.path_join(p_dir); } p_dir = p_dir.replace("/", "\\"); @@ -213,7 +213,7 @@ bool DirAccessWindows::file_exists(String p_file) { GLOBAL_LOCK_FUNCTION if (!p_file.is_absolute_path()) { - p_file = get_current_dir().plus_file(p_file); + p_file = get_current_dir().path_join(p_file); } p_file = fix_path(p_file); @@ -232,7 +232,7 @@ bool DirAccessWindows::dir_exists(String p_dir) { GLOBAL_LOCK_FUNCTION if (p_dir.is_relative_path()) { - p_dir = get_current_dir().plus_file(p_dir); + p_dir = get_current_dir().path_join(p_dir); } p_dir = fix_path(p_dir); @@ -247,13 +247,13 @@ bool DirAccessWindows::dir_exists(String p_dir) { Error DirAccessWindows::rename(String p_path, String p_new_path) { if (p_path.is_relative_path()) { - p_path = get_current_dir().plus_file(p_path); + p_path = get_current_dir().path_join(p_path); } p_path = fix_path(p_path); if (p_new_path.is_relative_path()) { - p_new_path = get_current_dir().plus_file(p_new_path); + p_new_path = get_current_dir().path_join(p_new_path); } p_new_path = fix_path(p_new_path); @@ -291,7 +291,7 @@ Error DirAccessWindows::rename(String p_path, String p_new_path) { Error DirAccessWindows::remove(String p_path) { if (p_path.is_relative_path()) { - p_path = get_current_dir().plus_file(p_path); + p_path = get_current_dir().path_join(p_path); } p_path = fix_path(p_path); diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 9af8b907c4..0183d08733 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -648,7 +648,7 @@ void AnimationBezierTrackEdit::set_animation_and_track(const Ref<Animation> &p_a animation = p_animation; read_only = p_read_only; selected_track = p_track; - update(); + queue_redraw(); } Size2 AnimationBezierTrackEdit::get_minimum_size() const { @@ -691,11 +691,11 @@ void AnimationBezierTrackEdit::_play_position_draw() { void AnimationBezierTrackEdit::set_play_position(real_t p_pos) { play_position_pos = p_pos; - play_position->update(); + play_position->queue_redraw(); } void AnimationBezierTrackEdit::update_play_position() { - play_position->update(); + play_position->queue_redraw(); } void AnimationBezierTrackEdit::set_root(Node *p_root) { @@ -734,12 +734,12 @@ void AnimationBezierTrackEdit::set_filtered(bool p_filtered) { } } } - update(); + queue_redraw(); } void AnimationBezierTrackEdit::_zoom_changed() { - update(); - play_position->update(); + queue_redraw(); + play_position->queue_redraw(); } void AnimationBezierTrackEdit::_update_locked_tracks_after(int p_track) { @@ -787,7 +787,7 @@ String AnimationBezierTrackEdit::get_tooltip(const Point2 &p_pos) const { void AnimationBezierTrackEdit::_clear_selection() { selection.clear(); emit_signal(SNAME("clear_selection")); - update(); + queue_redraw(); } void AnimationBezierTrackEdit::_change_selected_keys_handle_mode(Animation::HandleMode p_mode, bool p_auto) { @@ -819,7 +819,7 @@ void AnimationBezierTrackEdit::_select_at_anim(const Ref<Animation> &p_anim, int selection.insert(IntPair(p_track, idx)); emit_signal(SNAME("select_key"), idx, true, p_track); - update(); + queue_redraw(); } void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { @@ -909,7 +909,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { v_scroll = (maximum_value + minimum_value) / 2.0; v_zoom = (maximum_value - minimum_value) / ((get_size().height - timeline->get_size().height) * 0.9); - update(); + queue_redraw(); accept_event(); return; } else if (ED_GET_SHORTCUT("animation_bezier_editor/select_all_keys")->matches_event(p_event)) { @@ -917,13 +917,13 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { selection.insert(IntPair(edit_points[i].track, edit_points[i].key)); } - update(); + queue_redraw(); accept_event(); return; } else if (ED_GET_SHORTCUT("animation_bezier_editor/deselect_all_keys")->matches_event(p_event)) { selection.clear(); - update(); + queue_redraw(); accept_event(); return; } @@ -1024,7 +1024,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } } } - update(); + queue_redraw(); return; } else if (I.key == VISIBILITY_ICON) { if (hidden_tracks.has(track)) { @@ -1054,7 +1054,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { solo_track = -1; } - update(); + queue_redraw(); return; } else if (I.key == SOLO_ICON) { if (solo_track == track) { @@ -1076,7 +1076,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { set_animation_and_track(animation, track, read_only); solo_track = track; } - update(); + queue_redraw(); return; } return; @@ -1098,7 +1098,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } else { selection.insert(pair); } - update(); + queue_redraw(); select_single_attempt = IntPair(-1, -1); } else if (selection.has(pair)) { moving_selection_attempt = true; @@ -1110,7 +1110,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { moving_handle_right = animation->bezier_track_get_key_out_handle(pair.first, pair.second); moving_selection_offset = Vector2(); select_single_attempt = pair; - update(); + queue_redraw(); } else { moving_selection_attempt = true; moving_selection = true; @@ -1135,7 +1135,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { moving_handle_track = edit_points[i].track; moving_handle_left = animation->bezier_track_get_key_in_handle(edit_points[i].track, edit_points[i].key); moving_handle_right = animation->bezier_track_get_key_out_handle(edit_points[i].track, edit_points[i].key); - update(); + queue_redraw(); return; } @@ -1145,7 +1145,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { moving_handle_track = edit_points[i].track; moving_handle_left = animation->bezier_track_get_key_in_handle(edit_points[i].track, edit_points[i].key); moving_handle_right = animation->bezier_track_get_key_out_handle(edit_points[i].track, edit_points[i].key); - update(); + queue_redraw(); return; } } @@ -1186,7 +1186,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { moving_selection_from_track = selected_track; moving_selection_offset = Vector2(); select_single_attempt = IntPair(-1, -1); - update(); + queue_redraw(); return; } @@ -1258,7 +1258,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { box_selecting_attempt = false; box_selecting = false; - update(); + queue_redraw(); } if (moving_selection_attempt && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { @@ -1376,7 +1376,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } moving_selection_attempt = false; - update(); + queue_redraw(); } } @@ -1397,7 +1397,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { additional_moving_handle_lefts.clear(); additional_moving_handle_rights.clear(); - update(); + queue_redraw(); } if (box_selecting_attempt && mm.is_valid()) { @@ -1412,7 +1412,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { //avoid cursor from going too above, so it does not lose focus with viewport warp_mouse(Vector2(get_local_mouse_position().x, 0)); } - update(); + queue_redraw(); } if ((moving_handle == 1 || moving_handle == -1) && mm.is_valid()) { @@ -1461,7 +1461,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { moving_handle_left = -moving_handle_right; } } - update(); + queue_redraw(); } if ((moving_handle == -1 || moving_handle == 1) && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { @@ -1478,7 +1478,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } undo_redo->commit_action(); moving_handle = 0; - update(); + queue_redraw(); } } } @@ -1491,7 +1491,7 @@ void AnimationBezierTrackEdit::_pan_callback(Vector2 p_scroll_vec) { v_scroll += p_scroll_vec.y * v_zoom; v_scroll = CLAMP(v_scroll, -100000, 100000); timeline->set_value(timeline->get_value() - p_scroll_vec.x / timeline->get_zoom_scale()); - update(); + queue_redraw(); } void AnimationBezierTrackEdit::_zoom_callback(Vector2 p_scroll_vec, Vector2 p_origin, bool p_alt) { @@ -1511,7 +1511,7 @@ void AnimationBezierTrackEdit::_zoom_callback(Vector2 p_scroll_vec, Vector2 p_or } } v_scroll = v_scroll + (p_origin.y - get_size().y / 2.0) * (v_zoom - v_zoom_orig); - update(); + queue_redraw(); } void AnimationBezierTrackEdit::_menu_selected(int p_index) { @@ -1541,7 +1541,7 @@ void AnimationBezierTrackEdit::_menu_selected(int p_index) { undo_redo->add_do_method(animation.ptr(), "track_insert_key", selected_track, time, new_point); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", selected_track, time); undo_redo->commit_action(); - update(); + queue_redraw(); } } break; case MENU_KEY_DUPLICATE: { @@ -1624,7 +1624,7 @@ void AnimationBezierTrackEdit::duplicate_selection() { selection.insert(IntPair(track, existing_idx)); } - update(); + queue_redraw(); } void AnimationBezierTrackEdit::delete_selection() { diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index aaaf3e6f04..4991b2cfaf 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1399,8 +1399,8 @@ public: }; void AnimationTimelineEdit::_zoom_changed(double) { - update(); - play_position->update(); + queue_redraw(); + play_position->queue_redraw(); emit_signal(SNAME("zoom_changed")); } @@ -1430,7 +1430,7 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { undo_redo->add_undo_method(animation.ptr(), "set_length", animation->get_length()); undo_redo->commit_action(); editing = false; - update(); + queue_redraw(); emit_signal(SNAME("length_changed"), p_new_len); } @@ -1703,7 +1703,7 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation, boo add_track->hide(); play_position->hide(); } - update(); + queue_redraw(); update_values(); } @@ -1731,7 +1731,7 @@ void AnimationTimelineEdit::set_track_edit(AnimationTrackEdit *p_track_edit) { void AnimationTimelineEdit::set_play_position(float p_pos) { play_position_pos = p_pos; - play_position->update(); + play_position->queue_redraw(); } float AnimationTimelineEdit::get_play_position() const { @@ -1739,7 +1739,7 @@ float AnimationTimelineEdit::get_play_position() const { } void AnimationTimelineEdit::update_play_position() { - play_position->update(); + play_position->queue_redraw(); } void AnimationTimelineEdit::update_values() { @@ -1853,9 +1853,9 @@ void AnimationTimelineEdit::gui_input(const Ref<InputEvent> &p_event) { if (dragging_hsize) { int ofs = mm->get_position().x - dragging_hsize_from; name_limit = dragging_hsize_at + ofs; - update(); + queue_redraw(); emit_signal(SNAME("name_limit_changed")); - play_position->update(); + play_position->queue_redraw(); } if (dragging_timeline) { int x = mm->get_position().x - get_name_limit(); @@ -1898,7 +1898,7 @@ void AnimationTimelineEdit::_zoom_callback(Vector2 p_scroll_vec, Vector2 p_origi void AnimationTimelineEdit::set_use_fps(bool p_use_fps) { use_fps = p_use_fps; update_values(); - update(); + queue_redraw(); } bool AnimationTimelineEdit::is_using_fps() const { @@ -2292,13 +2292,13 @@ void AnimationTrackEdit::_notification(int p_what) { case NOTIFICATION_MOUSE_ENTER: hovered = true; - update(); + queue_redraw(); break; case NOTIFICATION_MOUSE_EXIT: hovered = false; // When the mouse cursor exits the track, we're no longer hovering any keyframe. hovering_key_idx = -1; - update(); + queue_redraw(); [[fallthrough]]; case NOTIFICATION_DRAG_END: { cancel_drop(); @@ -2491,7 +2491,7 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati read_only = p_read_only; track = p_track; - update(); + queue_redraw(); ERR_FAIL_INDEX(track, animation->get_track_count()); @@ -2553,11 +2553,11 @@ void AnimationTrackEdit::_play_position_draw() { void AnimationTrackEdit::set_play_position(float p_pos) { play_position_pos = p_pos; - play_position->update(); + play_position->queue_redraw(); } void AnimationTrackEdit::update_play_position() { - play_position->update(); + play_position->queue_redraw(); } void AnimationTrackEdit::set_root(Node *p_root) { @@ -2565,8 +2565,8 @@ void AnimationTrackEdit::set_root(Node *p_root) { } void AnimationTrackEdit::_zoom_changed() { - update(); - play_position->update(); + queue_redraw(); + play_position->queue_redraw(); } void AnimationTrackEdit::_path_submitted(const String &p_text) { @@ -2811,7 +2811,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { undo_redo->add_do_method(animation.ptr(), "track_set_enabled", track, !animation->track_is_enabled(track)); undo_redo->add_undo_method(animation.ptr(), "track_set_enabled", track, animation->track_is_enabled(track)); undo_redo->commit_action(); - update(); + queue_redraw(); accept_event(); } @@ -3090,7 +3090,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { if (hovering_key_idx != previous_hovering_key_idx) { // Required to draw keyframe hover feedback on the correct keyframe. - update(); + queue_redraw(); } } } @@ -3156,7 +3156,7 @@ bool AnimationTrackEdit::can_drop_data(const Point2 &p_point, const Variant &p_d dropping_at = 1; } - const_cast<AnimationTrackEdit *>(this)->update(); + const_cast<AnimationTrackEdit *>(this)->queue_redraw(); const_cast<AnimationTrackEdit *>(this)->emit_signal(SNAME("drop_attempted"), track); return true; @@ -3202,7 +3202,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) { undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", track, update_mode); undo_redo->add_undo_method(animation.ptr(), "value_track_set_update_mode", track, animation->value_track_get_update_mode(track)); undo_redo->commit_action(); - update(); + queue_redraw(); } break; case MENU_INTERPOLATION_NEAREST: @@ -3215,7 +3215,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) { undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", track, interp_mode); undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_type", track, animation->track_get_interpolation_type(track)); undo_redo->commit_action(); - update(); + queue_redraw(); } break; case MENU_LOOP_WRAP: case MENU_LOOP_CLAMP: { @@ -3224,7 +3224,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) { undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_loop_wrap", track, loop_wrap); undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_loop_wrap", track, animation->track_get_interpolation_loop_wrap(track)); undo_redo->commit_action(); - update(); + queue_redraw(); } break; case MENU_KEY_INSERT: { @@ -3247,13 +3247,13 @@ void AnimationTrackEdit::_menu_selected(int p_index) { void AnimationTrackEdit::cancel_drop() { if (dropping_at != 0) { dropping_at = 0; - update(); + queue_redraw(); } } void AnimationTrackEdit::set_in_group(bool p_enable) { in_group = p_enable; - update(); + queue_redraw(); } void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselection) { @@ -3399,7 +3399,7 @@ void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, co icon = p_type; node_name = p_name; node = p_node; - update(); + queue_redraw(); update_minimum_size(); } @@ -3419,11 +3419,11 @@ void AnimationTrackEditGroup::set_timeline(AnimationTimelineEdit *p_timeline) { void AnimationTrackEditGroup::set_root(Node *p_root) { root = p_root; - update(); + queue_redraw(); } void AnimationTrackEditGroup::_zoom_changed() { - update(); + queue_redraw(); } void AnimationTrackEditGroup::_bind_methods() { @@ -4645,18 +4645,18 @@ void AnimationTrackEditor::_update_tracks() { void AnimationTrackEditor::_redraw_tracks() { for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); + track_edits[i]->queue_redraw(); } } void AnimationTrackEditor::_redraw_groups() { for (int i = 0; i < groups.size(); i++) { - groups[i]->update(); + groups[i]->queue_redraw(); } } void AnimationTrackEditor::_sync_animation_change() { - bezier_edit->update(); + bezier_edit->queue_redraw(); } void AnimationTrackEditor::_animation_changed() { @@ -4669,12 +4669,12 @@ void AnimationTrackEditor::_animation_changed() { } if (key_edit && key_edit->setting) { - // If editing a key, just update the edited track, makes refresh less costly. + // If editing a key, just redraw the edited track, makes refresh less costly. if (key_edit->track < track_edits.size()) { if (animation->track_get_type(key_edit->track) == Animation::TYPE_BEZIER) { - bezier_edit->update(); + bezier_edit->queue_redraw(); } else { - track_edits[key_edit->track]->update(); + track_edits[key_edit->track]->queue_redraw(); } } return; @@ -4713,7 +4713,7 @@ void AnimationTrackEditor::_update_step_spinbox() { } void AnimationTrackEditor::_animation_update() { - timeline->update(); + timeline->queue_redraw(); timeline->update_values(); bool same = true; @@ -4742,7 +4742,7 @@ void AnimationTrackEditor::_animation_update() { _update_tracks(); } - bezier_edit->update(); + bezier_edit->queue_redraw(); _update_step_spinbox(); emit_signal(SNAME("animation_step_changed"), animation->get_step()); @@ -5000,7 +5000,7 @@ void AnimationTrackEditor::_timeline_value_changed(double) { } _redraw_groups(); - bezier_edit->update(); + bezier_edit->queue_redraw(); bezier_edit->update_play_position(); } diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index ab64aaa24d..6499cf8df2 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -197,7 +197,7 @@ void AnimationTrackEditAudio::_preview_changed(ObjectID p_which) { Ref<AudioStream> stream = object->call("get_stream"); if (stream.is_valid() && stream->get_instance_id() == p_which) { - update(); + queue_redraw(); } } @@ -799,7 +799,7 @@ void AnimationTrackEditTypeAudio::_preview_changed(ObjectID p_which) { for (int i = 0; i < get_animation()->track_get_key_count(get_track()); i++) { Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), i); if (stream.is_valid() && stream->get_instance_id() == p_which) { - update(); + queue_redraw(); return; } } @@ -1026,7 +1026,7 @@ void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant get_undo_redo()->add_undo_method(get_animation().ptr(), "track_remove_key_at_time", get_track(), ofs); get_undo_redo()->commit_action(); - update(); + queue_redraw(); return; } } @@ -1086,7 +1086,7 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) { if (len_resizing && mm.is_valid()) { len_resizing_rel += mm->get_relative().x; len_resizing_start = mm->is_shift_pressed(); - update(); + queue_redraw(); accept_event(); return; } @@ -1097,7 +1097,7 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) { len_resizing_start = mb->is_shift_pressed(); len_resizing_from_px = mb->get_position().x; len_resizing_rel = 0; - update(); + queue_redraw(); accept_event(); return; } @@ -1120,7 +1120,7 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) { } len_resizing_index = -1; - update(); + queue_redraw(); accept_event(); return; } diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 2b1584b20c..2d5e70e1ff 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1092,7 +1092,7 @@ void CodeTextEditor::trim_trailing_whitespace() { if (trimed_whitespace) { text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } } @@ -1110,7 +1110,7 @@ void CodeTextEditor::insert_final_newline() { text_editor->set_line(final_line, line); text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } } @@ -1154,7 +1154,7 @@ void CodeTextEditor::convert_indent_to_spaces() { if (changed_indentation) { text_editor->set_caret_column(cursor_column); text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } } @@ -1203,7 +1203,7 @@ void CodeTextEditor::convert_indent_to_tabs() { if (changed_indentation) { text_editor->set_caret_column(cursor_column); text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } } @@ -1295,7 +1295,7 @@ void CodeTextEditor::move_lines_up() { text_editor->set_caret_line(next_id); } text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } void CodeTextEditor::move_lines_down() { @@ -1341,7 +1341,7 @@ void CodeTextEditor::move_lines_down() { text_editor->set_caret_line(next_id); } text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } void CodeTextEditor::_delete_line(int p_line) { @@ -1418,7 +1418,7 @@ void CodeTextEditor::duplicate_selection() { } text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } void CodeTextEditor::toggle_inline_comment(const String &delimiter) { @@ -1495,7 +1495,7 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) { text_editor->set_caret_column(col); } text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } void CodeTextEditor::goto_line(int p_line) { diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 587c16c229..dce9ca2b93 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -753,22 +753,12 @@ void ConnectionsDock::_open_connection_dialog(TreeItem &p_item) { } Dictionary subst; - - String s = node_name.capitalize().replace(" ", ""); - subst["NodeName"] = s; - if (!s.is_empty()) { - s[0] = s.to_lower()[0]; - } - subst["nodeName"] = s; - subst["node_name"] = node_name.capitalize().replace(" ", "_").to_lower(); - - s = signal_name.capitalize().replace(" ", ""); - subst["SignalName"] = s; - if (!s.is_empty()) { - s[0] = s.to_lower()[0]; - } - subst["signalName"] = s; - subst["signal_name"] = signal_name.capitalize().replace(" ", "_").to_lower(); + subst["NodeName"] = node_name.to_pascal_case(); + subst["nodeName"] = node_name.to_camel_case(); + subst["node_name"] = node_name.to_snake_case(); + subst["SignalName"] = signal_name.to_pascal_case(); + subst["signalName"] = signal_name.to_camel_case(); + subst["signal_name"] = signal_name.to_snake_case(); String dst_method = String(EDITOR_GET("interface/editors/default_signal_callback_name")).format(subst); @@ -1070,7 +1060,7 @@ void ConnectionsDock::update_tree() { } // "::" separators used in make_custom_tooltip for formatting. - signal_item->set_tooltip(0, String(signal_name) + "::" + signaldesc + "::" + descr); + signal_item->set_tooltip_text(0, String(signal_name) + "::" + signaldesc + "::" + descr); } // List existing connections. diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 03e636d43a..8ccfda1145 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -313,7 +313,7 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String } const String &description = DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description); - r_item->set_tooltip(0, description); + r_item->set_tooltip_text(0, description); if (p_type_category == TypeCategory::OTHER_TYPE && !script_type) { Ref<Texture2D> icon = EditorNode::get_editor_data().get_custom_types()[custom_type_parents[p_type]][custom_type_indices[p_type]].icon; @@ -383,7 +383,7 @@ void CreateDialog::_confirmed() { } { - Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("create_recent." + base_type), FileAccess::WRITE); + Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().path_join("create_recent." + base_type), FileAccess::WRITE); if (f.is_valid()) { f->store_line(selected_item); @@ -660,7 +660,7 @@ void CreateDialog::_save_and_update_favorite_list() { TreeItem *root = favorites->create_item(); { - Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("favorites." + base_type), FileAccess::WRITE); + Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().path_join("favorites." + base_type), FileAccess::WRITE); if (f.is_valid()) { for (int i = 0; i < favorite_list.size(); i++) { String l = favorite_list[i]; @@ -686,7 +686,7 @@ void CreateDialog::_save_and_update_favorite_list() { void CreateDialog::_load_favorites_and_history() { String dir = EditorPaths::get_singleton()->get_project_settings_dir(); - Ref<FileAccess> f = FileAccess::open(dir.plus_file("create_recent." + base_type), FileAccess::READ); + Ref<FileAccess> f = FileAccess::open(dir.path_join("create_recent." + base_type), FileAccess::READ); if (f.is_valid()) { while (!f->eof_reached()) { String l = f->get_line().strip_edges(); @@ -698,7 +698,7 @@ void CreateDialog::_load_favorites_and_history() { } } - f = FileAccess::open(dir.plus_file("favorites." + base_type), FileAccess::READ); + f = FileAccess::open(dir.path_join("favorites." + base_type), FileAccess::READ); if (f.is_valid()) { while (!f->eof_reached()) { String l = f->get_line().strip_edges(); diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index dbd2c61d44..76efcd7190 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -155,7 +155,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int const SceneDebuggerTree::RemoteNode &node = p_tree->nodes[i]; TreeItem *item = create_item(parent); item->set_text(0, node.name); - item->set_tooltip(0, TTR("Type:") + " " + node.type_name); + item->set_tooltip_text(0, TTR("Type:") + " " + node.type_name); Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(node.type_name, ""); if (icon.is_valid()) { item->set_icon(0, icon); diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp index 55d025f675..10b50a81e4 100644 --- a/editor/debugger/editor_performance_profiler.cpp +++ b/editor/debugger/editor_performance_profiler.cpp @@ -61,7 +61,7 @@ void EditorPerformanceProfiler::Monitor::update_value(float p_value) { } break; } item->set_text(1, label); - item->set_tooltip(1, tooltip); + item->set_tooltip_text(1, tooltip); if (p_value > max) { max = p_value; @@ -73,7 +73,7 @@ void EditorPerformanceProfiler::Monitor::reset() { max = 0.0f; if (item) { item->set_text(1, ""); - item->set_tooltip(1, ""); + item->set_tooltip_text(1, ""); } } @@ -92,7 +92,7 @@ String EditorPerformanceProfiler::_create_label(float p_value, Performance::Moni } void EditorPerformanceProfiler::_monitor_select() { - monitor_draw->update(); + monitor_draw->queue_redraw(); } void EditorPerformanceProfiler::_monitor_draw() { @@ -283,12 +283,12 @@ void EditorPerformanceProfiler::_marker_input(const Ref<InputEvent> &p_event) { float spacing = float(point_sep) / float(columns); marker_frame = (rect.size.x - point.x) / spacing; } - monitor_draw->update(); + monitor_draw->queue_redraw(); return; } } marker_key = ""; - monitor_draw->update(); + monitor_draw->queue_redraw(); } } @@ -308,7 +308,7 @@ void EditorPerformanceProfiler::reset() { _build_monitor_tree(); marker_key = ""; marker_frame = 0; - monitor_draw->update(); + monitor_draw->queue_redraw(); } void EditorPerformanceProfiler::update_monitors(const Vector<StringName> &p_names) { @@ -357,7 +357,7 @@ void EditorPerformanceProfiler::add_profile_frame(const Vector<float> &p_values) E.value.update_value(data); } marker_frame++; - monitor_draw->update(); + monitor_draw->queue_redraw(); } List<float> *EditorPerformanceProfiler::get_monitor_data(const StringName &p_name) { diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index b49cab9df7..cf48366bd3 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -318,7 +318,7 @@ void EditorProfiler::_update_plot() { graph_texture->update(img); graph->set_texture(graph_texture); - graph->update(); + graph->queue_redraw(); } void EditorProfiler::_update_frame() { @@ -356,7 +356,7 @@ void EditorProfiler::_update_frame() { item->set_metadata(1, it.script); item->set_metadata(2, it.line); item->set_text_alignment(2, HORIZONTAL_ALIGNMENT_RIGHT); - item->set_tooltip(0, it.name + "\n" + it.script + ":" + itos(it.line)); + item->set_tooltip_text(0, it.name + "\n" + it.script + ":" + itos(it.line)); float time = dtime == DISPLAY_SELF_TIME ? it.self : it.total; @@ -421,7 +421,7 @@ void EditorProfiler::_graph_tex_draw() { void EditorProfiler::_graph_tex_mouse_exit() { hover_metric = -1; - graph->update(); + graph->queue_redraw(); } void EditorProfiler::_cursor_metric_changed(double) { @@ -429,7 +429,7 @@ void EditorProfiler::_cursor_metric_changed(double) { return; } - graph->update(); + graph->queue_redraw(); _update_frame(); } @@ -480,13 +480,13 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { } } - graph->update(); + graph->queue_redraw(); } } void EditorProfiler::disable_seeking() { seeking = false; - graph->update(); + graph->queue_redraw(); } void EditorProfiler::_combo_changed(int) { diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 6f3dd1793c..8e7135f1c5 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -312,7 +312,7 @@ void EditorVisualProfiler::_update_plot() { graph_texture->update(img); graph->set_texture(graph_texture); - graph->update(); + graph->queue_redraw(); } void EditorVisualProfiler::_update_frame(bool p_focus_selected) { @@ -489,7 +489,7 @@ void EditorVisualProfiler::_graph_tex_draw() { void EditorVisualProfiler::_graph_tex_mouse_exit() { hover_metric = -1; - graph->update(); + graph->queue_redraw(); } void EditorVisualProfiler::_cursor_metric_changed(double) { @@ -497,7 +497,7 @@ void EditorVisualProfiler::_cursor_metric_changed(double) { return; } - graph->update(); + graph->queue_redraw(); _update_frame(); } @@ -613,7 +613,7 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { } } - graph->update(); + graph->queue_redraw(); } } @@ -637,7 +637,7 @@ int EditorVisualProfiler::_get_cursor_index() const { void EditorVisualProfiler::disable_seeking() { seeking = false; - graph->update(); + graph->queue_redraw(); } void EditorVisualProfiler::_combo_changed(int) { diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index fab211f18c..5baa9970af 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -580,8 +580,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da stack_trace->set_text(1, frame_txt); } - error->set_tooltip(0, tooltip); - error->set_tooltip(1, tooltip); + error->set_tooltip_text(0, tooltip); + error->set_tooltip_text(1, tooltip); if (warning_count == 0 && error_count == 0) { expand_all_button->set_disabled(false); diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 489a55ede0..ec9a744e57 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -1071,7 +1071,7 @@ Error DocTools::load_classes(const String &p_dir) { while (!path.is_empty()) { if (!da->current_is_dir() && path.ends_with("xml")) { Ref<XMLParser> parser = memnew(XMLParser); - Error err2 = parser->open(p_dir.plus_file(path)); + Error err2 = parser->open(p_dir.path_join(path)); if (err2) { return err2; } @@ -1380,7 +1380,7 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String, } Error err; - String save_file = save_path.plus_file(c.name + ".xml"); + String save_file = save_path.path_join(c.name + ".xml"); Ref<FileAccess> f = FileAccess::open(save_file, FileAccess::WRITE, &err); ERR_CONTINUE_MSG(err != OK, "Can't write doc file: " + save_file + "."); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 8dc8a0ab6b..aaa5956c17 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -215,11 +215,11 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { if (FileAccess::exists(res_path)) { num_file_conflicts += 1; ti->set_custom_color(0, tree->get_theme_color(SNAME("error_color"), SNAME("Editor"))); - ti->set_tooltip(0, vformat(TTR("%s (already exists)"), res_path)); + ti->set_tooltip_text(0, vformat(TTR("%s (already exists)"), res_path)); ti->set_checked(0, false); ti->propagate_check(0); } else { - ti->set_tooltip(0, res_path); + ti->set_tooltip_text(0, res_path); } ti->set_metadata(0, res_path); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index a95cc4981a..b1253ed7cb 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -182,7 +182,7 @@ void EditorAudioBus::_notification(int p_what) { case NOTIFICATION_DRAG_END: { if (hovering_drop) { hovering_drop = false; - update(); + queue_redraw(); } } break; } @@ -967,7 +967,7 @@ void EditorAudioBusDrop::_notification(int p_what) { case NOTIFICATION_MOUSE_ENTER: { if (!hovering_drop) { hovering_drop = true; - update(); + queue_redraw(); } } break; @@ -975,7 +975,7 @@ void EditorAudioBusDrop::_notification(int p_what) { case NOTIFICATION_DRAG_END: { if (hovering_drop) { hovering_drop = false; - update(); + queue_redraw(); } } break; } diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 120ac5b984..544b6c7141 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -164,7 +164,7 @@ void EditorAutoloadSettings::_autoload_add() { if (!fpath.ends_with("/")) { fpath = fpath.get_base_dir(); } - dialog->config("Node", fpath.plus_file(vformat("%s.gd", autoload_add_name->get_text().camelcase_to_underscore())), false, false); + dialog->config("Node", fpath.path_join(vformat("%s.gd", autoload_add_name->get_text().to_snake_case())), false, false); dialog->popup_centered(); } else { if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_text())) { @@ -371,7 +371,7 @@ void EditorAutoloadSettings::_autoload_open(const String &fpath) { void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) { // Convert the file name to PascalCase, which is the convention for classes in GDScript. - const String class_name = p_path.get_file().get_basename().capitalize().replace(" ", ""); + const String class_name = p_path.get_file().get_basename().to_pascal_case(); // If the name collides with a built-in class, prefix the name to make it possible to add without having to edit the name. // The prefix is subjective, but it provides better UX than leaving the Add button disabled :) @@ -580,7 +580,7 @@ void EditorAutoloadSettings::_script_created(Ref<Script> p_script) { FileSystemDock::get_singleton()->get_script_create_dialog()->hide(); path = p_script->get_path().get_base_dir(); autoload_add_path->set_text(p_script->get_path()); - autoload_add_name->set_text(p_script->get_path().get_file().get_basename().capitalize().replace(" ", "")); + autoload_add_name->set_text(p_script->get_path().get_file().get_basename().to_pascal_case()); _autoload_add(); } diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index 4071722185..3bb050ce77 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -172,7 +172,7 @@ void EditorDirDialog::_make_dir_confirm() { mkdirerr->popup_centered(Size2(250, 80) * EDSCALE); } else { opened_paths.insert(dir); - //reload(dir.plus_file(makedirname->get_text())); + //reload(dir.path_join(makedirname->get_text())); EditorFileSystem::get_singleton()->scan_changes(); //we created a dir, so rescan changes } makedirname->set_text(""); // reset label diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index f0bf9fd5b3..708173ea26 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -315,7 +315,7 @@ void EditorFeatureProfileManager::_notification(int p_what) { current_profile = EDITOR_GET("_default_feature_profile"); if (!current_profile.is_empty()) { current.instantiate(); - Error err = current->load_from_file(EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(current_profile + ".profile")); + Error err = current->load_from_file(EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(current_profile + ".profile")); if (err != OK) { ERR_PRINT("Error loading default feature profile: " + current_profile); current_profile = String(); @@ -346,7 +346,7 @@ void EditorFeatureProfileManager::_update_profile_list(const String &p_select_pr if (p_select_profile.is_empty()) { //default, keep if (profile_list->get_selected() >= 0) { selected_profile = profile_list->get_item_metadata(profile_list->get_selected()); - if (!FileAccess::exists(EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(selected_profile + ".profile"))) { + if (!FileAccess::exists(EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(selected_profile + ".profile"))) { selected_profile = String(); //does not exist } } @@ -475,7 +475,7 @@ void EditorFeatureProfileManager::_create_new_profile() { EditorNode::get_singleton()->show_warning(TTR("Profile must be a valid filename and must not contain '.'")); return; } - String file = EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(name + ".profile"); + String file = EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(name + ".profile"); if (FileAccess::exists(file)) { EditorNode::get_singleton()->show_warning(TTR("Profile with this name already exists.")); return; @@ -630,7 +630,7 @@ void EditorFeatureProfileManager::_class_list_item_selected() { property->set_selectable(0, true); property->set_checked(0, !edited->is_class_property_disabled(class_name, name)); property->set_text(0, text); - property->set_tooltip(0, tooltip); + property->set_tooltip_text(0, tooltip); property->set_metadata(0, name); String icon_type = Variant::get_type_name(E.type); property->set_icon(0, EditorNode::get_singleton()->get_class_icon(icon_type)); @@ -754,8 +754,8 @@ void EditorFeatureProfileManager::_update_selected_profile() { } else { //reload edited, if different from current edited.instantiate(); - Error err = edited->load_from_file(EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(profile + ".profile")); - ERR_FAIL_COND_MSG(err != OK, "Error when loading editor feature profile from file '" + EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(profile + ".profile") + "'."); + Error err = edited->load_from_file(EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(profile + ".profile")); + ERR_FAIL_COND_MSG(err != OK, "Error when loading editor feature profile from file '" + EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(profile + ".profile") + "'."); } updating_features = true; @@ -810,7 +810,7 @@ void EditorFeatureProfileManager::_import_profiles(const Vector<String> &p_paths return; } - String dst_file = EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(basefile); + String dst_file = EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(basefile); if (FileAccess::exists(dst_file)) { EditorNode::get_singleton()->show_warning(vformat(TTR("Profile '%s' already exists. Remove it first before importing, import aborted."), basefile.get_basename())); @@ -825,7 +825,7 @@ void EditorFeatureProfileManager::_import_profiles(const Vector<String> &p_paths Error err = profile->load_from_file(p_paths[i]); ERR_CONTINUE(err != OK); String basefile = p_paths[i].get_file(); - String dst_file = EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(basefile); + String dst_file = EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(basefile); profile->save_to_file(dst_file); } @@ -849,7 +849,7 @@ void EditorFeatureProfileManager::_save_and_update() { ERR_FAIL_COND(edited_path.is_empty()); ERR_FAIL_COND(edited.is_null()); - edited->save_to_file(EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(edited_path + ".profile")); + edited->save_to_file(EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(edited_path + ".profile")); if (edited == current) { update_timer->start(); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 5d249b0fab..e24aa995c8 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -251,7 +251,7 @@ void EditorFileDialog::_file_submitted(const String &p_file) { } void EditorFileDialog::_save_confirm_pressed() { - String f = dir_access->get_current_dir().plus_file(file->get_text()); + String f = dir_access->get_current_dir().path_join(file->get_text()); _save_to_recent(); hide(); emit_signal(SNAME("file_selected"), f); @@ -284,7 +284,7 @@ void EditorFileDialog::_post_popup() { } if (is_visible() && !get_current_file().is_empty()) { - _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); + _request_single_thumbnail(get_current_dir().path_join(get_current_file())); } if (is_visible()) { @@ -381,7 +381,7 @@ void EditorFileDialog::_action_pressed() { Vector<String> files; for (int i = 0; i < item_list->get_item_count(); i++) { if (item_list->is_selected(i)) { - files.push_back(fbase.plus_file(item_list->get_item_text(i))); + files.push_back(fbase.path_join(item_list->get_item_text(i))); } } @@ -395,7 +395,7 @@ void EditorFileDialog::_action_pressed() { } String file_text = file->get_text(); - String f = file_text.is_absolute_path() ? file_text : dir_access->get_current_dir().plus_file(file_text); + String f = file_text.is_absolute_path() ? file_text : dir_access->get_current_dir().path_join(file_text); if ((mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_FILE) && dir_access->file_exists(f)) { _save_to_recent(); @@ -410,7 +410,7 @@ void EditorFileDialog::_action_pressed() { if (item_list->is_selected(i)) { Dictionary d = item_list->get_item_metadata(i); if (d["dir"]) { - path = path.plus_file(d["name"]); + path = path.path_join(d["name"]); break; } @@ -461,7 +461,7 @@ void EditorFileDialog::_action_pressed() { if (!valid && filterSliceCount > 0) { String str = (flt.get_slice(",", 0).strip_edges()); f += str.substr(1, str.length() - 1); - _request_single_thumbnail(get_current_dir().plus_file(f.get_file())); + _request_single_thumbnail(get_current_dir().path_join(f.get_file())); file->set_text(f.get_file()); valid = true; } @@ -505,7 +505,7 @@ void EditorFileDialog::_item_selected(int p_item) { if (!d["dir"]) { file->set_text(d["name"]); - _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); + _request_single_thumbnail(get_current_dir().path_join(get_current_file())); } else if (mode == FILE_MODE_OPEN_DIR) { set_ok_button_text(TTR("Select This Folder")); } @@ -523,7 +523,7 @@ void EditorFileDialog::_multi_selected(int p_item, bool p_selected) { if (!d["dir"] && p_selected) { file->set_text(d["name"]); - _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); + _request_single_thumbnail(get_current_dir().path_join(get_current_file())); } get_ok_button()->set_disabled(_is_open_should_be_disabled()); @@ -830,7 +830,7 @@ void EditorFileDialog::update_file_list() { Dictionary d; d["name"] = dir_name; - d["path"] = cdir.plus_file(dir_name); + d["path"] = cdir.path_join(dir_name); d["dir"] = true; item_list->set_item_metadata(-1, d); @@ -879,7 +879,7 @@ void EditorFileDialog::update_file_list() { item_list->add_item(files.front()->get()); if (get_icon_func) { - Ref<Texture2D> icon = get_icon_func(cdir.plus_file(files.front()->get())); + Ref<Texture2D> icon = get_icon_func(cdir.path_join(files.front()->get())); if (display_mode == DISPLAY_THUMBNAILS) { item_list->set_item_icon(-1, file_thumbnail); item_list->set_item_tag_icon(-1, icon); @@ -891,7 +891,7 @@ void EditorFileDialog::update_file_list() { Dictionary d; d["name"] = files.front()->get(); d["dir"] = false; - String fullpath = cdir.plus_file(files.front()->get()); + String fullpath = cdir.path_join(files.front()->get()); d["path"] = fullpath; item_list->set_item_metadata(-1, d); @@ -995,7 +995,7 @@ String EditorFileDialog::get_current_file() const { } String EditorFileDialog::get_current_path() const { - return dir_access->get_current_dir().plus_file(file->get_text()); + return dir_access->get_current_dir().path_join(file->get_text()); } void EditorFileDialog::set_current_dir(const String &p_dir) { @@ -1014,7 +1014,7 @@ void EditorFileDialog::set_current_file(const String &p_file) { _focus_file_text(); if (is_visible()) { - _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); + _request_single_thumbnail(get_current_dir().path_join(get_current_file())); } } diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index bda2e283ef..177bc6d2b2 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -99,7 +99,7 @@ String EditorFileSystemDirectory::get_path() const { String p; const EditorFileSystemDirectory *d = this; while (d->parent) { - p = d->name.plus_file(p); + p = d->name.path_join(p); d = d->parent; } @@ -110,7 +110,7 @@ String EditorFileSystemDirectory::get_file_path(int p_idx) const { String file = get_file(p_idx); const EditorFileSystemDirectory *d = this; while (d->parent) { - file = d->name.plus_file(file); + file = d->name.path_join(file); d = d->parent; } @@ -219,7 +219,7 @@ void EditorFileSystem::_scan_filesystem() { String project = ProjectSettings::get_singleton()->get_resource_path(); - String fscache = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(CACHE_FILE_NAME); + String fscache = EditorPaths::get_singleton()->get_project_settings_dir().path_join(CACHE_FILE_NAME); { Ref<FileAccess> f = FileAccess::open(fscache, FileAccess::READ); @@ -261,7 +261,7 @@ void EditorFileSystem::_scan_filesystem() { String file; file = name; - name = cpath.plus_file(name); + name = cpath.path_join(name); FileCache fc; fc.type = split[1]; @@ -289,7 +289,7 @@ void EditorFileSystem::_scan_filesystem() { } } - String update_cache = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("filesystem_update4"); + String update_cache = EditorPaths::get_singleton()->get_project_settings_dir().path_join("filesystem_update4"); if (FileAccess::exists(update_cache)) { { @@ -332,7 +332,7 @@ void EditorFileSystem::_scan_filesystem() { void EditorFileSystem::_save_filesystem_cache() { group_file_cache.clear(); - String fscache = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(CACHE_FILE_NAME); + String fscache = EditorPaths::get_singleton()->get_project_settings_dir().path_join(CACHE_FILE_NAME); Ref<FileAccess> f = FileAccess::open(fscache, FileAccess::WRITE); ERR_FAIL_COND_MSG(f.is_null(), "Cannot create file '" + fscache + "'. Check user write permissions."); @@ -758,7 +758,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc continue; } - if (_should_skip_directory(cd.plus_file(f))) { + if (_should_skip_directory(cd.path_join(f))) { continue; } @@ -822,7 +822,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo); fi->file = E->get(); - String path = cd.plus_file(fi->file); + String path = cd.path_join(fi->file); FileCache *fc = file_cache.getptr(path); uint64_t mt = FileAccess::get_modified_time(path); @@ -982,7 +982,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const int idx = p_dir->find_dir_index(f); if (idx == -1) { - if (_should_skip_directory(cd.plus_file(f))) { + if (_should_skip_directory(cd.path_join(f))) { continue; } @@ -991,7 +991,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const efd->parent = p_dir; efd->name = f; Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_RESOURCES); - d->change_dir(cd.plus_file(f)); + d->change_dir(cd.path_join(f)); _scan_new_dir(efd, d, p_progress.get_sub(1, 1)); ItemAction ia; @@ -1017,7 +1017,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo); fi->file = f; - String path = cd.plus_file(fi->file); + String path = cd.path_join(fi->file); fi->modified_time = FileAccess::get_modified_time(path); fi->import_modified_time = 0; fi->type = ResourceLoader::get_resource_type(path); @@ -1066,7 +1066,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const continue; } - String path = cd.plus_file(p_dir->files[i]->file); + String path = cd.path_join(p_dir->files[i]->file); if (import_extensions.has(p_dir->files[i]->file.get_extension().to_lower())) { //check here if file must be imported or not @@ -1452,7 +1452,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p void EditorFileSystem::_save_late_updated_files() { //files that already existed, and were modified, need re-scanning for dependencies upon project restart. This is done via saving this special file - String fscache = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("filesystem_update4"); + String fscache = EditorPaths::get_singleton()->get_project_settings_dir().path_join("filesystem_update4"); Ref<FileAccess> f = FileAccess::open(fscache, FileAccess::WRITE); ERR_FAIL_COND_MSG(f.is_null(), "Cannot create file '" + fscache + "'. Check user write permissions."); for (const String &E : late_update_files) { @@ -2198,12 +2198,12 @@ bool EditorFileSystem::_should_skip_directory(const String &p_path) { return true; } - if (FileAccess::exists(p_path.plus_file("project.godot"))) { + if (FileAccess::exists(p_path.path_join("project.godot"))) { // skip if another project inside this return true; } - if (FileAccess::exists(p_path.plus_file(".gdignore"))) { + if (FileAccess::exists(p_path.path_join(".gdignore"))) { // skip if a `.gdignore` file is inside this return true; } diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index c1d6e505db..d455e0248e 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -56,7 +56,7 @@ void EditorFolding::save_resource_folding(const Ref<Resource> &p_resource, const config->set_value("folding", "sections_unfolded", unfolds); String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; - file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(file); + file = EditorPaths::get_singleton()->get_project_settings_dir().path_join(file); config->save(file); } @@ -74,7 +74,7 @@ void EditorFolding::load_resource_folding(Ref<Resource> p_resource, const String config.instantiate(); String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; - file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(file); + file = EditorPaths::get_singleton()->get_project_settings_dir().path_join(file); if (config->load(file) != OK) { return; @@ -150,7 +150,7 @@ void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path config->set_value("folding", "nodes_folded", nodes_folded); String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; - file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(file); + file = EditorPaths::get_singleton()->get_project_settings_dir().path_join(file); config->save(file); } @@ -160,7 +160,7 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) { String path = EditorPaths::get_singleton()->get_project_settings_dir(); String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; - file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(file); + file = EditorPaths::get_singleton()->get_project_settings_dir().path_join(file); if (config->load(file) != OK) { return; @@ -214,7 +214,7 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) { bool EditorFolding::has_folding_data(const String &p_path) { String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; - file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(file); + file = EditorPaths::get_singleton()->get_project_settings_dir().path_join(file); return FileAccess::exists(file); } diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index fe03166a01..97f5363bb8 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1929,7 +1929,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } String image = bbcode.substr(brk_end + 1, end - brk_end - 1); - Ref<Texture2D> texture = ResourceLoader::load(base_path.plus_file(image), "Texture2D"); + Ref<Texture2D> texture = ResourceLoader::load(base_path.path_join(image), "Texture2D"); if (texture.is_valid()) { p_rt->add_image(texture); } @@ -1946,7 +1946,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } else if (tag.begins_with("font=")) { String fnt = tag.substr(5, tag.length()); - Ref<Font> font = ResourceLoader::load(base_path.plus_file(fnt), "Font"); + Ref<Font> font = ResourceLoader::load(base_path.path_join(fnt), "Font"); if (font.is_valid()) { p_rt->push_font(font); } else { diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index b4678d8363..2e35f21e47 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -562,8 +562,8 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const item->set_icon(0, icon); item->set_text(0, p_doc->name); item->set_text(1, TTR("Class")); - item->set_tooltip(0, tooltip); - item->set_tooltip(1, tooltip); + item->set_tooltip_text(0, tooltip); + item->set_tooltip_text(1, tooltip); item->set_metadata(0, "class_name:" + p_doc->name); if (p_gray) { item->set_custom_color(0, disabled_color); @@ -639,8 +639,8 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons item->set_icon(0, icon); item->set_text(0, text); item->set_text(1, TTRGET(p_type)); - item->set_tooltip(0, p_tooltip); - item->set_tooltip(1, p_tooltip); + item->set_tooltip_text(0, p_tooltip); + item->set_tooltip_text(1, p_tooltip); item->set_metadata(0, "class_" + p_metatype + ":" + p_class_name + ":" + p_name); _match_item(item, p_name); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 8716196658..6aa0bd3f99 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -231,7 +231,7 @@ void EditorProperty::_notification(int p_what) { bottom_child_rect = bottom_rect; } - update(); //need to redraw text + queue_redraw(); //need to redraw text } break; case NOTIFICATION_DRAW: { @@ -398,7 +398,7 @@ void EditorProperty::_notification(int p_what) { void EditorProperty::set_label(const String &p_label) { label = p_label; - update(); + queue_redraw(); } String EditorProperty::get_label() const { @@ -478,7 +478,7 @@ void EditorProperty::update_revert_and_pin_status() { } can_revert = new_can_revert; pinned = new_pinned; - update(); + queue_redraw(); } } @@ -499,7 +499,7 @@ bool EditorProperty::use_keying_next() const { void EditorProperty::set_checkable(bool p_checkable) { checkable = p_checkable; - update(); + queue_redraw(); queue_sort(); } @@ -509,7 +509,7 @@ bool EditorProperty::is_checkable() const { void EditorProperty::set_checked(bool p_checked) { checked = p_checked; - update(); + queue_redraw(); } bool EditorProperty::is_checked() const { @@ -518,18 +518,18 @@ bool EditorProperty::is_checked() const { void EditorProperty::set_draw_warning(bool p_draw_warning) { draw_warning = p_draw_warning; - update(); + queue_redraw(); } void EditorProperty::set_keying(bool p_keying) { keying = p_keying; - update(); + queue_redraw(); queue_sort(); } void EditorProperty::set_deletable(bool p_deletable) { deletable = p_deletable; - update(); + queue_redraw(); queue_sort(); } @@ -552,7 +552,7 @@ void EditorProperty::_focusable_focused(int p_index) { bool already_selected = selected; selected = true; selected_focusable = p_index; - update(); + queue_redraw(); if (!already_selected && selected) { emit_signal(SNAME("selected"), property, selected_focusable); } @@ -571,7 +571,7 @@ void EditorProperty::select(int p_focusable) { focusables[p_focusable]->grab_focus(); } else { selected = true; - update(); + queue_redraw(); } if (!already_selected && selected) { @@ -582,7 +582,7 @@ void EditorProperty::select(int p_focusable) { void EditorProperty::deselect() { selected = false; selected_focusable = -1; - update(); + queue_redraw(); } bool EditorProperty::is_selected() const { @@ -608,25 +608,25 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) { bool new_keying_hover = keying_rect.has_point(mpos) && !button_left; if (new_keying_hover != keying_hover) { keying_hover = new_keying_hover; - update(); + queue_redraw(); } bool new_delete_hover = delete_rect.has_point(mpos) && !button_left; if (new_delete_hover != delete_hover) { delete_hover = new_delete_hover; - update(); + queue_redraw(); } bool new_revert_hover = revert_rect.has_point(mpos) && !button_left; if (new_revert_hover != revert_hover) { revert_hover = new_revert_hover; - update(); + queue_redraw(); } bool new_check_hover = check_rect.has_point(mpos) && !button_left; if (new_check_hover != check_hover) { check_hover = new_check_hover; - update(); + queue_redraw(); } } @@ -641,7 +641,7 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) { if (!selected && selectable) { selected = true; emit_signal(SNAME("selected"), property, -1); - update(); + queue_redraw(); } if (keying_rect.has_point(mpos)) { @@ -681,7 +681,7 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) { if (check_rect.has_point(mpos)) { checked = !checked; - update(); + queue_redraw(); emit_signal(SNAME("property_checked"), property, checked); } } else if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) { @@ -912,7 +912,7 @@ void EditorProperty::menu_option(int p_option) { } break; case MENU_PIN_VALUE: { emit_signal(SNAME("property_pinned"), property, !pinned); - update(); + queue_redraw(); } break; case MENU_OPEN_DOCUMENTATION: { ScriptEditor::get_singleton()->goto_help(doc_path); @@ -961,7 +961,7 @@ void EditorProperty::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keying"), "set_keying", "is_keying"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "deletable"), "set_deletable", "is_deletable"); - ADD_SIGNAL(MethodInfo("property_changed", PropertyInfo(Variant::STRING_NAME, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT))); + ADD_SIGNAL(MethodInfo("property_changed", PropertyInfo(Variant::STRING_NAME, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), PropertyInfo(Variant::STRING_NAME, "field"), PropertyInfo(Variant::BOOL, "changing"))); ADD_SIGNAL(MethodInfo("multiple_properties_changed", PropertyInfo(Variant::PACKED_STRING_ARRAY, "properties"), PropertyInfo(Variant::ARRAY, "value"))); ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING_NAME, "property"))); ADD_SIGNAL(MethodInfo("property_deleted", PropertyInfo(Variant::STRING_NAME, "property"))); @@ -1372,26 +1372,26 @@ void EditorInspectorSection::_notification(int p_what) { } dropping = children_can_drop; - update(); + queue_redraw(); } break; case NOTIFICATION_DRAG_END: { dropping = false; - update(); + queue_redraw(); } break; case NOTIFICATION_MOUSE_ENTER: { if (dropping) { dropping_unfold_timer->start(); } - update(); + queue_redraw(); } break; case NOTIFICATION_MOUSE_EXIT: { if (dropping) { dropping_unfold_timer->stop(); } - update(); + queue_redraw(); } break; } } @@ -1477,7 +1477,7 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) { fold(); } } else if (mb.is_valid() && !mb->is_pressed()) { - update(); + queue_redraw(); } } @@ -1494,7 +1494,7 @@ void EditorInspectorSection::unfold() { object->editor_set_section_unfold(section, true); vbox->show(); - update(); + queue_redraw(); } void EditorInspectorSection::fold() { @@ -1508,7 +1508,7 @@ void EditorInspectorSection::fold() { object->editor_set_section_unfold(section, false); vbox->hide(); - update(); + queue_redraw(); } bool EditorInspectorSection::has_revertable_properties() const { @@ -1523,7 +1523,7 @@ void EditorInspectorSection::property_can_revert_changed(const String &p_path, b revertable_properties.erase(p_path); } if (has_revertable_properties() != had_revertable_properties) { - update(); + queue_redraw(); } } @@ -2052,8 +2052,8 @@ void EditorInspectorArray::_setup() { ae.panel->set_drag_forwarding(this); ae.panel->set_meta("index", begin_array_index + i); ae.panel->set_tooltip_text(vformat(TTR("Element %d: %s%d*"), i, array_element_prefix, i)); - ae.panel->connect("focus_entered", callable_mp((CanvasItem *)ae.panel, &PanelContainer::update)); - ae.panel->connect("focus_exited", callable_mp((CanvasItem *)ae.panel, &PanelContainer::update)); + ae.panel->connect("focus_entered", callable_mp((CanvasItem *)ae.panel, &PanelContainer::queue_redraw)); + ae.panel->connect("focus_exited", callable_mp((CanvasItem *)ae.panel, &PanelContainer::queue_redraw)); ae.panel->connect("draw", callable_mp(this, &EditorInspectorArray::_panel_draw).bind(i)); ae.panel->connect("gui_input", callable_mp(this, &EditorInspectorArray::_panel_gui_input).bind(i)); ae.panel->add_theme_style_override(SNAME("panel"), i % 2 ? odd_style : even_style); @@ -2155,7 +2155,7 @@ bool EditorInspectorArray::can_drop_data_fw(const Point2 &p_point, const Variant return false; } // First, update drawing. - control_dropping->update(); + control_dropping->queue_redraw(); if (p_data.get_type() != Variant::DICTIONARY) { return false; @@ -2206,14 +2206,14 @@ void EditorInspectorArray::_notification(int p_what) { Dictionary dict = get_viewport()->gui_get_drag_data(); if (dict.has("type") && dict["type"] == "property_array_element" && String(dict["property_array_prefix"]) == array_element_prefix) { dropping = true; - control_dropping->update(); + control_dropping->queue_redraw(); } } break; case NOTIFICATION_DRAG_END: { if (dropping) { dropping = false; - control_dropping->update(); + control_dropping->queue_redraw(); } } break; } diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 86b0145240..a3d4296edb 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -131,7 +131,7 @@ void EditorLog::_save_state() { Ref<ConfigFile> config; config.instantiate(); // Load and amend existing config if it exists. - config->load(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); const String section = "editor_log"; for (const KeyValue<MessageType, LogFilter *> &E : type_filter_map) { @@ -141,7 +141,7 @@ void EditorLog::_save_state() { config->set_value(section, "collapse", collapse); config->set_value(section, "show_search", search_box->is_visible()); - config->save(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + config->save(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); } void EditorLog::_load_state() { @@ -149,7 +149,7 @@ void EditorLog::_load_state() { Ref<ConfigFile> config; config.instantiate(); - config->load(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); // Run the below code even if config->load returns an error, since we want the defaults to be set even if the file does not exist yet. const String section = "editor_log"; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 9a188bbe38..0f2e0c8fcb 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -544,6 +544,9 @@ void EditorNode::_update_from_settings() { Viewport::SDFScale sdf_scale = Viewport::SDFScale(int(GLOBAL_GET("rendering/2d/sdf/scale"))); scene_root->set_sdf_scale(sdf_scale); + Viewport::MSAA msaa = Viewport::MSAA(int(GLOBAL_GET("rendering/anti_aliasing/quality/msaa_2d"))); + scene_root->set_msaa_2d(msaa); + float mesh_lod_threshold = GLOBAL_GET("rendering/mesh_lod/lod_change/threshold_pixels"); scene_root->set_mesh_lod_threshold(mesh_lod_threshold); @@ -750,6 +753,8 @@ void EditorNode::_notification(int p_what) { gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles"))); bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); + + tabbar_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("tabbar_background"), SNAME("TabContainer"))); scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"))); scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles"))); @@ -1096,7 +1101,7 @@ void EditorNode::_scan_external_changes() { } } - String project_settings_path = ProjectSettings::get_singleton()->get_resource_path().plus_file("project.godot"); + String project_settings_path = ProjectSettings::get_singleton()->get_resource_path().path_join("project.godot"); if (FileAccess::get_modified_time(project_settings_path) > ProjectSettings::get_singleton()->get_last_saved_time()) { TreeItem *ti = disk_changed_list->create_item(r); ti->set_text(0, "project.godot"); @@ -1314,7 +1319,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String file->set_current_file(p_resource->get_path().get_file()); } else { if (extensions.size()) { - String resource_name_snake_case = p_resource->get_class().camelcase_to_underscore(); + String resource_name_snake_case = p_resource->get_class().to_snake_case(); file->set_current_file("new_" + resource_name_snake_case + "." + preferred.front()->get().to_lower()); } else { file->set_current_file(String()); @@ -1331,7 +1336,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String } else if (preferred.size()) { String existing; if (extensions.size()) { - String resource_name_snake_case = p_resource->get_class().camelcase_to_underscore(); + String resource_name_snake_case = p_resource->get_class().to_snake_case(); existing = "new_" + resource_name_snake_case + "." + preferred.front()->get().to_lower(); } file->set_current_path(existing); @@ -1393,7 +1398,7 @@ void EditorNode::_get_scene_metadata(const String &p_file) { return; } - String path = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); + String path = EditorPaths::get_singleton()->get_project_settings_dir().path_join(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); Ref<ConfigFile> cf; cf.instantiate(); @@ -1425,7 +1430,7 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) { return; } - String path = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); + String path = EditorPaths::get_singleton()->get_project_settings_dir().path_join(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); Ref<ConfigFile> cf; cf.instantiate(); @@ -1621,7 +1626,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { // Save thumbnail directly, as thumbnailer may not update due to actual scene not changing md5. String temp_path = EditorPaths::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(p_file).md5_text(); - cache_base = temp_path.plus_file("resthumb-" + cache_base); + cache_base = temp_path.path_join("resthumb-" + cache_base); // Does not have it, try to load a cached thumbnail. String file = cache_base + ".png"; @@ -2730,10 +2735,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { // Use casing of the root node. break; case SCENE_NAME_CASING_PASCAL_CASE: { - root_name = root_name.capitalize().replace(" ", ""); + root_name = root_name.to_pascal_case(); } break; case SCENE_NAME_CASING_SNAKE_CASE: - root_name = root_name.capitalize().replace(" ", "").replace("-", "_").camelcase_to_underscore(); + root_name = root_name.replace("-", "_").to_snake_case(); break; } file->set_current_path(root_name + "." + extensions.front()->get().to_lower()); @@ -2908,7 +2913,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { OS::get_singleton()->shell_open(String("file://") + OS::get_singleton()->get_user_data_dir()); } break; case FILE_EXPLORE_ANDROID_BUILD_TEMPLATES: { - OS::get_singleton()->shell_open("file://" + ProjectSettings::get_singleton()->get_resource_path().plus_file("android")); + OS::get_singleton()->shell_open("file://" + ProjectSettings::get_singleton()->get_resource_path().path_join("android")); } break; case FILE_QUIT: case RUN_PROJECT_MANAGER: @@ -3445,7 +3450,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, // Only try to load the script if it has a name. Else, the plugin has no init script. if (script_path.length() > 0) { - script_path = addon_path.get_base_dir().plus_file(script_path); + script_path = addon_path.get_base_dir().path_join(script_path); script = ResourceLoader::load(script_path); if (script.is_null()) { @@ -4563,7 +4568,7 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { } if (nrect != dock_select_rect_over_idx) { - dock_select->update(); + dock_select->queue_redraw(); dock_select_rect_over_idx = nrect; } @@ -4589,7 +4594,7 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { dock_popup_selected_idx = nrect; dock_slot[nrect]->set_current_tab(dock_slot[nrect]->get_tab_count() - 1); dock_slot[nrect]->show(); - dock_select->update(); + dock_select->queue_redraw(); _update_dock_containers(); @@ -4601,7 +4606,7 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { void EditorNode::_dock_popup_exit() { dock_select_rect_over_idx = -1; - dock_select->update(); + dock_select->queue_redraw(); } void EditorNode::_dock_pre_popup(int p_which) { @@ -4619,7 +4624,7 @@ void EditorNode::_dock_move_left() { } dock_slot[dock_popup_selected_idx]->move_child(current, prev->get_index()); dock_slot[dock_popup_selected_idx]->set_current_tab(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1); - dock_select->update(); + dock_select->queue_redraw(); _edit_current(); _save_docks(); } @@ -4632,7 +4637,7 @@ void EditorNode::_dock_move_right() { } dock_slot[dock_popup_selected_idx]->move_child(next, current->get_index()); dock_slot[dock_popup_selected_idx]->set_current_tab(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1); - dock_select->update(); + dock_select->queue_redraw(); _edit_current(); _save_docks(); } @@ -4730,13 +4735,13 @@ void EditorNode::_save_docks() { Ref<ConfigFile> config; config.instantiate(); // Load and amend existing config if it exists. - config->load(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); _save_docks_to_config(config, "docks"); _save_open_scenes_to_config(config, "EditorNode"); editor_data.get_plugin_window_layout(config); - config->save(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + config->save(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); } void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section) { @@ -4800,7 +4805,7 @@ void EditorNode::_dock_split_dragged(int ofs) { void EditorNode::_load_docks() { Ref<ConfigFile> config; config.instantiate(); - Error err = config->load(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + Error err = config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); if (err != OK) { // No config. if (overridden_default_layout >= 0) { @@ -5033,7 +5038,7 @@ bool EditorNode::has_scenes_in_session() { } Ref<ConfigFile> config; config.instantiate(); - Error err = config->load(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + Error err = config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); if (err != OK) { return false; } @@ -5685,7 +5690,7 @@ void EditorNode::_add_dropped_files_recursive(const Vector<String> &p_files, Str for (int i = 0; i < p_files.size(); i++) { String from = p_files[i]; - String to = to_path.plus_file(from.get_file()); + String to = to_path.path_join(from.get_file()); if (dir->dir_exists(from)) { Vector<String> sub_files; @@ -5700,7 +5705,7 @@ void EditorNode::_add_dropped_files_recursive(const Vector<String> &p_files, Str continue; } - sub_files.push_back(from.plus_file(next_file)); + sub_files.push_back(from.path_join(next_file)); next_file = sub_dir->get_next(); } @@ -6487,8 +6492,11 @@ EditorNode::EditorNode() { tab_preview->set_position(Point2(2, 2) * EDSCALE); tab_preview_panel->add_child(tab_preview); + tabbar_panel = memnew(PanelContainer); + tabbar_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("tabbar_background"), SNAME("TabContainer"))); + srt->add_child(tabbar_panel); tabbar_container = memnew(HBoxContainer); - srt->add_child(tabbar_container); + tabbar_panel->add_child(tabbar_container); scene_tabs = memnew(TabBar); scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"))); diff --git a/editor/editor_node.h b/editor/editor_node.h index 792d2fc879..7e66e14ce0 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -426,6 +426,7 @@ private: int dock_popup_selected_idx = -1; int dock_select_rect_over_idx = -1; + PanelContainer *tabbar_panel = nullptr; HBoxContainer *tabbar_container = nullptr; Button *distraction_free = nullptr; Button *scene_tab_add = nullptr; diff --git a/editor/editor_paths.cpp b/editor/editor_paths.cpp index b6364e1ab7..54d4660cb6 100644 --- a/editor/editor_paths.cpp +++ b/editor/editor_paths.cpp @@ -67,19 +67,19 @@ String EditorPaths::get_self_contained_file() const { } String EditorPaths::get_export_templates_dir() const { - return get_data_dir().plus_file(export_templates_folder); + return get_data_dir().path_join(export_templates_folder); } String EditorPaths::get_project_settings_dir() const { - return get_project_data_dir().plus_file("editor"); + return get_project_data_dir().path_join("editor"); } String EditorPaths::get_text_editor_themes_dir() const { - return get_config_dir().plus_file(text_editor_themes_folder); + return get_config_dir().path_join(text_editor_themes_folder); } String EditorPaths::get_script_templates_dir() const { - return get_config_dir().plus_file(script_templates_folder); + return get_config_dir().path_join(script_templates_folder); } String EditorPaths::get_project_script_templates_dir() const { @@ -87,7 +87,7 @@ String EditorPaths::get_project_script_templates_dir() const { } String EditorPaths::get_feature_profiles_dir() const { - return get_config_dir().plus_file(feature_profiles_folder); + return get_config_dir().path_join(feature_profiles_folder); } void EditorPaths::create() { @@ -119,8 +119,8 @@ EditorPaths::EditorPaths() { String exe_path = OS::get_singleton()->get_executable_path().get_base_dir(); // On macOS, look outside .app bundle, since .app bundle is read-only. - if (OS::get_singleton()->has_feature("macos") && exe_path.ends_with("MacOS") && exe_path.plus_file("..").simplify_path().ends_with("Contents")) { - exe_path = exe_path.plus_file("../../..").simplify_path(); + if (OS::get_singleton()->has_feature("macos") && exe_path.ends_with("MacOS") && exe_path.path_join("..").simplify_path().ends_with("Contents")) { + exe_path = exe_path.path_join("../../..").simplify_path(); } { Ref<DirAccess> d = DirAccess::create_for_path(exe_path); @@ -141,24 +141,24 @@ EditorPaths::EditorPaths() { if (self_contained) { // editor is self contained, all in same folder data_path = exe_path; - data_dir = data_path.plus_file("editor_data"); + data_dir = data_path.path_join("editor_data"); config_path = exe_path; config_dir = data_dir; cache_path = exe_path; - cache_dir = data_dir.plus_file("cache"); + cache_dir = data_dir.path_join("cache"); } else { // Typically XDG_DATA_HOME or %APPDATA%. data_path = OS::get_singleton()->get_data_path(); - data_dir = data_path.plus_file(OS::get_singleton()->get_godot_dir_name()); + data_dir = data_path.path_join(OS::get_singleton()->get_godot_dir_name()); // Can be different from data_path e.g. on Linux or macOS. config_path = OS::get_singleton()->get_config_path(); - config_dir = config_path.plus_file(OS::get_singleton()->get_godot_dir_name()); + config_dir = config_path.path_join(OS::get_singleton()->get_godot_dir_name()); // Can be different from above paths, otherwise a subfolder of data_dir. cache_path = OS::get_singleton()->get_cache_path(); if (cache_path == data_path) { - cache_dir = data_dir.plus_file("cache"); + cache_dir = data_dir.path_join("cache"); } else { - cache_dir = cache_path.plus_file(OS::get_singleton()->get_godot_dir_name()); + cache_dir = cache_path.path_join(OS::get_singleton()->get_godot_dir_name()); } } @@ -232,7 +232,7 @@ EditorPaths::EditorPaths() { } // Check that the project data directory '.gdignore' file exists - String project_data_gdignore_file_path = project_data_dir.plus_file(".gdignore"); + String project_data_gdignore_file_path = project_data_dir.path_join(".gdignore"); if (!FileAccess::exists(project_data_gdignore_file_path)) { // Add an empty .gdignore file to avoid scan. Ref<FileAccess> f = FileAccess::open(project_data_gdignore_file_path, FileAccess::WRITE); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index b0bd500ef8..4fc6947636 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -599,7 +599,7 @@ int EditorPlugin::update_overlays() const { return count; } else { // This will update the normal viewport itself as well - CanvasItemEditor::get_singleton()->get_viewport_control()->update(); + CanvasItemEditor::get_singleton()->get_viewport_control()->queue_redraw(); return 1; } } diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index 5a010a66c1..a8df486381 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -102,7 +102,7 @@ void EditorPluginSettings::update_plugins() { TreeItem *item = plugin_list->create_item(root); item->set_text(0, name); - item->set_tooltip(0, TTR("Name:") + " " + name + "\n" + TTR("Path:") + " " + path + "\n" + TTR("Main Script:") + " " + script + "\n" + TTR("Description:") + " " + description); + item->set_tooltip_text(0, TTR("Name:") + " " + name + "\n" + TTR("Path:") + " " + path + "\n" + TTR("Main Script:") + " " + script + "\n" + TTR("Description:") + " " + description); item->set_metadata(0, path); item->set_text(1, version); item->set_metadata(1, script); @@ -178,8 +178,8 @@ Vector<String> EditorPluginSettings::_get_plugins(const String &p_dir) { continue; } - const String full_path = p_dir.plus_file(path); - const String plugin_config = full_path.plus_file("plugin.cfg"); + const String full_path = p_dir.path_join(path); + const String plugin_config = full_path.path_join("plugin.cfg"); if (FileAccess::exists(plugin_config)) { plugins.push_back(plugin_config); } else { diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 0e69c0e2f4..b7910a152e 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -951,7 +951,7 @@ void EditorPropertyLayersGrid::gui_input(const Ref<InputEvent> &p_ev) { bool expand_was_hovered = expand_hovered; expand_hovered = expand_rect.has_point(mm->get_position()); if (expand_hovered != expand_was_hovered) { - update(); + queue_redraw(); } if (!expand_hovered) { @@ -959,7 +959,7 @@ void EditorPropertyLayersGrid::gui_input(const Ref<InputEvent> &p_ev) { if (flag_rects[i].has_point(mm->get_position())) { // Used to highlight the hovered flag in the layers grid. hovered_index = i; - update(); + queue_redraw(); return; } } @@ -968,7 +968,7 @@ void EditorPropertyLayersGrid::gui_input(const Ref<InputEvent> &p_ev) { // Remove highlight when no square is hovered. if (hovered_index != -1) { hovered_index = -1; - update(); + queue_redraw(); } return; @@ -986,11 +986,11 @@ void EditorPropertyLayersGrid::gui_input(const Ref<InputEvent> &p_ev) { } emit_signal(SNAME("flag_changed"), value); - update(); + queue_redraw(); } else if (expand_hovered) { expanded = !expanded; update_minimum_size(); - update(); + queue_redraw(); } } if (mb.is_valid() && mb->get_button_index() == MouseButton::RIGHT && mb->is_pressed()) { @@ -1131,11 +1131,11 @@ void EditorPropertyLayersGrid::_notification(int p_what) { case NOTIFICATION_MOUSE_EXIT: { if (expand_hovered) { expand_hovered = false; - update(); + queue_redraw(); } if (hovered_index != -1) { hovered_index = -1; - update(); + queue_redraw(); } } break; } @@ -1143,7 +1143,7 @@ void EditorPropertyLayersGrid::_notification(int p_what) { void EditorPropertyLayersGrid::set_flag(uint32_t p_flag) { value = p_flag; - update(); + queue_redraw(); } void EditorPropertyLayersGrid::_bind_methods() { @@ -1276,7 +1276,7 @@ void EditorPropertyLayers::_menu_pressed(int p_menu) { } else { grid->value |= (1 << p_menu); } - grid->update(); + grid->queue_redraw(); layers->set_item_checked(layers->get_item_index(p_menu), grid->value & (1 << p_menu)); _grid_changed(grid->value); } @@ -1523,13 +1523,13 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { // Ensure the easing doesn't appear as being dragged dragging = false; - easing_draw->update(); + easing_draw->queue_redraw(); } if (mb->get_button_index() == MouseButton::LEFT) { dragging = mb->is_pressed(); // Update to display the correct dragging color - easing_draw->update(); + easing_draw->queue_redraw(); } } @@ -1569,7 +1569,7 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { val = CLAMP(val, -1'000'000, 1'000'000); emit_changed(get_edited_property(), val); - easing_draw->update(); + easing_draw->queue_redraw(); } } @@ -1621,14 +1621,14 @@ void EditorPropertyEasing::_draw_easing() { } void EditorPropertyEasing::update_property() { - easing_draw->update(); + easing_draw->queue_redraw(); } void EditorPropertyEasing::_set_preset(int p_preset) { static const float preset_value[EASING_MAX] = { 0.0, 1.0, 2.0, 0.5, -2.0, -0.5 }; emit_changed(get_edited_property(), preset_value[p_preset]); - easing_draw->update(); + easing_draw->queue_redraw(); } void EditorPropertyEasing::_setup_spin() { @@ -1667,7 +1667,7 @@ void EditorPropertyEasing::_spin_focus_exited() { spin->hide(); // Ensure the easing doesn't appear as being dragged dragging = false; - easing_draw->update(); + easing_draw->queue_redraw(); } void EditorPropertyEasing::setup(bool p_positive_only, bool p_flip) { @@ -3952,7 +3952,7 @@ void EditorPropertyResource::_update_property_bg() { } updating_theme = false; - update(); + queue_redraw(); } void EditorPropertyResource::_update_preferred_shader() { diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index f6953e8866..ad84b30689 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -509,7 +509,7 @@ void EditorPropertyArray::_notification(int p_what) { if (is_visible_in_tree()) { if (_is_drop_valid(get_viewport()->gui_get_drag_data())) { dropping = true; - edit->update(); + edit->queue_redraw(); } } } break; @@ -517,7 +517,7 @@ void EditorPropertyArray::_notification(int p_what) { case NOTIFICATION_DRAG_END: { if (dropping) { dropping = false; - edit->update(); + edit->queue_redraw(); } } break; } diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index ce05026696..22e7b01418 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -775,14 +775,14 @@ void EditorResourcePicker::_notification(int p_what) { case NOTIFICATION_DRAG_BEGIN: { if (editable && _is_drop_valid(get_viewport()->gui_get_drag_data())) { dropping = true; - assign_button->update(); + assign_button->queue_redraw(); } } break; case NOTIFICATION_DRAG_END: { if (dropping) { dropping = false; - assign_button->update(); + assign_button->queue_redraw(); } } break; } @@ -1049,7 +1049,7 @@ void EditorAudioStreamPicker::_notification(int p_what) { Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(audio_stream); if (preview.is_valid()) { if (preview->get_version() != last_preview_version) { - stream_preview_rect->update(); + stream_preview_rect->queue_redraw(); last_preview_version = preview->get_version(); } } @@ -1083,10 +1083,10 @@ void EditorAudioStreamPicker::_notification(int p_what) { } } - stream_preview_rect->update(); + stream_preview_rect->queue_redraw(); } else { if (tagged_frame_offset_count != 0) { - stream_preview_rect->update(); + stream_preview_rect->queue_redraw(); } tagged_frame_offset_count = 0; } @@ -1107,7 +1107,7 @@ void EditorAudioStreamPicker::_update_resource() { set_assign_button_min_size(Size2(1, font->get_height(font_size) * 1.5)); } - stream_preview_rect->update(); + stream_preview_rect->queue_redraw(); } void EditorAudioStreamPicker::_preview_draw() { diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index c0ea2b743e..706b77c142 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -244,7 +244,7 @@ void EditorResourcePreview::_iterate() { } else { String temp_path = EditorPaths::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(item.path).md5_text(); - cache_base = temp_path.plus_file("resthumb-" + cache_base); + cache_base = temp_path.path_join("resthumb-" + cache_base); //does not have it, try to load a cached thumbnail diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 1faefb5af7..94ee741db5 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -283,7 +283,7 @@ void SectionedInspector::update_category_list() { const String tooltip = EditorPropertyNameProcessor::get_singleton()->process_name(sectionarr[i], tooltip_style); ms->set_text(0, text); - ms->set_tooltip(0, tooltip); + ms->set_tooltip_text(0, tooltip); ms->set_metadata(0, metasection); ms->set_selectable(0, false); } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index f5d3b4842d..edd44b0a3a 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -856,7 +856,7 @@ void EditorSettings::create() { // Validate editor config file. Ref<DirAccess> dir = DirAccess::open(EditorPaths::get_singleton()->get_config_dir()); String config_file_name = "editor_settings-" + itos(VERSION_MAJOR) + ".tres"; - config_file_path = EditorPaths::get_singleton()->get_config_dir().plus_file(config_file_name); + config_file_path = EditorPaths::get_singleton()->get_config_dir().path_join(config_file_name); if (!dir->file_exists(config_file_name)) { goto fail; } @@ -887,7 +887,7 @@ fail: if (extra_config->has_section("init_projects")) { Vector<String> list = extra_config->get_value("init_projects", "list"); for (int i = 0; i < list.size(); i++) { - list.write[i] = exe_path.plus_file(list[i]); + list.write[i] = exe_path.path_join(list[i]); } extra_config->set_value("init_projects", "list", list); } @@ -1106,7 +1106,7 @@ void EditorSettings::add_property_hint(const PropertyInfo &p_hint) { void EditorSettings::set_project_metadata(const String &p_section, const String &p_key, Variant p_data) { Ref<ConfigFile> cf = memnew(ConfigFile); - String path = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("project_metadata.cfg"); + String path = EditorPaths::get_singleton()->get_project_settings_dir().path_join("project_metadata.cfg"); Error err; err = cf->load(path); ERR_FAIL_COND_MSG(err != OK && err != ERR_FILE_NOT_FOUND, "Cannot load editor settings from file '" + path + "'."); @@ -1117,7 +1117,7 @@ void EditorSettings::set_project_metadata(const String &p_section, const String Variant EditorSettings::get_project_metadata(const String &p_section, const String &p_key, Variant p_default) const { Ref<ConfigFile> cf = memnew(ConfigFile); - String path = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("project_metadata.cfg"); + String path = EditorPaths::get_singleton()->get_project_settings_dir().path_join("project_metadata.cfg"); Error err = cf->load(path); if (err != OK) { return p_default; @@ -1129,9 +1129,9 @@ void EditorSettings::set_favorites(const Vector<String> &p_favorites) { favorites = p_favorites; String favorites_file; if (Engine::get_singleton()->is_project_manager_hint()) { - favorites_file = EditorPaths::get_singleton()->get_config_dir().plus_file("favorite_dirs"); + favorites_file = EditorPaths::get_singleton()->get_config_dir().path_join("favorite_dirs"); } else { - favorites_file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("favorites"); + favorites_file = EditorPaths::get_singleton()->get_project_settings_dir().path_join("favorites"); } Ref<FileAccess> f = FileAccess::open(favorites_file, FileAccess::WRITE); if (f.is_valid()) { @@ -1149,9 +1149,9 @@ void EditorSettings::set_recent_dirs(const Vector<String> &p_recent_dirs) { recent_dirs = p_recent_dirs; String recent_dirs_file; if (Engine::get_singleton()->is_project_manager_hint()) { - recent_dirs_file = EditorPaths::get_singleton()->get_config_dir().plus_file("recent_dirs"); + recent_dirs_file = EditorPaths::get_singleton()->get_config_dir().path_join("recent_dirs"); } else { - recent_dirs_file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("recent_dirs"); + recent_dirs_file = EditorPaths::get_singleton()->get_project_settings_dir().path_join("recent_dirs"); } Ref<FileAccess> f = FileAccess::open(recent_dirs_file, FileAccess::WRITE); if (f.is_valid()) { @@ -1169,11 +1169,11 @@ void EditorSettings::load_favorites_and_recent_dirs() { String favorites_file; String recent_dirs_file; if (Engine::get_singleton()->is_project_manager_hint()) { - favorites_file = EditorPaths::get_singleton()->get_config_dir().plus_file("favorite_dirs"); - recent_dirs_file = EditorPaths::get_singleton()->get_config_dir().plus_file("recent_dirs"); + favorites_file = EditorPaths::get_singleton()->get_config_dir().path_join("favorite_dirs"); + recent_dirs_file = EditorPaths::get_singleton()->get_config_dir().path_join("recent_dirs"); } else { - favorites_file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("favorites"); - recent_dirs_file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("recent_dirs"); + favorites_file = EditorPaths::get_singleton()->get_project_settings_dir().path_join("favorites"); + recent_dirs_file = EditorPaths::get_singleton()->get_project_settings_dir().path_join("recent_dirs"); } Ref<FileAccess> f = FileAccess::open(favorites_file, FileAccess::READ); if (f.is_valid()) { @@ -1236,7 +1236,7 @@ void EditorSettings::load_text_editor_theme() { return; // sorry for "Settings changed" console spam } - String theme_path = EditorPaths::get_singleton()->get_text_editor_themes_dir().plus_file(p_file + ".tet"); + String theme_path = EditorPaths::get_singleton()->get_text_editor_themes_dir().path_join(p_file + ".tet"); Ref<ConfigFile> cf = memnew(ConfigFile); Error err = cf->load(theme_path); @@ -1273,7 +1273,7 @@ bool EditorSettings::import_text_editor_theme(String p_file) { Ref<DirAccess> d = DirAccess::open(EditorPaths::get_singleton()->get_text_editor_themes_dir()); if (d.is_valid()) { - d->copy(p_file, EditorPaths::get_singleton()->get_text_editor_themes_dir().plus_file(p_file.get_file())); + d->copy(p_file, EditorPaths::get_singleton()->get_text_editor_themes_dir().path_join(p_file.get_file())); return true; } } @@ -1286,7 +1286,7 @@ bool EditorSettings::save_text_editor_theme() { if (_is_default_text_editor_theme(p_file.get_file().to_lower())) { return false; } - String theme_path = EditorPaths::get_singleton()->get_text_editor_themes_dir().plus_file(p_file + ".tet"); + String theme_path = EditorPaths::get_singleton()->get_text_editor_themes_dir().path_join(p_file + ".tet"); return _save_text_editor_theme(theme_path); } @@ -1339,7 +1339,7 @@ Vector<String> EditorSettings::get_script_templates(const String &p_extension, c } String EditorSettings::get_editor_layouts_config() const { - return EditorPaths::get_singleton()->get_config_dir().plus_file("editor_layouts.cfg"); + return EditorPaths::get_singleton()->get_config_dir().path_join("editor_layouts.cfg"); } float EditorSettings::get_auto_display_scale() const { diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index 67c602ad2d..d190ab57c3 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -440,7 +440,7 @@ void EditorSettingsDialog::_update_shortcuts() { const String tooltip = EditorPropertyNameProcessor::get_singleton()->process_name(section_name, tooltip_style); section->set_text(0, item_name); - section->set_tooltip(0, tooltip); + section->set_tooltip_text(0, tooltip); section->set_selectable(0, false); section->set_selectable(1, false); section->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index b9a3e9decf..73c365ce4a 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -82,7 +82,7 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &p_event) { if (grabbing_spinner) { Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); Input::get_singleton()->warp_mouse(grabbing_spinner_mouse_pos); - update(); + queue_redraw(); } else { _focus_entered(); } @@ -93,7 +93,7 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &p_event) { } } else if (mb->get_button_index() == MouseButton::WHEEL_UP || mb->get_button_index() == MouseButton::WHEEL_DOWN) { if (grabber->is_visible()) { - call_deferred(SNAME("update")); + call_deferred(SNAME("queue_redraw")); } } } @@ -137,7 +137,7 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &p_event) { bool new_hover = (mm->get_position().x > updown_offset); if (new_hover != hover_updown) { hover_updown = new_hover; - update(); + queue_redraw(); } } } @@ -190,7 +190,7 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(Math::is_zero_approx(scale_x)); float grabbing_ofs = (grabber->get_transform().xform(mm->get_position()).x - grabbing_from) / float(grabber_range) / scale_x; set_as_ratio(grabbing_ratio + grabbing_ofs); - update(); + queue_redraw(); } } @@ -463,12 +463,12 @@ void EditorSpinSlider::_notification(int p_what) { case NOTIFICATION_MOUSE_ENTER: { mouse_over_spin = true; - update(); + queue_redraw(); } break; case NOTIFICATION_MOUSE_EXIT: { mouse_over_spin = false; - update(); + queue_redraw(); } break; case NOTIFICATION_FOCUS_ENTER: { @@ -498,7 +498,7 @@ Size2 EditorSpinSlider::get_minimum_size() const { void EditorSpinSlider::set_hide_slider(bool p_hide) { hide_slider = p_hide; - update(); + queue_redraw(); } bool EditorSpinSlider::is_hiding_slider() const { @@ -507,7 +507,7 @@ bool EditorSpinSlider::is_hiding_slider() const { void EditorSpinSlider::set_label(const String &p_label) { label = p_label; - update(); + queue_redraw(); } String EditorSpinSlider::get_label() const { @@ -516,7 +516,7 @@ String EditorSpinSlider::get_label() const { void EditorSpinSlider::set_suffix(const String &p_suffix) { suffix = p_suffix; - update(); + queue_redraw(); } String EditorSpinSlider::get_suffix() const { @@ -583,17 +583,17 @@ void EditorSpinSlider::_value_focus_exited() { void EditorSpinSlider::_grabber_mouse_entered() { mouse_over_grabber = true; - update(); + queue_redraw(); } void EditorSpinSlider::_grabber_mouse_exited() { mouse_over_grabber = false; - update(); + queue_redraw(); } void EditorSpinSlider::set_read_only(bool p_enable) { read_only = p_enable; - update(); + queue_redraw(); } bool EditorSpinSlider::is_read_only() const { @@ -602,7 +602,7 @@ bool EditorSpinSlider::is_read_only() const { void EditorSpinSlider::set_flat(bool p_enable) { flat = p_enable; - update(); + queue_redraw(); } bool EditorSpinSlider::is_flat() const { diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 827a657a31..088239c2d9 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -476,6 +476,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color font_color = mono_color.lerp(base_color, 0.25); const Color font_hover_color = mono_color.lerp(base_color, 0.125); const Color font_focus_color = mono_color.lerp(base_color, 0.125); + const Color font_hover_pressed_color = font_hover_color.lerp(accent_color, 0.74); const Color font_disabled_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.3); const Color font_readonly_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.65); const Color font_placeholder_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.6); @@ -655,45 +656,46 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // TabBar - Ref<StyleBoxFlat> style_tab_selected = style_widget->duplicate(); + Ref<StyleBoxFlat> style_tab_base = style_widget->duplicate(); - // Add a highlight line at the top of the selected tab. - style_tab_selected->set_border_width_all(0); - style_tab_selected->set_default_margin(SIDE_LEFT, widget_default_margin.x - border_width); - style_tab_selected->set_border_width(SIDE_TOP, Math::round(2 * EDSCALE)); - // Make the highlight line prominent, but not too prominent as to not be distracting. - Color tab_highlight = dark_color_2.lerp(accent_color, 0.75); - style_tab_selected->set_border_color(tab_highlight); + style_tab_base->set_border_width_all(0); // Don't round the top corners to avoid creating a small blank space between the tabs and the main panel. // This also makes the top highlight look better. - style_tab_selected->set_corner_radius_all(0); + style_tab_base->set_corner_detail(corner_width); + style_tab_base->set_corner_radius_all(0); + style_tab_base->set_corner_radius(CORNER_TOP_LEFT, corner_radius * EDSCALE); + style_tab_base->set_corner_radius(CORNER_TOP_RIGHT, corner_radius * EDSCALE); // Prevent visible artifacts and cover the top-left rounded corner of the panel below the tab if selected // We can't prevent them with both rounded corners and non-zero border width, though - style_tab_selected->set_expand_margin_size(SIDE_BOTTOM, corner_width > 0 ? corner_width : border_width); - + style_tab_base->set_expand_margin_size(SIDE_BOTTOM, corner_width > 0 ? corner_width : border_width); // When using a border width greater than 0, visually line up the left of the selected tab with the underlying panel. - style_tab_selected->set_expand_margin_size(SIDE_LEFT, -border_width); + style_tab_base->set_expand_margin_size(SIDE_LEFT, -border_width); + + style_tab_base->set_default_margin(SIDE_LEFT, widget_default_margin.x + 5 * EDSCALE); + style_tab_base->set_default_margin(SIDE_RIGHT, widget_default_margin.x + 5 * EDSCALE); + style_tab_base->set_default_margin(SIDE_BOTTOM, widget_default_margin.y); + style_tab_base->set_default_margin(SIDE_TOP, widget_default_margin.y); + + Ref<StyleBoxFlat> style_tab_selected = style_tab_base->duplicate(); - style_tab_selected->set_default_margin(SIDE_LEFT, widget_default_margin.x + 2 * EDSCALE); - style_tab_selected->set_default_margin(SIDE_RIGHT, widget_default_margin.x + 2 * EDSCALE); - style_tab_selected->set_default_margin(SIDE_BOTTOM, widget_default_margin.y); - style_tab_selected->set_default_margin(SIDE_TOP, widget_default_margin.y); style_tab_selected->set_bg_color(base_color); + // Add a highlight line at the top of the selected tab. + style_tab_selected->set_border_width(SIDE_TOP, Math::round(2 * EDSCALE)); + // Make the highlight line prominent, but not too prominent as to not be distracting. + Color tab_highlight = dark_color_2.lerp(accent_color, 0.75); + style_tab_selected->set_border_color(tab_highlight); + style_tab_selected->set_corner_radius_all(0); - Ref<StyleBoxFlat> style_tab_unselected = style_tab_selected->duplicate(); - style_tab_unselected->set_bg_color(dark_color_1); + Ref<StyleBoxFlat> style_tab_unselected = style_tab_base->duplicate(); style_tab_unselected->set_expand_margin_size(SIDE_BOTTOM, 0); + style_tab_unselected->set_bg_color(dark_color_1); // Add some spacing between unselected tabs to make them easier to distinguish from each other style_tab_unselected->set_border_color(Color(0, 0, 0, 0)); - style_tab_unselected->set_border_width(SIDE_LEFT, Math::round(1 * EDSCALE)); - style_tab_unselected->set_border_width(SIDE_RIGHT, Math::round(1 * EDSCALE)); - style_tab_unselected->set_default_margin(SIDE_LEFT, widget_default_margin.x + 2 * EDSCALE); - style_tab_unselected->set_default_margin(SIDE_RIGHT, widget_default_margin.x + 2 * EDSCALE); - Ref<StyleBoxFlat> style_tab_disabled = style_tab_selected->duplicate(); - style_tab_disabled->set_bg_color(disabled_bg_color); + Ref<StyleBoxFlat> style_tab_disabled = style_tab_base->duplicate(); style_tab_disabled->set_expand_margin_size(SIDE_BOTTOM, 0); + style_tab_disabled->set_bg_color(disabled_bg_color); style_tab_disabled->set_border_color(disabled_bg_color); // Editor background @@ -750,6 +752,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "MenuButton", font_color); theme->set_color("font_hover_color", "MenuButton", font_hover_color); + theme->set_color("font_hover_pressed_color", "MenuButton", font_hover_pressed_color); theme->set_color("font_focus_color", "MenuButton", font_focus_color); theme->set_stylebox("MenuHover", "EditorStyles", style_widget_hover); @@ -763,6 +766,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "Button", font_color); theme->set_color("font_hover_color", "Button", font_hover_color); + theme->set_color("font_hover_pressed_color", "Button", font_hover_pressed_color); theme->set_color("font_focus_color", "Button", font_focus_color); theme->set_color("font_pressed_color", "Button", accent_color); theme->set_color("font_disabled_color", "Button", font_disabled_color); @@ -815,6 +819,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "MenuBar", font_color); theme->set_color("font_hover_color", "MenuBar", font_hover_color); + theme->set_color("font_hover_pressed_color", "MenuBar", font_hover_pressed_color); theme->set_color("font_focus_color", "MenuBar", font_focus_color); theme->set_color("font_pressed_color", "MenuBar", accent_color); theme->set_color("font_disabled_color", "MenuBar", font_disabled_color); @@ -851,6 +856,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "OptionButton", font_color); theme->set_color("font_hover_color", "OptionButton", font_hover_color); + theme->set_color("font_hover_pressed_color", "OptionButton", font_hover_pressed_color); theme->set_color("font_focus_color", "OptionButton", font_focus_color); theme->set_color("font_pressed_color", "OptionButton", accent_color); theme->set_color("font_disabled_color", "OptionButton", font_disabled_color); @@ -885,6 +891,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "CheckButton", font_color); theme->set_color("font_hover_color", "CheckButton", font_hover_color); + theme->set_color("font_hover_pressed_color", "CheckButton", font_hover_pressed_color); theme->set_color("font_focus_color", "CheckButton", font_focus_color); theme->set_color("font_pressed_color", "CheckButton", accent_color); theme->set_color("font_disabled_color", "CheckButton", font_disabled_color); @@ -921,6 +928,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "CheckBox", font_color); theme->set_color("font_hover_color", "CheckBox", font_hover_color); + theme->set_color("font_hover_pressed_color", "CheckBox", font_hover_pressed_color); theme->set_color("font_focus_color", "CheckBox", font_focus_color); theme->set_color("font_pressed_color", "CheckBox", accent_color); theme->set_color("font_disabled_color", "CheckBox", font_disabled_color); @@ -1192,6 +1200,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("line_separation", "ItemList", 3 * EDSCALE); // TabBar & TabContainer + Ref<StyleBoxFlat> style_tabbar_background = make_flat_stylebox(dark_color_1, 0, 0, 0, 0); + style_tabbar_background->set_expand_margin_size(SIDE_BOTTOM, corner_width > 0 ? corner_width : border_width); + style_tabbar_background->set_corner_detail(corner_width); + style_tabbar_background->set_corner_radius(CORNER_TOP_LEFT, corner_radius * EDSCALE); + style_tabbar_background->set_corner_radius(CORNER_TOP_RIGHT, corner_radius * EDSCALE); + theme->set_stylebox("tabbar_background", "TabContainer", style_tabbar_background); + theme->set_stylebox("tab_selected", "TabContainer", style_tab_selected); theme->set_stylebox("tab_unselected", "TabContainer", style_tab_unselected); theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled); @@ -1227,14 +1242,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Ref<StyleBoxFlat> style_content_panel = style_default->duplicate(); style_content_panel->set_border_color(dark_color_3); style_content_panel->set_border_width_all(border_width); + style_content_panel->set_border_width(Side::SIDE_TOP, 0); + style_content_panel->set_corner_radius(CORNER_TOP_LEFT, 0); + style_content_panel->set_corner_radius(CORNER_TOP_RIGHT, 0); // compensate the border style_content_panel->set_default_margin(SIDE_TOP, (2 + margin_size_extra) * EDSCALE); style_content_panel->set_default_margin(SIDE_RIGHT, margin_size_extra * EDSCALE); style_content_panel->set_default_margin(SIDE_BOTTOM, margin_size_extra * EDSCALE); style_content_panel->set_default_margin(SIDE_LEFT, margin_size_extra * EDSCALE); - // Display border to visually split the body of the container from its possible backgrounds. - style_content_panel->set_border_width(Side::SIDE_TOP, Math::round(2 * EDSCALE)); - style_content_panel->set_border_color(dark_color_2); theme->set_stylebox("panel", "TabContainer", style_content_panel); // TabContainerOdd can be used on tabs against the base color background (e.g. nested tabs). @@ -1478,6 +1493,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("focus", "LinkButton", style_empty); theme->set_color("font_color", "LinkButton", font_color); theme->set_color("font_hover_color", "LinkButton", font_hover_color); + theme->set_color("font_hover_pressed_color", "LinkButton", font_hover_pressed_color); theme->set_color("font_focus_color", "LinkButton", font_focus_color); theme->set_color("font_pressed_color", "LinkButton", accent_color); theme->set_color("font_disabled_color", "LinkButton", font_disabled_color); @@ -1508,8 +1524,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { control_editor_popup_style->set_default_margin(SIDE_BOTTOM, default_margin_size * EDSCALE); control_editor_popup_style->set_border_width_all(0); - theme->set_stylebox("panel", "ControlEditorPopupButton", control_editor_popup_style); - theme->set_type_variation("ControlEditorPopupButton", "PopupPanel"); + theme->set_stylebox("panel", "ControlEditorPopupPanel", control_editor_popup_style); + theme->set_type_variation("ControlEditorPopupPanel", "PopupPanel"); // SpinBox theme->set_icon("updown", "SpinBox", theme->get_icon(SNAME("GuiSpinboxUpdown"), SNAME("EditorIcons"))); diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp index bb29b1c171..5b015fc95c 100644 --- a/editor/editor_toaster.cpp +++ b/editor/editor_toaster.cpp @@ -62,7 +62,7 @@ void EditorToaster::_notification(int p_what) { if (toasts[element.key].remaining_time < 0) { close(element.key); } - element.key->update(); + element.key->queue_redraw(); } } else { // Reset the timers when hovered. @@ -71,7 +71,7 @@ void EditorToaster::_notification(int p_what) { continue; } toasts[element.key].remaining_time = element.value.duration; - element.key->update(); + element.key->queue_redraw(); } } @@ -101,7 +101,7 @@ void EditorToaster::_notification(int p_what) { if (needs_update) { _update_vbox_position(); _update_disable_notifications_button(); - main_button->update(); + main_button->queue_redraw(); } } break; @@ -132,8 +132,8 @@ void EditorToaster::_notification(int p_what) { error_panel_style_progress->set_bg_color(get_theme_color(SNAME("base_color"), SNAME("Editor")).lightened(0.03)); error_panel_style_progress->set_border_color(get_theme_color(SNAME("error_color"), SNAME("Editor"))); - main_button->update(); - disable_notifications_button->update(); + main_button->queue_redraw(); + disable_notifications_button->queue_redraw(); } break; case NOTIFICATION_TRANSFORM_CHANGED: { @@ -334,7 +334,7 @@ void EditorToaster::_repop_old() { if (needs_update) { _update_vbox_position(); _update_disable_notifications_button(); - main_button->update(); + main_button->queue_redraw(); } } @@ -389,7 +389,7 @@ Control *EditorToaster::popup(Control *p_control, Severity p_severity, double p_ _auto_hide_or_free_toasts(); _update_vbox_position(); _update_disable_notifications_button(); - main_button->update(); + main_button->queue_redraw(); return panel; } @@ -438,7 +438,7 @@ void EditorToaster::_popup_str(String p_message, Severity p_severity, String p_t _auto_hide_or_free_toasts(); _update_vbox_position(); _update_disable_notifications_button(); - main_button->update(); + main_button->queue_redraw(); } // Retrieve the label back then update the text. diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp index cb188f9c3e..53cc8d5b22 100644 --- a/editor/editor_vcs_interface.cpp +++ b/editor/editor_vcs_interface.cpp @@ -168,14 +168,14 @@ void EditorVCSInterface::set_singleton(EditorVCSInterface *p_singleton) { void EditorVCSInterface::create_vcs_metadata_files(VCSMetadata p_vcs_metadata_type, String &p_dir) { if (p_vcs_metadata_type == VCSMetadata::GIT) { - Ref<FileAccess> f = FileAccess::open(p_dir.plus_file(".gitignore"), FileAccess::WRITE); + Ref<FileAccess> f = FileAccess::open(p_dir.path_join(".gitignore"), FileAccess::WRITE); if (f.is_null()) { ERR_FAIL_MSG(TTR("Couldn't create .gitignore in project path.")); } else { f->store_line("# Godot 4+ specific ignores"); f->store_line(".godot/"); } - f = FileAccess::open(p_dir.plus_file(".gitattributes"), FileAccess::WRITE); + f = FileAccess::open(p_dir.path_join(".gitattributes"), FileAccess::WRITE); if (f.is_null()) { ERR_FAIL_MSG(TTR("Couldn't create .gitattributes in project path.")); } else { diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 8283c24e61..e07b5e4cdb 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -295,7 +295,7 @@ Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const { String EditorExportPlatform::find_export_template(String template_file_name, String *err) const { String current_version = VERSION_FULL_CONFIG; - String template_path = EditorPaths::get_singleton()->get_export_templates_dir().plus_file(current_version).plus_file(template_file_name); + String template_path = EditorPaths::get_singleton()->get_export_templates_dir().path_join(current_version).path_join(template_file_name); if (FileAccess::exists(template_path)) { return template_path; @@ -848,7 +848,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } } else { // Use default text server data. - String icu_data_file = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmp_icu_data"); + String icu_data_file = EditorPaths::get_singleton()->get_cache_dir().path_join("tmp_icu_data"); TS->save_support_data(icu_data_file); Vector<uint8_t> array = FileAccess::get_file_as_array(icu_data_file); err = p_func(p_udata, ts_data, array, idx, total, enc_in_filters, enc_ex_filters, key); @@ -861,7 +861,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } String config_file = "project.binary"; - String engine_cfb = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmp" + config_file); + String engine_cfb = EditorPaths::get_singleton()->get_cache_dir().path_join("tmp" + config_file); ProjectSettings::get_singleton()->save_custom(engine_cfb, custom_map, custom_list); Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb); DirAccess::remove_file_or_error(engine_cfb); @@ -885,7 +885,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); da->make_dir_recursive(EditorPaths::get_singleton()->get_cache_dir()); - String tmppath = EditorPaths::get_singleton()->get_cache_dir().plus_file("packtmp"); + String tmppath = EditorPaths::get_singleton()->get_cache_dir().path_join("packtmp"); Ref<FileAccess> ftmp = FileAccess::open(tmppath, FileAccess::WRITE); if (ftmp.is_null()) { add_message(EXPORT_MESSAGE_ERROR, TTR("Save PCK"), vformat(TTR("Cannot create file \"%s\"."), tmppath)); diff --git a/editor/export/editor_export_platform_pc.cpp b/editor/export/editor_export_platform_pc.cpp index 9fca4c908a..8538414523 100644 --- a/editor/export/editor_export_platform_pc.cpp +++ b/editor/export/editor_export_platform_pc.cpp @@ -185,9 +185,9 @@ Error EditorExportPlatformPC::export_project_data(const Ref<EditorExportPreset> String src_path = ProjectSettings::get_singleton()->globalize_path(so_files[i].path); String target_path; if (so_files[i].target.is_empty()) { - target_path = p_path.get_base_dir().plus_file(src_path.get_file()); + target_path = p_path.get_base_dir().path_join(src_path.get_file()); } else { - target_path = p_path.get_base_dir().plus_file(so_files[i].target).plus_file(src_path.get_file()); + target_path = p_path.get_base_dir().path_join(so_files[i].target).path_join(src_path.get_file()); } if (da->dir_exists(src_path)) { diff --git a/editor/export/editor_export_plugin.cpp b/editor/export/editor_export_plugin.cpp index cf3a9b0810..27a671a919 100644 --- a/editor/export/editor_export_plugin.cpp +++ b/editor/export/editor_export_plugin.cpp @@ -181,7 +181,7 @@ void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, con if (!convert) { return; } - String tmp_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmpfile.res"); + String tmp_path = EditorPaths::get_singleton()->get_cache_dir().path_join("tmpfile.res"); Error err = ResourceFormatLoaderText::convert_file_to_binary(p_path, tmp_path); if (err != OK) { DirAccess::remove_file_or_error(tmp_path); diff --git a/editor/export/export_template_manager.cpp b/editor/export/export_template_manager.cpp index a0afcf4237..0ecbc9a8a3 100644 --- a/editor/export/export_template_manager.cpp +++ b/editor/export/export_template_manager.cpp @@ -91,7 +91,7 @@ void ExportTemplateManager::_update_template_status() { install_options_vb->show(); if (templates.has(current_version)) { - current_installed_path->set_text(templates_dir.plus_file(current_version)); + current_installed_path->set_text(templates_dir.path_join(current_version)); } } @@ -146,7 +146,7 @@ void ExportTemplateManager::_download_template(const String &p_url, bool p_skip_ download_progress_hb->show(); _set_current_progress_status(TTR("Starting the download...")); - download_templates->set_download_file(EditorPaths::get_singleton()->get_cache_dir().plus_file("tmp_templates.tpz")); + download_templates->set_download_file(EditorPaths::get_singleton()->get_cache_dir().path_join("tmp_templates.tpz")); download_templates->set_use_threads(true); const String proxy_host = EDITOR_GET("network/http_proxy/host"); @@ -440,7 +440,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ } Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - String template_path = EditorPaths::get_singleton()->get_export_templates_dir().plus_file(version); + String template_path = EditorPaths::get_singleton()->get_export_templates_dir().path_join(version); Error err = d->make_dir_recursive(template_path); if (err != OK) { EditorNode::get_singleton()->show_warning(TTR("Error creating path for extracting templates:") + "\n" + template_path); @@ -486,12 +486,12 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ if (base_dir != contents_dir && base_dir.begins_with(contents_dir)) { base_dir = base_dir.substr(contents_dir.length(), file_path.length()).trim_prefix("/"); - file = base_dir.plus_file(file); + file = base_dir.path_join(file); Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); ERR_CONTINUE(da.is_null()); - String output_dir = template_path.plus_file(base_dir); + String output_dir = template_path.path_join(base_dir); if (!DirAccess::exists(output_dir)) { Error mkdir_err = da->make_dir_recursive(output_dir); @@ -503,7 +503,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ p->step(TTR("Importing:") + " " + file, fc); } - String to_write = template_path.plus_file(file); + String to_write = template_path.path_join(file); Ref<FileAccess> f = FileAccess::open(to_write, FileAccess::WRITE); if (f.is_null()) { @@ -544,14 +544,14 @@ void ExportTemplateManager::_uninstall_template_confirmed() { Error err = da->change_dir(templates_dir); ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir + "'."); err = da->change_dir(uninstall_version); - ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir.plus_file(uninstall_version) + "'."); + ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir.path_join(uninstall_version) + "'."); err = da->erase_contents_recursive(); - ERR_FAIL_COND_MSG(err != OK, "Could not remove all templates in '" + templates_dir.plus_file(uninstall_version) + "'."); + ERR_FAIL_COND_MSG(err != OK, "Could not remove all templates in '" + templates_dir.path_join(uninstall_version) + "'."); da->change_dir(".."); err = da->remove(uninstall_version); - ERR_FAIL_COND_MSG(err != OK, "Could not remove templates directory at '" + templates_dir.plus_file(uninstall_version) + "'."); + ERR_FAIL_COND_MSG(err != OK, "Could not remove templates directory at '" + templates_dir.path_join(uninstall_version) + "'."); _update_template_status(); } @@ -618,7 +618,7 @@ void ExportTemplateManager::_installed_table_button_cbk(Object *p_item, int p_co void ExportTemplateManager::_open_template_folder(const String &p_version) { const String &templates_dir = EditorPaths::get_singleton()->get_export_templates_dir(); - OS::get_singleton()->shell_open("file://" + templates_dir.plus_file(p_version)); + OS::get_singleton()->shell_open("file://" + templates_dir.path_join(p_version)); } void ExportTemplateManager::popup_manager() { @@ -641,13 +641,13 @@ void ExportTemplateManager::_hide_dialog() { } bool ExportTemplateManager::can_install_android_template() { - const String templates_dir = EditorPaths::get_singleton()->get_export_templates_dir().plus_file(VERSION_FULL_CONFIG); - return FileAccess::exists(templates_dir.plus_file("android_source.zip")); + const String templates_dir = EditorPaths::get_singleton()->get_export_templates_dir().path_join(VERSION_FULL_CONFIG); + return FileAccess::exists(templates_dir.path_join("android_source.zip")); } Error ExportTemplateManager::install_android_template() { - const String &templates_path = EditorPaths::get_singleton()->get_export_templates_dir().plus_file(VERSION_FULL_CONFIG); - const String &source_zip = templates_path.plus_file("android_source.zip"); + const String &templates_path = EditorPaths::get_singleton()->get_export_templates_dir().path_join(VERSION_FULL_CONFIG); + const String &source_zip = templates_path.path_join("android_source.zip"); ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN); return install_android_template_from_file(source_zip); } @@ -723,11 +723,11 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_ unzCloseCurrentFile(pkg); if (!dirs_tested.has(base_dir)) { - da->make_dir_recursive(String("android/build").plus_file(base_dir)); + da->make_dir_recursive(String("android/build").path_join(base_dir)); dirs_tested.insert(base_dir); } - String to_write = String("res://android/build").plus_file(path); + String to_write = String("res://android/build").path_join(path); Ref<FileAccess> f = FileAccess::open(to_write, FileAccess::WRITE); if (f.is_valid()) { f->store_buffer(data.ptr(), data.size()); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index a42433caee..19788e70da 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -146,7 +146,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory file_item->set_text(0, fi.name); file_item->set_structured_text_bidi_override(0, TextServer::STRUCTURED_TEXT_FILE); file_item->set_icon(0, _get_tree_item_icon(!fi.import_broken, fi.type)); - String file_metadata = lpath.plus_file(fi.name); + String file_metadata = lpath.path_join(fi.name); file_item->set_metadata(0, file_metadata); if (!p_select_in_favorites && path == file_metadata) { file_item->select(0); @@ -276,7 +276,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo ti->set_text(0, text); ti->set_icon(0, icon); ti->set_icon_modulate(0, color); - ti->set_tooltip(0, fave); + ti->set_tooltip_text(0, fave); ti->set_selectable(0, true); ti->set_metadata(0, fave); if (p_select_in_favorites && fave == path) { @@ -867,7 +867,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { String dname = efd->get_subdir(i)->get_name(); files->add_item(dname, folder_icon, true); - files->set_item_metadata(-1, directory.plus_file(dname) + "/"); + files->set_item_metadata(-1, directory.path_join(dname) + "/"); files->set_item_icon_modulate(-1, folder_color); if (cselection.has(dname)) { @@ -880,7 +880,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { for (int i = 0; i < efd->get_file_count(); i++) { FileInfo fi; fi.name = efd->get_file(i); - fi.path = directory.plus_file(fi.name); + fi.path = directory.path_join(fi.name); fi.type = efd->get_file_type(i); fi.import_broken = !efd->get_file_import_is_valid(i); fi.modified_time = efd->get_file_modified_time(i); @@ -1545,7 +1545,7 @@ void FileSystemDock::_rename_operation_confirm() { } String old_path = to_rename.path.ends_with("/") ? to_rename.path.substr(0, to_rename.path.length() - 1) : to_rename.path; - String new_path = old_path.get_base_dir().plus_file(new_name); + String new_path = old_path.get_base_dir().path_join(new_name); if (old_path == new_path) { return; } @@ -1605,7 +1605,7 @@ void FileSystemDock::_duplicate_operation_confirm() { base_dir = base_dir.get_base_dir(); } - String new_path = base_dir.plus_file(new_name); + String new_path = base_dir.path_join(new_name); // Present a more user friendly warning for name conflict Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES); @@ -1630,7 +1630,7 @@ Vector<String> FileSystemDock::_check_existing() { String &p_to_path = to_move_path; for (int i = 0; i < to_move.size(); i++) { String ol_pth = to_move[i].path.ends_with("/") ? to_move[i].path.substr(0, to_move[i].path.length() - 1) : to_move[i].path; - String p_new_path = p_to_path.plus_file(ol_pth.get_file()); + String p_new_path = p_to_path.path_join(ol_pth.get_file()); FileOrFolder p_item = to_move[i]; String old_path = (p_item.is_file || p_item.path.ends_with("/")) ? p_item.path : (p_item.path + "/"); @@ -1662,7 +1662,7 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_ove // Check groups. for (int i = 0; i < to_move.size(); i++) { if (to_move[i].is_file && EditorFileSystem::get_singleton()->is_group_file(to_move[i].path)) { - EditorFileSystem::get_singleton()->move_group_file(to_move[i].path, p_to_path.plus_file(to_move[i].path.get_file())); + EditorFileSystem::get_singleton()->move_group_file(to_move[i].path, p_to_path.path_join(to_move[i].path.get_file())); } } @@ -1671,7 +1671,7 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_ove bool is_moved = false; for (int i = 0; i < to_move.size(); i++) { String old_path = to_move[i].path.ends_with("/") ? to_move[i].path.substr(0, to_move[i].path.length() - 1) : to_move[i].path; - String new_path = p_to_path.plus_file(old_path.get_file()); + String new_path = p_to_path.path_join(old_path.get_file()); if (old_path != new_path) { _try_move_item(to_move[i], new_path, file_renames, folder_renames); is_moved = true; @@ -2005,7 +2005,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected if (!fpath.ends_with("/")) { fpath = fpath.get_base_dir(); } - make_script_dialog->config("Node", fpath.plus_file("new_script.gd"), false, false); + make_script_dialog->config("Node", fpath.path_join("new_script.gd"), false, false); make_script_dialog->popup_centered(); } break; @@ -2047,15 +2047,15 @@ void FileSystemDock::_resource_created() { String type_name = new_resource_dialog->get_selected_type(); if (type_name == "Shader") { - make_shader_dialog->config(fpath.plus_file("new_shader"), false, false, 0); + make_shader_dialog->config(fpath.path_join("new_shader"), false, false, 0); make_shader_dialog->popup_centered(); return; } else if (type_name == "VisualShader") { - make_shader_dialog->config(fpath.plus_file("new_shader"), false, false, 1); + make_shader_dialog->config(fpath.path_join("new_shader"), false, false, 1); make_shader_dialog->popup_centered(); return; } else if (type_name == "ShaderInclude") { - make_shader_dialog->config(fpath.plus_file("new_shader_include"), false, false, 2); + make_shader_dialog->config(fpath.path_join("new_shader_include"), false, false, 2); make_shader_dialog->popup_centered(); return; } @@ -2370,11 +2370,11 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, String new_path_base; if (to_move[i].is_file) { - new_path = to_dir.plus_file(to_move[i].path.get_file()); + new_path = to_dir.path_join(to_move[i].path.get_file()); new_path_base = new_path.get_basename() + " (%d)." + new_path.get_extension(); } else { PackedStringArray path_split = to_move[i].path.split("/"); - new_path = to_dir.plus_file(path_split[path_split.size() - 2]); + new_path = to_dir.path_join(path_split[path_split.size() - 2]); new_path_base = new_path + " (%d)"; } diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 56387e87f5..16c5003fdc 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -168,7 +168,7 @@ void FindInFiles::_iterate() { String folder_name = folders_to_scan[folders_to_scan.size() - 1]; pop_back(folders_to_scan); - _current_dir = _current_dir.plus_file(folder_name); + _current_dir = _current_dir.path_join(folder_name); PackedStringArray sub_dirs; _scan_dir("res://" + _current_dir, sub_dirs); @@ -246,7 +246,7 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) { } else { String file_ext = file.get_extension(); if (_extension_filter.has(file_ext)) { - _files_to_scan.push_back(path.plus_file(file)); + _files_to_scan.push_back(path.path_join(file)); } } } diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 15add50fd4..dac86acae4 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -89,7 +89,7 @@ void GroupDialog::_load_nodes(Node *p_current) { if (keep) { node->set_text(0, item_name); node->set_metadata(0, path); - node->set_tooltip(0, path); + node->set_tooltip_text(0, path); Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(p_current, "Node"); node->set_icon(0, icon); diff --git a/editor/import/audio_stream_import_settings.cpp b/editor/import/audio_stream_import_settings.cpp index cc7c5809d6..e3da82a5cb 100644 --- a/editor/import/audio_stream_import_settings.cpp +++ b/editor/import/audio_stream_import_settings.cpp @@ -57,13 +57,13 @@ void AudioStreamImportSettings::_notification(int p_what) { zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); - _indicator->update(); - _preview->update(); + _indicator->queue_redraw(); + _preview->queue_redraw(); } break; case NOTIFICATION_PROCESS: { _current = _player->get_playback_position(); - _indicator->update(); + _indicator->queue_redraw(); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -167,7 +167,7 @@ void AudioStreamImportSettings::_draw_preview() { void AudioStreamImportSettings::_preview_changed(ObjectID p_which) { if (stream.is_valid() && stream->get_instance_id() == p_which) { - _preview->update(); + _preview->queue_redraw(); } } @@ -179,8 +179,8 @@ void AudioStreamImportSettings::_preview_zoom_in() { zoom_bar->set_page(page_size * 0.5); zoom_bar->set_value(zoom_bar->get_value() + page_size * 0.25); - _preview->update(); - _indicator->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); } void AudioStreamImportSettings::_preview_zoom_out() { @@ -191,8 +191,8 @@ void AudioStreamImportSettings::_preview_zoom_out() { zoom_bar->set_page(MIN(zoom_bar->get_max(), page_size * 2.0)); zoom_bar->set_value(zoom_bar->get_value() - page_size * 0.5); - _preview->update(); - _indicator->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); } void AudioStreamImportSettings::_preview_zoom_reset() { @@ -202,22 +202,22 @@ void AudioStreamImportSettings::_preview_zoom_reset() { zoom_bar->set_max(stream->get_length()); zoom_bar->set_page(zoom_bar->get_max()); zoom_bar->set_value(0); - _preview->update(); - _indicator->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); } void AudioStreamImportSettings::_preview_zoom_offset_changed(double) { - _preview->update(); - _indicator->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); } void AudioStreamImportSettings::_audio_changed() { if (!is_visible()) { return; } - _preview->update(); - _indicator->update(); - color_rect->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); + color_rect->queue_redraw(); } void AudioStreamImportSettings::_play() { @@ -238,7 +238,7 @@ void AudioStreamImportSettings::_stop() { _player->stop(); _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); _current = 0; - _indicator->update(); + _indicator->queue_redraw(); set_process(false); } @@ -246,7 +246,7 @@ void AudioStreamImportSettings::_on_finished() { _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); if (!_pausing) { _current = 0; - _indicator->update(); + _indicator->queue_redraw(); } else { _pausing = false; } @@ -310,7 +310,7 @@ void AudioStreamImportSettings::_draw_indicator() { void AudioStreamImportSettings::_on_indicator_mouse_exited() { _hovering_beat = -1; - _indicator->update(); + _indicator->queue_redraw(); } void AudioStreamImportSettings::_on_input_indicator(Ref<InputEvent> p_event) { @@ -353,11 +353,11 @@ void AudioStreamImportSettings::_on_input_indicator(Ref<InputEvent> p_event) { int new_hovering_beat = _get_beat_at_pos(mm->get_position().x); if (new_hovering_beat != _hovering_beat) { _hovering_beat = new_hovering_beat; - _indicator->update(); + _indicator->queue_redraw(); } } else if (_hovering_beat != -1) { _hovering_beat = -1; - _indicator->update(); + _indicator->queue_redraw(); } } } @@ -391,7 +391,7 @@ void AudioStreamImportSettings::_seek_to(real_t p_x) { _current = zoom_bar->get_value() + p_x / _preview->get_rect().size.x * zoom_bar->get_page(); _current = CLAMP(_current, 0, stream->get_length()); _player->seek(_current); - _indicator->update(); + _indicator->queue_redraw(); } void AudioStreamImportSettings::edit(const String &p_path, const String &p_importer, const Ref<AudioStream> &p_stream) { @@ -410,9 +410,9 @@ void AudioStreamImportSettings::edit(const String &p_path, const String &p_impor if (!stream.is_null()) { stream->connect("changed", callable_mp(this, &AudioStreamImportSettings::_audio_changed)); - _preview->update(); - _indicator->update(); - color_rect->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); + color_rect->queue_redraw(); } else { hide(); } @@ -500,9 +500,9 @@ void AudioStreamImportSettings::_settings_changed() { updating_settings = false; - _preview->update(); - _indicator->update(); - color_rect->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); + color_rect->queue_redraw(); } void AudioStreamImportSettings::_reimport() { diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index 5b9ed2c1d2..5d8e453395 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -289,7 +289,7 @@ void Collada::_parse_image(XMLParser &parser) { String path = parser.get_attribute_value("source").strip_edges(); if (!path.contains("://") && path.is_relative_path()) { // path is relative to file being loaded, so convert to a resource path - image.path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().plus_file(path.uri_decode())); + image.path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().path_join(path.uri_decode())); } } else { while (parser.read() == OK) { @@ -302,7 +302,7 @@ void Collada::_parse_image(XMLParser &parser) { if (!path.contains("://") && path.is_relative_path()) { // path is relative to file being loaded, so convert to a resource path - path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().plus_file(path)); + path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().path_join(path)); } else if (path.find("file:///") == 0) { path = path.replace_first("file:///", ""); diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index 0575f3cbf3..405d8d2169 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -474,7 +474,7 @@ void DynamicFontImportSettings::_main_prop_changed(const String &p_edited_proper font_preview_label->add_theme_font_override("font", font_preview); font_preview_label->add_theme_font_size_override("font_size", 200 * EDSCALE); - font_preview_label->update(); + font_preview_label->queue_redraw(); } /*************************************************************************/ @@ -1096,7 +1096,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { } font_preview_label->add_theme_font_override("font", font_preview); font_preview_label->add_theme_font_size_override("font_size", 200 * EDSCALE); - font_preview_label->update(); + font_preview_label->queue_redraw(); _variations_validate(); diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index d1c4e1f8dd..fe70fd58b5 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -129,7 +129,7 @@ static Error _parse_material_library(const String &p_path, HashMap<String, Ref<S if (p.is_absolute_path()) { path = p; } else { - path = base_path.plus_file(p); + path = base_path.path_join(p); } Ref<Texture2D> texture = ResourceLoader::load(path); @@ -149,7 +149,7 @@ static Error _parse_material_library(const String &p_path, HashMap<String, Ref<S if (p.is_absolute_path()) { path = p; } else { - path = base_path.plus_file(p); + path = base_path.path_join(p); } Ref<Texture2D> texture = ResourceLoader::load(path); @@ -169,7 +169,7 @@ static Error _parse_material_library(const String &p_path, HashMap<String, Ref<S if (p.is_absolute_path()) { path = p; } else { - path = base_path.plus_file(p); + path = base_path.path_join(p); } Ref<Texture2D> texture = ResourceLoader::load(path); @@ -184,7 +184,7 @@ static Error _parse_material_library(const String &p_path, HashMap<String, Ref<S ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT); String p = l.replace("map_bump", "").replace("\\", "/").strip_edges(); - String path = base_path.plus_file(p); + String path = base_path.path_join(p); Ref<Texture2D> texture = ResourceLoader::load(path); @@ -405,7 +405,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ HashMap<String, Ref<StandardMaterial3D>> lib; String lib_path = current_material_library; if (lib_path.is_relative_path()) { - lib_path = p_path.get_base_dir().plus_file(current_material_library); + lib_path = p_path.get_base_dir().path_join(current_material_library); } Error err = _parse_material_library(lib_path, lib, r_missing_deps); if (err == OK) { diff --git a/editor/import/resource_importer_shader_file.cpp b/editor/import/resource_importer_shader_file.cpp index d3079141e0..55afd71c76 100644 --- a/editor/import/resource_importer_shader_file.cpp +++ b/editor/import/resource_importer_shader_file.cpp @@ -79,7 +79,7 @@ static String _include_function(const String &p_path, void *userpointer) { String include = p_path; if (include.is_relative_path()) { - include = base_path->plus_file(include); + include = base_path->path_join(include); } Ref<FileAccess> file_inc = FileAccess::open(include, FileAccess::READ, &err); diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index 6c12464b5a..1ff771bcce 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -176,7 +176,7 @@ void SceneImportSettings::_fill_material(Tree *p_tree, const Ref<Material> &p_ma item->set_meta("type", "Material"); item->set_meta("import_id", import_id); - item->set_tooltip(0, vformat(TTR("Import ID: %s"), import_id)); + item->set_tooltip_text(0, vformat(TTR("Import ID: %s"), import_id)); item->set_selectable(0, true); if (p_tree == scene_tree) { @@ -232,7 +232,7 @@ void SceneImportSettings::_fill_mesh(Tree *p_tree, const Ref<Mesh> &p_mesh, Tree item->set_meta("type", "Mesh"); item->set_meta("import_id", import_id); - item->set_tooltip(0, vformat(TTR("Import ID: %s"), import_id)); + item->set_tooltip_text(0, vformat(TTR("Import ID: %s"), import_id)); item->set_selectable(0, true); @@ -331,7 +331,7 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) { item->set_meta("type", "Node"); item->set_meta("class", type); item->set_meta("import_id", import_id); - item->set_tooltip(0, vformat(TTR("Type: %s\nImport ID: %s"), type, import_id)); + item->set_tooltip_text(0, vformat(TTR("Type: %s\nImport ID: %s"), type, import_id)); item->set_selectable(0, true); @@ -979,7 +979,7 @@ void SceneImportSettings::_save_path_changed(const String &p_path) { if (FileAccess::exists(p_path)) { save_path_item->set_text(2, "Warning: File exists"); - save_path_item->set_tooltip(2, TTR("Existing file with the same name will be replaced.")); + save_path_item->set_tooltip_text(2, TTR("Existing file with the same name will be replaced.")); save_path_item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { @@ -1024,12 +1024,12 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (md.has_import_id) { if (md.settings.has("use_external/enabled") && bool(md.settings["use_external/enabled"])) { item->set_text(2, "Already External"); - item->set_tooltip(2, TTR("This material already references an external file, no action will be taken.\nDisable the external property for it to be extracted again.")); + item->set_tooltip_text(2, TTR("This material already references an external file, no action will be taken.\nDisable the external property for it to be extracted again.")); } else { item->set_metadata(0, E.key); item->set_editable(0, true); item->set_checked(0, true); - String path = p_path.plus_file(name); + String path = p_path.path_join(name); if (external_extension_type->get_selected() == 0) { path += ".tres"; } else { @@ -1039,7 +1039,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { item->set_text(1, path); if (FileAccess::exists(path)) { item->set_text(2, "Warning: File exists"); - item->set_tooltip(2, TTR("Existing file with the same name will be replaced.")); + item->set_tooltip_text(2, TTR("Existing file with the same name will be replaced.")); item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { @@ -1052,7 +1052,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { } else { item->set_text(2, "No import ID"); - item->set_tooltip(2, TTR("Material has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); + item->set_tooltip_text(2, TTR("Material has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); item->set_icon(2, get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); } @@ -1077,12 +1077,12 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (md.has_import_id) { if (md.settings.has("save_to_file/enabled") && bool(md.settings["save_to_file/enabled"])) { item->set_text(2, "Already Saving"); - item->set_tooltip(2, TTR("This mesh already saves to an external resource, no action will be taken.")); + item->set_tooltip_text(2, TTR("This mesh already saves to an external resource, no action will be taken.")); } else { item->set_metadata(0, E.key); item->set_editable(0, true); item->set_checked(0, true); - String path = p_path.plus_file(name); + String path = p_path.path_join(name); if (external_extension_type->get_selected() == 0) { path += ".tres"; } else { @@ -1092,7 +1092,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { item->set_text(1, path); if (FileAccess::exists(path)) { item->set_text(2, "Warning: File exists"); - item->set_tooltip(2, TTR("Existing file with the same name will be replaced on import.")); + item->set_tooltip_text(2, TTR("Existing file with the same name will be replaced on import.")); item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { @@ -1105,7 +1105,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { } else { item->set_text(2, "No import ID"); - item->set_tooltip(2, TTR("Mesh has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); + item->set_tooltip_text(2, TTR("Mesh has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); item->set_icon(2, get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); } @@ -1129,12 +1129,12 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (ad.settings.has("save_to_file/enabled") && bool(ad.settings["save_to_file/enabled"])) { item->set_text(2, "Already Saving"); - item->set_tooltip(2, TTR("This animation already saves to an external resource, no action will be taken.")); + item->set_tooltip_text(2, TTR("This animation already saves to an external resource, no action will be taken.")); } else { item->set_metadata(0, E.key); item->set_editable(0, true); item->set_checked(0, true); - String path = p_path.plus_file(name); + String path = p_path.path_join(name); if (external_extension_type->get_selected() == 0) { path += ".tres"; } else { @@ -1144,7 +1144,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { item->set_text(1, path); if (FileAccess::exists(path)) { item->set_text(2, "Warning: File exists"); - item->set_tooltip(2, TTR("Existing file with the same name will be replaced on import.")); + item->set_tooltip_text(2, TTR("Existing file with the same name will be replaced on import.")); item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index 77a1700ebf..683481ecc1 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -193,7 +193,7 @@ void LocalizationEditor::_translation_res_option_popup(bool p_arrow_clicked) { TreeItem *ed = translation_remap_options->get_edited(); ERR_FAIL_COND(!ed); - locale_select->set_locale(ed->get_tooltip(1)); + locale_select->set_locale(ed->get_tooltip_text(1)); locale_select->popup_locale_dialog(); } @@ -202,7 +202,7 @@ void LocalizationEditor::_translation_res_option_selected(const String &p_locale ERR_FAIL_COND(!ed); ed->set_text(1, TranslationServer::get_singleton()->get_locale_name(p_locale)); - ed->set_tooltip(1, p_locale); + ed->set_tooltip_text(1, p_locale); LocalizationEditor::_translation_res_option_changed(); } @@ -226,7 +226,7 @@ void LocalizationEditor::_translation_res_option_changed() { String key = k->get_metadata(0); int idx = ed->get_metadata(0); String path = ed->get_metadata(1); - String locale = ed->get_tooltip(1); + String locale = ed->get_tooltip_text(1); ERR_FAIL_COND(!remaps.has(key)); PackedStringArray r = remaps[key]; @@ -486,7 +486,7 @@ void LocalizationEditor::update_translations() { TreeItem *t = translation_list->create_item(root); t->set_editable(0, false); t->set_text(0, translations[i].replace_first("res://", "")); - t->set_tooltip(0, translations[i]); + t->set_tooltip_text(0, translations[i]); t->set_metadata(0, i); t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); } @@ -520,14 +520,14 @@ void LocalizationEditor::update_translations() { TreeItem *t = translation_remap->create_item(root); t->set_editable(0, false); t->set_text(0, keys[i].replace_first("res://", "")); - t->set_tooltip(0, keys[i]); + t->set_tooltip_text(0, keys[i]); t->set_metadata(0, keys[i]); t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); // Display that it has been removed if this is the case. if (!FileAccess::exists(keys[i])) { t->set_text(0, t->get_text(0) + vformat(" (%s)", TTR("Removed"))); - t->set_tooltip(0, vformat(TTR("%s cannot be found."), t->get_tooltip(0))); + t->set_tooltip_text(0, vformat(TTR("%s cannot be found."), t->get_tooltip_text(0))); } if (keys[i] == remap_selected) { @@ -544,19 +544,19 @@ void LocalizationEditor::update_translations() { TreeItem *t2 = translation_remap_options->create_item(root2); t2->set_editable(0, false); t2->set_text(0, path.replace_first("res://", "")); - t2->set_tooltip(0, path); + t2->set_tooltip_text(0, path); t2->set_metadata(0, j); t2->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); t2->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); t2->set_text(1, TranslationServer::get_singleton()->get_locale_name(locale)); t2->set_editable(1, true); t2->set_metadata(1, path); - t2->set_tooltip(1, locale); + t2->set_tooltip_text(1, locale); // Display that it has been removed if this is the case. if (!FileAccess::exists(path)) { t2->set_text(0, t2->get_text(0) + vformat(" (%s)", TTR("Removed"))); - t2->set_tooltip(0, vformat(TTR("%s cannot be found."), t2->get_tooltip(0))); + t2->set_tooltip_text(0, vformat(TTR("%s cannot be found."), t2->get_tooltip_text(0))); } } } @@ -573,7 +573,7 @@ void LocalizationEditor::update_translations() { TreeItem *t = translation_pot_list->create_item(root); t->set_editable(0, false); t->set_text(0, pot_translations[i].replace_first("res://", "")); - t->set_tooltip(0, pot_translations[i]); + t->set_tooltip_text(0, pot_translations[i]); t->set_metadata(0, i); t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); } diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 88aa6354e4..71ff77e9bc 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -62,7 +62,7 @@ void PluginConfigDialog::_on_confirmed() { if (script_name.get_extension().is_empty()) { script_name += "." + ext; } - String script_path = path.plus_file(script_name); + String script_path = path.path_join(script_name); Ref<ConfigFile> cf = memnew(ConfigFile); cf->set_value("plugin", "name", name_edit->get_text()); @@ -71,7 +71,7 @@ void PluginConfigDialog::_on_confirmed() { cf->set_value("plugin", "version", version_edit->get_text()); cf->set_value("plugin", "script", script_name); - cf->save(path.plus_file("plugin.cfg")); + cf->save(path.path_join("plugin.cfg")); if (!_edit_mode) { String class_name = script_name.get_basename(); diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index 3b7829c37b..b79f4c90bf 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -120,7 +120,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven } if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { - blend_space_draw->update(); // why not + blend_space_draw->queue_redraw(); // why not // try to see if a point can be selected selected_point = -1; @@ -167,7 +167,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven dragging_selected_attempt = false; dragging_selected = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } } @@ -178,20 +178,20 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven blend_pos += blend_space->get_min_space(); AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid() && !blend_space_draw->has_focus()) { blend_space_draw->grab_focus(); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } if (mm.is_valid() && dragging_selected_attempt) { dragging_selected = true; drag_ofs = ((mm->get_position() - drag_from) / blend_space_draw->get_size()) * ((blend_space->get_max_space() - blend_space->get_min_space()) * Vector2(1, 0)); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); _update_edited_point_pos(); } @@ -202,7 +202,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } } @@ -330,7 +330,7 @@ void AnimationNodeBlendSpace1DEditor::_update_space() { snap_value->set_value(blend_space->get_snap()); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); updating = false; } @@ -355,7 +355,7 @@ void AnimationNodeBlendSpace1DEditor::_config_changed(double) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace1DEditor::_labels_changed(String) { @@ -374,7 +374,7 @@ void AnimationNodeBlendSpace1DEditor::_labels_changed(String) { } void AnimationNodeBlendSpace1DEditor::_snap_toggled() { - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace1DEditor::_file_opened(const String &p_file) { @@ -425,7 +425,7 @@ void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace1DEditor::_add_animation_type(int p_index) { @@ -443,7 +443,7 @@ void AnimationNodeBlendSpace1DEditor::_add_animation_type(int p_index) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace1DEditor::_tool_switch(int p_tool) { @@ -456,7 +456,7 @@ void AnimationNodeBlendSpace1DEditor::_tool_switch(int p_tool) { } _update_tool_erase(); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace1DEditor::_update_edited_point_pos() { @@ -517,7 +517,7 @@ void AnimationNodeBlendSpace1DEditor::_erase_selected() { updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } } @@ -537,7 +537,7 @@ void AnimationNodeBlendSpace1DEditor::_edit_point_pos(double) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace1DEditor::_open_editor() { diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index d904ccb5e0..1646a1cef4 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -52,7 +52,7 @@ bool AnimationNodeBlendSpace2DEditor::can_edit(const Ref<AnimationNode> &p_node) } void AnimationNodeBlendSpace2DEditor::_blend_space_changed() { - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::edit(const Ref<AnimationNode> &p_node) { @@ -161,7 +161,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { - blend_space_draw->update(); //update anyway + blend_space_draw->queue_redraw(); //update anyway //try to see if a point can be selected selected_point = -1; selected_triangle = -1; @@ -201,7 +201,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } if (mb.is_valid() && mb->is_pressed() && tool_triangle->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { - blend_space_draw->update(); //update anyway + blend_space_draw->queue_redraw(); //update anyway //try to see if a point can be selected selected_point = -1; @@ -260,7 +260,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } dragging_selected_attempt = false; dragging_selected = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } if (mb.is_valid() && mb->is_pressed() && tool_blend->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { @@ -271,14 +271,14 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid() && !blend_space_draw->has_focus()) { blend_space_draw->grab_focus(); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } if (mm.is_valid() && dragging_selected_attempt) { @@ -286,17 +286,17 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven if (!read_only) { drag_ofs = ((mm->get_position() - drag_from) / blend_space_draw->get_size()) * (blend_space->get_max_space() - blend_space->get_min_space()) * Vector2(1, -1); } - blend_space_draw->update(); + blend_space_draw->queue_redraw(); _update_edited_point_pos(); } if (mm.is_valid() && tool_triangle->is_pressed() && making_triangle.size()) { - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } if (mm.is_valid() && !tool_triangle->is_pressed() && making_triangle.size()) { making_triangle.clear(); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } if (mm.is_valid() && tool_blend->is_pressed() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { @@ -307,7 +307,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } } @@ -359,7 +359,7 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::_add_animation_type(int p_index) { @@ -377,7 +377,7 @@ void AnimationNodeBlendSpace2DEditor::_add_animation_type(int p_index) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::_update_tool_erase() { @@ -424,7 +424,7 @@ void AnimationNodeBlendSpace2DEditor::_tool_switch(int p_tool) { tool_erase_sep->hide(); } _update_tool_erase(); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { @@ -614,7 +614,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { } void AnimationNodeBlendSpace2DEditor::_snap_toggled() { - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::_update_space() { @@ -647,7 +647,7 @@ void AnimationNodeBlendSpace2DEditor::_update_space() { snap_x->set_value(blend_space->get_snap().x); snap_y->set_value(blend_space->get_snap().y); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); updating = false; } @@ -674,7 +674,7 @@ void AnimationNodeBlendSpace2DEditor::_config_changed(double) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::_labels_changed(String) { @@ -716,7 +716,7 @@ void AnimationNodeBlendSpace2DEditor::_erase_selected() { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } else if (selected_triangle != -1) { updating = true; undo_redo->create_action(TTR("Remove BlendSpace2D Triangle")); @@ -728,7 +728,7 @@ void AnimationNodeBlendSpace2DEditor::_erase_selected() { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } } @@ -767,7 +767,7 @@ void AnimationNodeBlendSpace2DEditor::_edit_point_pos(double) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { diff --git a/editor/plugins/animation_library_editor.cpp b/editor/plugins/animation_library_editor.cpp index f9e5aa799a..50ba1a71c0 100644 --- a/editor/plugins/animation_library_editor.cpp +++ b/editor/plugins/animation_library_editor.cpp @@ -635,7 +635,7 @@ void AnimationLibraryEditor::update_tree() { String al_path = al->get_path(); if (!al_path.is_resource_file()) { libitem->set_text(1, TTR("[built-in]")); - libitem->set_tooltip(1, al_path); + libitem->set_tooltip_text(1, al_path); int srpos = al_path.find("::"); if (srpos != -1) { String base = al_path.substr(0, srpos); @@ -687,7 +687,7 @@ void AnimationLibraryEditor::update_tree() { String anim_path = anim->get_path(); if (!anim_path.is_resource_file()) { anitem->set_text(1, TTR("[built-in]")); - anitem->set_tooltip(1, anim_path); + anitem->set_tooltip_text(1, anim_path); int srpos = anim_path.find("::"); if (srpos != -1) { String base = anim_path.substr(0, srpos); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index be1e531cb8..cded53e054 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -128,7 +128,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv //travel playback->travel(node_rects[i].node_name); } - state_machine_draw->update(); + state_machine_draw->queue_redraw(); return; } @@ -168,7 +168,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv Ref<AnimationNode> anode = state_machine->get_node(selected_node); EditorNode::get_singleton()->push_item(anode.ptr(), "", true); - state_machine_draw->update(); + state_machine_draw->queue_redraw(); dragging_selected_attempt = true; dragging_selected = false; drag_from = mb->get_position(); @@ -228,7 +228,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } } - state_machine_draw->update(); + state_machine_draw->queue_redraw(); _update_mode(); } @@ -259,7 +259,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv dragging_selected_attempt = false; dragging_selected = false; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } // Connect nodes @@ -296,7 +296,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv _open_menu(mb->get_position()); } connecting_to_node = StringName(); - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } // Start box selecting @@ -319,7 +319,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv // End box selecting if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT && !mb->is_pressed() && box_selecting) { box_selecting = false; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); _update_mode(); } @@ -335,7 +335,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv if (mm.is_valid() && connecting && !read_only) { connecting_to = mm->get_position(); connecting_to_node = StringName(); - state_machine_draw->update(); + state_machine_draw->queue_redraw(); for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order if (node_rects[i].node_name != connecting_from && node_rects[i].node.has_point(connecting_to)) { //select node since nothing else was selected @@ -382,7 +382,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } } - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } // Move mouse while moving box select @@ -412,7 +412,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } } - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } if (mm.is_valid()) { @@ -442,7 +442,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv if (new_over_node != over_node || new_over_node_what != over_node_what) { over_node = new_over_node; over_node_what = new_over_node_what; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } // set tooltip for transition @@ -620,7 +620,7 @@ void AnimationNodeStateMachineEditor::_group_selected_nodes() { selected_nodes.clear(); selected_nodes.insert(group_name); - state_machine_draw->update(); + state_machine_draw->queue_redraw(); accept_event(); _update_mode(); } @@ -721,7 +721,7 @@ void AnimationNodeStateMachineEditor::_ungroup_selected_nodes() { if (find) { selected_nodes = new_selected_nodes; selected_node = StringName(); - state_machine_draw->update(); + state_machine_draw->queue_redraw(); accept_event(); _update_mode(); } @@ -909,7 +909,7 @@ bool AnimationNodeStateMachineEditor::_create_submenu(PopupMenu *p_menu, Ref<Ani void AnimationNodeStateMachineEditor::_stop_connecting() { connecting = false; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } void AnimationNodeStateMachineEditor::_delete_selected() { @@ -1028,7 +1028,7 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { undo_redo->commit_action(); updating = false; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) { @@ -1056,7 +1056,7 @@ void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) { undo_redo->commit_action(); updating = false; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } void AnimationNodeStateMachineEditor::_connect_to(int p_index) { @@ -1475,7 +1475,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { v_scroll->set_value(state_machine->get_graph_offset().y); updating = false; - state_machine_play_pos->update(); + state_machine_play_pos->queue_redraw(); } void AnimationNodeStateMachineEditor::_state_machine_pos_draw() { @@ -1537,7 +1537,7 @@ void AnimationNodeStateMachineEditor::_update_graph() { updating = true; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); updating = false; } @@ -1609,34 +1609,34 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { } if (tidx == -1) { //missing transition, should redraw - state_machine_draw->update(); + state_machine_draw->queue_redraw(); break; } if (transition_lines[i].disabled != state_machine->get_transition(tidx)->is_disabled()) { - state_machine_draw->update(); + state_machine_draw->queue_redraw(); break; } if (transition_lines[i].auto_advance != state_machine->get_transition(tidx)->has_auto_advance()) { - state_machine_draw->update(); + state_machine_draw->queue_redraw(); break; } if (transition_lines[i].advance_condition_name != state_machine->get_transition(tidx)->get_advance_condition_name()) { - state_machine_draw->update(); + state_machine_draw->queue_redraw(); break; } if (transition_lines[i].mode != state_machine->get_transition(tidx)->get_switch_mode()) { - state_machine_draw->update(); + state_machine_draw->queue_redraw(); break; } bool acstate = transition_lines[i].advance_condition_name != StringName() && bool(AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + String(transition_lines[i].advance_condition_name))); if (transition_lines[i].advance_condition_state != acstate) { - state_machine_draw->update(); + state_machine_draw->queue_redraw(); break; } } @@ -1671,14 +1671,14 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { } } - //update if travel state changed + //redraw if travel state changed if (!same_travel_path || last_active != is_playing || last_current_node != current_node || last_blend_from_node != blend_from_node) { - state_machine_draw->update(); + state_machine_draw->queue_redraw(); last_travel_path = tp; last_current_node = current_node; last_active = is_playing; last_blend_from_node = blend_from_node; - state_machine_play_pos->update(); + state_machine_play_pos->queue_redraw(); } { @@ -1703,7 +1703,7 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { if (last_play_pos != play_pos) { last_play_pos = play_pos; - state_machine_play_pos->update(); + state_machine_play_pos->queue_redraw(); } } break; @@ -1749,7 +1749,7 @@ void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) { name_edit_popup->hide(); updating = false; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } void AnimationNodeStateMachineEditor::_name_edited_focus_out() { @@ -1766,7 +1766,7 @@ void AnimationNodeStateMachineEditor::_scroll_changed(double) { } state_machine->set_graph_offset(Vector2(h_scroll->get_value(), v_scroll->get_value())); - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } void AnimationNodeStateMachineEditor::_erase_selected(const bool p_nested_action) { @@ -1857,7 +1857,7 @@ void AnimationNodeStateMachineEditor::_erase_selected(const bool p_nested_action selected_multi_transition = TransitionLine(); } - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } void AnimationNodeStateMachineEditor::_update_mode() { diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index bce4c9de8e..ed231c446b 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -59,10 +59,11 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) { Vector<String> path; if (tree && tree->has_meta("_tree_edit_path")) { path = tree->get_meta("_tree_edit_path"); - edit_path(path); } else { current_root = ObjectID(); } + + edit_path(path); } void AnimationTreeEditor::_path_button_pressed(int p_path) { @@ -129,6 +130,11 @@ void AnimationTreeEditor::edit_path(const Vector<String> &p_path) { } else { current_root = ObjectID(); edited_path = button_path; + + for (int i = 0; i < editors.size(); i++) { + editors[i]->edit(Ref<AnimationNode>()); + editors[i]->hide(); + } } _update_path(); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 025312c38c..41383edafe 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -487,7 +487,7 @@ void EditorAssetLibraryItemDownload::_make_request() { retry_button->hide(); download->cancel_request(); - download->set_download_file(EditorPaths::get_singleton()->get_cache_dir().plus_file("tmp_asset_" + itos(asset_id)) + ".zip"); + download->set_download_file(EditorPaths::get_singleton()->get_cache_dir().path_join("tmp_asset_" + itos(asset_id)) + ".zip"); Error err = download->request(host); if (err != OK) { @@ -730,7 +730,7 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedB PackedByteArray image_data = p_data; if (use_cache) { - String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); + String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().path_join("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); Ref<FileAccess> file = FileAccess::open(cache_filename_base + ".data", FileAccess::READ); if (file.is_valid()) { @@ -804,7 +804,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons if (p_code != HTTPClient::RESPONSE_NOT_MODIFIED) { for (int i = 0; i < headers.size(); i++) { if (headers[i].findn("ETag:") == 0) { // Save etag - String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); + String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().path_join("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); String new_etag = headers[i].substr(headers[i].find(":") + 1, headers[i].length()).strip_edges(); Ref<FileAccess> file = FileAccess::open(cache_filename_base + ".etag", FileAccess::WRITE); if (file.is_valid()) { @@ -846,7 +846,7 @@ void EditorAssetLibrary::_update_image_queue() { List<int> to_delete; for (KeyValue<int, ImageQueue> &E : image_queue) { if (!E.value.active && current_images < max_images) { - String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().plus_file("assetimage_" + E.value.image_url.md5_text()); + String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().path_join("assetimage_" + E.value.image_url.md5_text()); Vector<String> headers; if (FileAccess::exists(cache_filename_base + ".etag") && FileAccess::exists(cache_filename_base + ".data")) { diff --git a/editor/plugins/bone_map_editor_plugin.cpp b/editor/plugins/bone_map_editor_plugin.cpp index c16dca00a3..988f9cc394 100644 --- a/editor/plugins/bone_map_editor_plugin.cpp +++ b/editor/plugins/bone_map_editor_plugin.cpp @@ -609,7 +609,7 @@ int BoneMapper::search_bone_by_name(Skeleton3D *p_skeleton, Vector<String> p_pic } BoneMapper::BoneSegregation BoneMapper::guess_bone_segregation(String p_bone_name) { - String fixed_bn = p_bone_name.camelcase_to_underscore().to_lower(); + String fixed_bn = p_bone_name.to_snake_case(); LocalVector<String> left_words; left_words.push_back("(?<![a-zA-Z])left"); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 37c79d4974..c4a32d6d4b 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -487,21 +487,21 @@ void CanvasItemEditor::shortcut_input(const Ref<InputEvent> &p_ev) { if (k.is_valid()) { if (k->get_keycode() == Key::CTRL || k->get_keycode() == Key::ALT || k->get_keycode() == Key::SHIFT) { - viewport->update(); + viewport->queue_redraw(); } if (k->is_pressed() && !k->is_ctrl_pressed() && !k->is_echo() && (grid_snap_active || _is_grid_visible())) { if (multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->matches_event(p_ev)) { // Multiply the grid size grid_step_multiplier = MIN(grid_step_multiplier + 1, 12); - viewport->update(); + viewport->queue_redraw(); } else if (divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->matches_event(p_ev)) { // Divide the grid size Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1); if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) { grid_step_multiplier--; } - viewport->update(); + viewport->queue_redraw(); } } } @@ -758,7 +758,7 @@ bool CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_po } } } - viewport->update(); + viewport->queue_redraw(); return still_selected; } @@ -875,15 +875,15 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite } } } - undo_redo->add_do_method(viewport, "update"); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_do_method(viewport, "queue_redraw"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } void CanvasItemEditor::_snap_changed() { static_cast<SnapDialog *>(snap_dialog)->get_fields(grid_offset, grid_step, primary_grid_steps, snap_rotation_offset, snap_rotation_step, snap_scale_step); grid_step_multiplier = 0; - viewport->update(); + viewport->queue_redraw(); } void CanvasItemEditor::_selection_result_pressed(int p_result) { @@ -983,7 +983,7 @@ void CanvasItemEditor::_on_grid_menu_id_pressed(int p_id) { case GRID_VISIBILITY_SHOW_WHEN_SNAPPING: case GRID_VISIBILITY_HIDE: grid_visibility = (GridVisibility)p_id; - viewport->update(); + viewport->queue_redraw(); view_menu->get_popup()->hide(); return; } @@ -1010,7 +1010,7 @@ void CanvasItemEditor::_on_grid_menu_id_pressed(int p_id) { break; } } - viewport->update(); + viewport->queue_redraw(); } bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_event) { @@ -1105,7 +1105,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve drag_to = xform.affine_inverse().xform(m->get_position()); dragged_guide_pos = xform.xform(snap_point(drag_to, SNAP_GRID | SNAP_PIXEL | SNAP_OTHER_NODES)); - viewport->update(); + viewport->queue_redraw(); return true; } @@ -1128,14 +1128,14 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve undo_redo->create_action(TTR("Move Vertical Guide")); undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", vguides); undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", prev_vguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } else { vguides.push_back(edited.x); undo_redo->create_action(TTR("Create Vertical Guide")); undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", vguides); undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", prev_vguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } } else { @@ -1148,7 +1148,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", vguides); } undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", prev_vguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } } @@ -1161,14 +1161,14 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve undo_redo->create_action(TTR("Move Horizontal Guide")); undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides); undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", prev_hguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } else { hguides.push_back(edited.y); undo_redo->create_action(TTR("Create Horizontal Guide")); undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides); undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", prev_hguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } } else { @@ -1181,7 +1181,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides); } undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", prev_hguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } } @@ -1197,7 +1197,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides); undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", prev_vguides); undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", prev_hguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } } @@ -1205,7 +1205,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve snap_target[0] = SNAP_TARGET_NONE; snap_target[1] = SNAP_TARGET_NONE; _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -1380,7 +1380,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->get_button_index() == MouseButton::RIGHT && b->is_pressed()) { _restore_canvas_item_state(drag_selection); _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -1430,7 +1430,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { //Rotate the opposite way if the canvas item's compounded scale has an uneven number of negative elements bool opposite = (canvas_item->get_global_transform().get_scale().sign().dot(canvas_item->get_transform().get_scale().sign()) == 0); canvas_item->_edit_set_rotation(snap_angle(canvas_item->_edit_get_rotation() + (opposite ? -1 : 1) * (drag_from - drag_rotation_center).angle_to(drag_to - drag_rotation_center), canvas_item->_edit_get_rotation())); - viewport->update(); + viewport->queue_redraw(); } return true; } @@ -1463,7 +1463,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->get_button_index() == MouseButton::RIGHT && b->is_pressed()) { _restore_canvas_item_state(drag_selection); _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -1625,7 +1625,7 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->get_button_index() == MouseButton::RIGHT && b->is_pressed()) { _restore_canvas_item_state(drag_selection); _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -1824,7 +1824,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { snap_target[0] = SNAP_TARGET_NONE; snap_target[1] = SNAP_TARGET_NONE; _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } @@ -1834,7 +1834,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { snap_target[0] = SNAP_TARGET_NONE; snap_target[1] = SNAP_TARGET_NONE; _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -1963,7 +1963,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { } _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } @@ -1971,7 +1971,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->get_button_index() == MouseButton::RIGHT && b->is_pressed()) { _restore_canvas_item_state(drag_selection); _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -2096,7 +2096,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { snap_target[1] = SNAP_TARGET_NONE; _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } @@ -2106,7 +2106,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { snap_target[0] = SNAP_TARGET_NONE; snap_target[1] = SNAP_TARGET_NONE; _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -2214,7 +2214,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } _reset_drag(); } - viewport->update(); + viewport->queue_redraw(); return true; } @@ -2339,7 +2339,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { if (!b->is_shift_pressed()) { // Clear the selection if not additive editor_selection->clear(); - viewport->update(); + viewport->queue_redraw(); selected_from_canvas = true; }; @@ -2415,21 +2415,21 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { } _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } if (b.is_valid() && b->is_pressed() && b->get_button_index() == MouseButton::RIGHT) { // Cancel box selection _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } if (m.is_valid()) { // Update box selection box_selecting_to = transform.affine_inverse().xform(m->get_position()); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -2437,7 +2437,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { if (k.is_valid() && k->is_pressed() && k->get_keycode() == Key::ESCAPE && drag_type == DRAG_NONE && tool == TOOL_SELECT) { // Unselect everything editor_selection->clear(); - viewport->update(); + viewport->queue_redraw(); } return false; } @@ -2463,12 +2463,12 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) { ruler_tool_active = false; } - viewport->update(); + viewport->queue_redraw(); return true; } if (m.is_valid() && (ruler_tool_active || (grid_snap_active && previous_origin != ruler_tool_origin))) { - viewport->update(); + viewport->queue_redraw(); return true; } @@ -2480,7 +2480,7 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) { if (m.is_valid()) { Point2 click = transform.affine_inverse().xform(m->get_position()); - // Checks if the hovered items changed, update the viewport if so + // Checks if the hovered items changed, redraw the viewport if so Vector<_SelectResult> hovering_results_items; _get_canvas_items_at_pos(click, hovering_results_items); hovering_results_items.sort(); @@ -2502,7 +2502,7 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) { hovering_results_tmp.push_back(hover_result); } - // Check if changed, if so, update. + // Check if changed, if so, redraw. bool changed = false; if (hovering_results_tmp.size() == hovering_results.size()) { for (int i = 0; i < hovering_results_tmp.size(); i++) { @@ -2519,7 +2519,7 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) { if (changed) { hovering_results = hovering_results_tmp; - viewport->update(); + viewport->queue_redraw(); } return true; @@ -3827,7 +3827,7 @@ void CanvasItemEditor::_draw_viewport() { void CanvasItemEditor::update_viewport() { _update_scrollbars(); - viewport->update(); + viewport->queue_redraw(); } void CanvasItemEditor::set_current_tool(Tool p_tool) { @@ -3895,7 +3895,7 @@ void CanvasItemEditor::_notification(int p_what) { Transform2D xform = canvas_item->get_transform(); if (rect != se->prev_rect || xform != se->prev_xform) { - viewport->update(); + viewport->queue_redraw(); se->prev_rect = rect; se->prev_xform = xform; } @@ -3917,7 +3917,7 @@ void CanvasItemEditor::_notification(int p_what) { se->prev_anchors[SIDE_RIGHT] = anchors[SIDE_RIGHT]; se->prev_anchors[SIDE_TOP] = anchors[SIDE_TOP]; se->prev_anchors[SIDE_BOTTOM] = anchors[SIDE_BOTTOM]; - viewport->update(); + viewport->queue_redraw(); } } @@ -3933,7 +3933,7 @@ void CanvasItemEditor::_notification(int p_what) { for (KeyValue<BoneKey, BoneList> &E : bone_list) { Object *b = ObjectDB::get_instance(E.key.from); if (!b) { - viewport->update(); + viewport->queue_redraw(); break; } @@ -3946,13 +3946,13 @@ void CanvasItemEditor::_notification(int p_what) { if (global_xform != E.value.xform) { E.value.xform = global_xform; - viewport->update(); + viewport->queue_redraw(); } Bone2D *bone = Object::cast_to<Bone2D>(b); if (bone && bone->get_length() != E.value.length) { E.value.length = bone->get_length(); - viewport->update(); + viewport->queue_redraw(); } } } break; @@ -4106,7 +4106,7 @@ void CanvasItemEditor::_update_scroll(real_t) { view_offset.x = h_scroll->get_value(); view_offset.y = v_scroll->get_value(); - viewport->update(); + viewport->queue_redraw(); } void CanvasItemEditor::_zoom_on_position(real_t p_zoom, Point2 p_position) { @@ -4148,12 +4148,12 @@ void CanvasItemEditor::_shortcut_zoom_set(real_t p_zoom) { void CanvasItemEditor::_button_toggle_smart_snap(bool p_status) { smart_snap_active = p_status; - viewport->update(); + viewport->queue_redraw(); } void CanvasItemEditor::_button_toggle_grid_snap(bool p_status) { grid_snap_active = p_status; - viewport->update(); + viewport->queue_redraw(); } void CanvasItemEditor::_button_override_camera(bool p_pressed) { @@ -4174,7 +4174,7 @@ void CanvasItemEditor::_button_tool_select(int p_index) { tool = (Tool)p_index; - viewport->update(); + viewport->queue_redraw(); _update_cursor(); } @@ -4276,25 +4276,25 @@ void CanvasItemEditor::_popup_callback(int p_op) { show_origin = !show_origin; int idx = view_menu->get_popup()->get_item_index(SHOW_ORIGIN); view_menu->get_popup()->set_item_checked(idx, show_origin); - viewport->update(); + viewport->queue_redraw(); } break; case SHOW_VIEWPORT: { show_viewport = !show_viewport; int idx = view_menu->get_popup()->get_item_index(SHOW_VIEWPORT); view_menu->get_popup()->set_item_checked(idx, show_viewport); - viewport->update(); + viewport->queue_redraw(); } break; case SHOW_EDIT_LOCKS: { show_edit_locks = !show_edit_locks; int idx = view_menu->get_popup()->get_item_index(SHOW_EDIT_LOCKS); view_menu->get_popup()->set_item_checked(idx, show_edit_locks); - viewport->update(); + viewport->queue_redraw(); } break; case SHOW_TRANSFORMATION_GIZMOS: { show_transformation_gizmos = !show_transformation_gizmos; int idx = view_menu->get_popup()->get_item_index(SHOW_TRANSFORMATION_GIZMOS); view_menu->get_popup()->set_item_checked(idx, show_transformation_gizmos); - viewport->update(); + viewport->queue_redraw(); } break; case SNAP_USE_NODE_PARENT: { snap_node_parent = !snap_node_parent; @@ -4340,7 +4340,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { snap_relative = !snap_relative; int idx = snap_config_menu->get_popup()->get_item_index(SNAP_RELATIVE); snap_config_menu->get_popup()->set_item_checked(idx, snap_relative); - viewport->update(); + viewport->queue_redraw(); } break; case SNAP_USE_PIXEL: { snap_pixel = !snap_pixel; @@ -4370,20 +4370,20 @@ void CanvasItemEditor::_popup_callback(int p_op) { show_helpers = !show_helpers; int idx = view_menu->get_popup()->get_item_index(SHOW_HELPERS); view_menu->get_popup()->set_item_checked(idx, show_helpers); - viewport->update(); + viewport->queue_redraw(); } break; case SHOW_RULERS: { show_rulers = !show_rulers; int idx = view_menu->get_popup()->get_item_index(SHOW_RULERS); view_menu->get_popup()->set_item_checked(idx, show_rulers); _update_scrollbars(); - viewport->update(); + viewport->queue_redraw(); } break; case SHOW_GUIDES: { show_guides = !show_guides; int idx = view_menu->get_popup()->get_item_index(SHOW_GUIDES); view_menu->get_popup()->set_item_checked(idx, show_guides); - viewport->update(); + viewport->queue_redraw(); } break; case LOCK_SELECTED: { undo_redo->create_action(TTR("Lock Selected")); @@ -4403,8 +4403,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->add_do_method(this, "emit_signal", "item_lock_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_lock_status_changed"); } - undo_redo->add_do_method(viewport, "update"); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_do_method(viewport, "queue_redraw"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } break; case UNLOCK_SELECTED: { @@ -4425,8 +4425,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->add_do_method(this, "emit_signal", "item_lock_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_lock_status_changed"); } - undo_redo->add_do_method(viewport, "update"); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_do_method(viewport, "queue_redraw"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } break; case GROUP_SELECTED: { @@ -4447,8 +4447,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->add_do_method(this, "emit_signal", "item_group_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_group_status_changed"); } - undo_redo->add_do_method(viewport, "update"); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_do_method(viewport, "queue_redraw"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } break; case UNGROUP_SELECTED: { @@ -4469,8 +4469,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->add_do_method(this, "emit_signal", "item_group_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_group_status_changed"); } - undo_redo->add_do_method(viewport, "update"); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_do_method(viewport, "queue_redraw"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } break; @@ -4590,7 +4590,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->add_do_method(root, "remove_meta", "_edit_vertical_guides_"); undo_redo->add_undo_method(root, "set_meta", "_edit_vertical_guides_", vguides); } - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } @@ -4704,7 +4704,7 @@ void CanvasItemEditor::_focus_selection(int p_op) { real_t scale_y = viewport->get_size().y / rect.size.y; zoom = scale_x < scale_y ? scale_x : scale_y; zoom *= 0.90; - viewport->update(); + viewport->queue_redraw(); zoom_widget->set_zoom(zoom); call_deferred(SNAME("_popup_callback"), VIEW_CENTER_TO_SELECTION); } @@ -4930,7 +4930,7 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) { if (update_scrollbars) { _update_scrollbars(); } - viewport->update(); + viewport->queue_redraw(); } void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) { @@ -4980,7 +4980,7 @@ CanvasItemEditor::CanvasItemEditor() { undo_redo = EditorNode::get_singleton()->get_undo_redo(); editor_selection = EditorNode::get_singleton()->get_editor_selection(); editor_selection->add_editor_plugin(this); - editor_selection->connect("selection_changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); + editor_selection->connect("selection_changed", callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); editor_selection->connect("selection_changed", callable_mp(this, &CanvasItemEditor::_selection_changed)); SceneTreeDock::get_singleton()->connect("node_created", callable_mp(this, &CanvasItemEditor::_node_created)); diff --git a/editor/plugins/control_editor_plugin.cpp b/editor/plugins/control_editor_plugin.cpp index 69f32a3a98..bb6092755e 100644 --- a/editor/plugins/control_editor_plugin.cpp +++ b/editor/plugins/control_editor_plugin.cpp @@ -523,7 +523,7 @@ ControlEditorPopupButton::ControlEditorPopupButton() { set_focus_mode(FOCUS_NONE); popup_panel = memnew(PopupPanel); - popup_panel->set_theme_type_variation("ControlEditorPopupButton"); + popup_panel->set_theme_type_variation("ControlEditorPopupPanel"); add_child(popup_panel); popup_panel->connect("about_to_popup", callable_mp(this, &ControlEditorPopupButton::_popup_visibility_changed).bind(true)); popup_panel->connect("popup_hide", callable_mp(this, &ControlEditorPopupButton::_popup_visibility_changed).bind(false)); diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 013a9f10a4..9a31263f9a 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -87,7 +87,7 @@ void CurveEditor::set_curve(Ref<Curve> curve) { _hover_point = -1; _selected_tangent = TANGENT_NONE; - update(); + queue_redraw(); // Note: if you edit a curve, then set another, and try to undo, // it will normally apply on the previous curve, but you won't see it @@ -311,7 +311,7 @@ void CurveEditor::on_preset_item_selected(int preset_id) { } void CurveEditor::_curve_changed() { - update(); + queue_redraw(); // Point count can change in case of undo if (_selected_point >= _curve_ref->get_point_count()) { set_selected_point(-1); @@ -512,14 +512,14 @@ void CurveEditor::toggle_linear(TangentIndex tangent) { void CurveEditor::set_selected_point(int index) { if (index != _selected_point) { _selected_point = index; - update(); + queue_redraw(); } } void CurveEditor::set_hover_point_index(int index) { if (index != _hover_point) { _hover_point = index; - update(); + queue_redraw(); } } diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 0196214ceb..f4a718119e 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -255,7 +255,7 @@ Ref<Texture2D> EditorPackedScenePreviewPlugin::generate(const Ref<Resource> &p_f Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const { String temp_path = EditorPaths::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(p_path).md5_text(); - cache_base = temp_path.plus_file("resthumb-" + cache_base); + cache_base = temp_path.path_join("resthumb-" + cache_base); //does not have it, try to load a cached thumbnail diff --git a/editor/plugins/font_config_plugin.cpp b/editor/plugins/font_config_plugin.cpp index 935b0a5501..2df951518e 100644 --- a/editor/plugins/font_config_plugin.cpp +++ b/editor/plugins/font_config_plugin.cpp @@ -942,7 +942,7 @@ Size2 FontPreview::get_minimum_size() const { void FontPreview::set_data(const Ref<Font> &p_f) { prev_font = p_f; - update(); + queue_redraw(); } FontPreview::FontPreview() { diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp index f368d5bea1..890090c899 100644 --- a/editor/plugins/gradient_editor_plugin.cpp +++ b/editor/plugins/gradient_editor_plugin.cpp @@ -50,7 +50,7 @@ void GradientEditor::_gradient_changed() { Vector<Gradient::Point> points = gradient->get_points(); set_points(points); set_interpolation_mode(gradient->get_interpolation_mode()); - update(); + queue_redraw(); editing = false; } @@ -83,7 +83,7 @@ void GradientEditor::reverse_gradient() { gradient->reverse(); set_points(gradient->get_points()); emit_signal(SNAME("ramp_changed")); - update(); + queue_redraw(); } GradientEditor::GradientEditor() { diff --git a/editor/plugins/gradient_texture_2d_editor_plugin.cpp b/editor/plugins/gradient_texture_2d_editor_plugin.cpp index 5aaf450d3f..dc01a52bb3 100644 --- a/editor/plugins/gradient_texture_2d_editor_plugin.cpp +++ b/editor/plugins/gradient_texture_2d_editor_plugin.cpp @@ -89,17 +89,17 @@ void GradientTexture2DEditorRect::gui_input(const Ref<InputEvent> &p_event) { void GradientTexture2DEditorRect::set_texture(Ref<GradientTexture2D> &p_texture) { texture = p_texture; - texture->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); + texture->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); } void GradientTexture2DEditorRect::set_snap_enabled(bool p_snap_enabled) { snap_enabled = p_snap_enabled; - update(); + queue_redraw(); } void GradientTexture2DEditorRect::set_snap_size(float p_snap_size) { snap_size = p_snap_size; - update(); + queue_redraw(); } void GradientTexture2DEditorRect::_notification(int p_what) { diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 74a6e90a6d..709f19016c 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -153,7 +153,7 @@ MaterialEditor::MaterialEditor() { vc->add_child(viewport); viewport->set_disable_input(true); viewport->set_transparent_background(true); - viewport->set_msaa(Viewport::MSAA_4X); + viewport->set_msaa_3d(Viewport::MSAA_4X); camera = memnew(Camera3D); camera->set_transform(Transform3D(Basis(), Vector3(0, 0, 3))); diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index 980d2974a0..90d50d30d9 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -112,7 +112,7 @@ MeshEditor::MeshEditor() { viewport->set_world_3d(world_3d); //use own world add_child(viewport); viewport->set_disable_input(true); - viewport->set_msaa(Viewport::MSAA_4X); + viewport->set_msaa_3d(Viewport::MSAA_4X); set_stretch(true); camera = memnew(Camera3D); camera->set_transform(Transform3D(Basis(), Vector3(0, 0, 1.1))); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index f165b83999..b771faeb33 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -99,7 +99,7 @@ void ViewportRotationControl::_notification(int p_what) { axis_colors.push_back(get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); axis_colors.push_back(get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); axis_colors.push_back(get_theme_color(SNAME("axis_z_color"), SNAME("Editor"))); - update(); + queue_redraw(); if (!is_connected("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited))) { connect("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited)); @@ -247,13 +247,13 @@ void ViewportRotationControl::_update_focus() { } if (focused_axis != original_focus) { - update(); + queue_redraw(); } } void ViewportRotationControl::_on_mouse_exited() { focused_axis = -2; - update(); + queue_redraw(); } void ViewportRotationControl::set_viewport(Node3DEditorViewport *p_viewport) { @@ -350,7 +350,7 @@ void Node3DEditorViewport::_update_camera(real_t p_interp_delta) { } update_transform_gizmo_view(); - rotation_control->update(); + rotation_control->queue_redraw(); spatial_editor->update_grid(); } } @@ -1614,7 +1614,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } } - surface->update(); + surface->queue_redraw(); } else { if (_edit.gizmo.is_valid()) { _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, false); @@ -1632,7 +1632,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (cursor.region_select) { _select_region(); cursor.region_select = false; - surface->update(); + surface->queue_redraw(); } } @@ -1657,7 +1657,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { _edit.mode = TRANSFORM_NONE; set_message(""); } - surface->update(); + surface->queue_redraw(); } } break; @@ -1741,7 +1741,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (cursor.region_select) { cursor.region_end = m->get_position(); - surface->update(); + surface->queue_redraw(); return; } @@ -2244,12 +2244,12 @@ void Node3DEditorViewport::set_freelook_active(bool active_now) { void Node3DEditorViewport::scale_fov(real_t p_fov_offset) { cursor.fov_scale = CLAMP(cursor.fov_scale + p_fov_offset, 0.1, 2.5); - surface->update(); + surface->queue_redraw(); } void Node3DEditorViewport::reset_fov() { cursor.fov_scale = 1.0; - surface->update(); + surface->queue_redraw(); } void Node3DEditorViewport::scale_cursor_distance(real_t scale) { @@ -2268,7 +2268,7 @@ void Node3DEditorViewport::scale_cursor_distance(real_t scale) { } zoom_indicator_delay = ZOOM_FREELOOK_INDICATOR_DELAY_S; - surface->update(); + surface->queue_redraw(); } void Node3DEditorViewport::scale_freelook_speed(real_t scale) { @@ -2281,7 +2281,7 @@ void Node3DEditorViewport::scale_freelook_speed(real_t scale) { } zoom_indicator_delay = ZOOM_FREELOOK_INDICATOR_DELAY_S; - surface->update(); + surface->queue_redraw(); } Point2i Node3DEditorViewport::_get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const { @@ -2393,8 +2393,8 @@ void Node3DEditorViewport::_project_settings_changed() { // Update MSAA, screen-space AA and debanding if changed - const int msaa_mode = ProjectSettings::get_singleton()->get("rendering/anti_aliasing/quality/msaa"); - viewport->set_msaa(Viewport::MSAA(msaa_mode)); + const int msaa_mode = ProjectSettings::get_singleton()->get("rendering/anti_aliasing/quality/msaa_3d"); + viewport->set_msaa_3d(Viewport::MSAA(msaa_mode)); const int ssaa_mode = GLOBAL_GET("rendering/anti_aliasing/quality/screen_space_aa"); viewport->set_screen_space_aa(Viewport::ScreenSpaceAA(ssaa_mode)); const bool use_taa = GLOBAL_GET("rendering/anti_aliasing/quality/use_taa"); @@ -2454,7 +2454,7 @@ void Node3DEditorViewport::_notification(int p_what) { if (zoom_indicator_delay > 0) { zoom_indicator_delay -= delta; if (zoom_indicator_delay <= 0) { - surface->update(); + surface->queue_redraw(); zoom_limit_label->hide(); } } @@ -2472,7 +2472,7 @@ void Node3DEditorViewport::_notification(int p_what) { previewing = cam; previewing->connect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera()); - surface->update(); + surface->queue_redraw(); } } @@ -2538,13 +2538,13 @@ void Node3DEditorViewport::_notification(int p_what) { if (message_time > 0) { if (message != last_message) { - surface->update(); + surface->queue_redraw(); last_message = message; } message_time -= get_physics_process_delta_time(); if (message_time < 0) { - surface->update(); + surface->queue_redraw(); } } @@ -3356,13 +3356,13 @@ void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) { if (!preview) { preview_camera->hide(); } - surface->update(); + surface->queue_redraw(); } else { previewing = preview; previewing->connect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace - surface->update(); + surface->queue_redraw(); } } @@ -3384,7 +3384,7 @@ void Node3DEditorViewport::_toggle_cinema_preview(bool p_activate) { preview_camera->show(); } view_menu->show(); - surface->update(); + surface->queue_redraw(); } } @@ -3619,7 +3619,7 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) { previewing = Object::cast_to<Camera3D>(pv); previewing->connect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace - surface->update(); + surface->queue_redraw(); preview_camera->set_pressed(true); preview_camera->show(); } @@ -4392,7 +4392,7 @@ void Node3DEditorViewport::update_transform(Point2 p_mousepos, bool p_shift) { } spatial_editor->update_transform_gizmo(); - surface->update(); + surface->queue_redraw(); } break; @@ -4491,7 +4491,7 @@ void Node3DEditorViewport::update_transform(Point2 p_mousepos, bool p_shift) { } spatial_editor->update_transform_gizmo(); - surface->update(); + surface->queue_redraw(); } break; @@ -4595,7 +4595,7 @@ void Node3DEditorViewport::update_transform(Point2 p_mousepos, bool p_shift) { } spatial_editor->update_transform_gizmo(); - surface->update(); + surface->queue_redraw(); } break; default: { @@ -4608,7 +4608,7 @@ void Node3DEditorViewport::finish_transform() { spatial_editor->update_transform_gizmo(); _edit.mode = TRANSFORM_NONE; _edit.instant = false; - surface->update(); + surface->queue_redraw(); } // Register a shortcut and also add it as an input action with the same events. @@ -5010,7 +5010,7 @@ void Node3DEditorViewportContainer::gui_input(const Ref<InputEvent> &p_event) { hovering_v = mm->get_position().y > (mid_h - v_sep / 2) && mm->get_position().y < (mid_h + v_sep / 2); if (was_hovering_h != hovering_h || was_hovering_v != hovering_v) { - update(); + queue_redraw(); } } @@ -5019,14 +5019,14 @@ void Node3DEditorViewportContainer::gui_input(const Ref<InputEvent> &p_event) { new_ratio = CLAMP(new_ratio, 40 / get_size().width, (get_size().width - 40) / get_size().width); ratio_h = new_ratio; queue_sort(); - update(); + queue_redraw(); } if (dragging_v) { real_t new_ratio = drag_begin_ratio.y + (mm->get_position().y - drag_begin_pos.y) / get_size().height; new_ratio = CLAMP(new_ratio, 40 / get_size().height, (get_size().height - 40) / get_size().height); ratio_v = new_ratio; queue_sort(); - update(); + queue_redraw(); } } } @@ -5036,7 +5036,7 @@ void Node3DEditorViewportContainer::_notification(int p_what) { case NOTIFICATION_MOUSE_ENTER: case NOTIFICATION_MOUSE_EXIT: { mouseover = (p_what == NOTIFICATION_MOUSE_ENTER); - update(); + queue_redraw(); } break; case NOTIFICATION_DRAW: { @@ -7581,7 +7581,7 @@ void Node3DEditor::_preview_settings_changed() { Transform3D t; t.basis = Basis(Vector3(sun_rotation.x, sun_rotation.y, 0)); preview_sun->set_transform(t); - sun_direction->update(); + sun_direction->queue_redraw(); preview_sun->set_param(Light3D::PARAM_ENERGY, sun_energy->get_value()); preview_sun->set_param(Light3D::PARAM_SHADOW_MAX_DISTANCE, sun_max_distance->get_value()); preview_sun->set_color(sun_color->get_pick_color()); @@ -7615,7 +7615,7 @@ void Node3DEditor::_load_default_preview_settings() { sun_angle_altitude->set_value(-Math::rad_to_deg(sun_rotation.x)); sun_angle_azimuth->set_value(180.0 - Math::rad_to_deg(sun_rotation.y)); - sun_direction->update(); + sun_direction->queue_redraw(); environ_sky_color->set_pick_color(Color(0.385, 0.454, 0.55)); environ_ground_color->set_pick_color(Color(0.2, 0.169, 0.133)); environ_energy->set_value(1.0); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index e0298ebd5f..d38c5948cc 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -433,7 +433,7 @@ protected: static void _bind_methods(); public: - void update_surface() { surface->update(); } + void update_surface() { surface->queue_redraw(); } void update_transform_gizmo_view(); void set_can_preview(Camera3D *p_preview); diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index b71cee8882..a652d1d12f 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -155,8 +155,8 @@ void Polygon2DEditor::_sync_bones() { undo_redo->add_undo_method(node, "_set_bones", prev_bones); undo_redo->add_do_method(this, "_update_bone_list"); undo_redo->add_undo_method(this, "_update_bone_list"); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } @@ -195,11 +195,11 @@ void Polygon2DEditor::_update_bone_list() { cb->connect("pressed", callable_mp(this, &Polygon2DEditor::_bone_paint_selected).bind(i)); } - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_bone_paint_selected(int p_index) { - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_uv_edit_mode_select(int p_mode) { @@ -269,7 +269,7 @@ void Polygon2DEditor::_uv_edit_mode_select(int p_mode) { } uv_edit->set_size(uv_edit->get_size()); // Necessary readjustment of the popup window. - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_uv_edit_popup_hide() { @@ -293,8 +293,8 @@ void Polygon2DEditor::_menu_option(int p_option) { undo_redo->create_action(TTR("Create UV Map")); undo_redo->add_do_method(node, "set_uv", points); undo_redo->add_undo_method(node, "set_uv", uvs); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } @@ -314,8 +314,8 @@ void Polygon2DEditor::_menu_option(int p_option) { undo_redo->create_action(TTR("Create UV Map")); undo_redo->add_do_method(node, "set_uv", points); undo_redo->add_undo_method(node, "set_uv", uvs); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } break; case UVEDIT_UV_TO_POLYGON: { @@ -328,8 +328,8 @@ void Polygon2DEditor::_menu_option(int p_option) { undo_redo->create_action(TTR("Create Polygon")); undo_redo->add_do_method(node, "set_polygon", uvs); undo_redo->add_undo_method(node, "set_polygon", points); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } break; case UVEDIT_UV_CLEAR: { @@ -340,8 +340,8 @@ void Polygon2DEditor::_menu_option(int p_option) { undo_redo->create_action(TTR("Create UV Map")); undo_redo->add_do_method(node, "set_uv", Vector<Vector2>()); undo_redo->add_undo_method(node, "set_uv", uvs); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } break; case UVEDIT_GRID_SETTINGS: { @@ -391,8 +391,8 @@ void Polygon2DEditor::_update_polygon_editing_state() { void Polygon2DEditor::_commit_action() { // Makes that undo/redoing actions made outside of the UV editor still affect its polygon. - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->add_do_method(CanvasItemEditor::get_singleton(), "update_viewport"); undo_redo->add_undo_method(CanvasItemEditor::get_singleton(), "update_viewport"); undo_redo->commit_action(); @@ -406,31 +406,31 @@ void Polygon2DEditor::_set_use_snap(bool p_use) { void Polygon2DEditor::_set_show_grid(bool p_show) { snap_show_grid = p_show; EditorSettings::get_singleton()->set_project_metadata("polygon_2d_uv_editor", "show_grid", p_show); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_set_snap_off_x(real_t p_val) { snap_offset.x = p_val; EditorSettings::get_singleton()->set_project_metadata("polygon_2d_uv_editor", "snap_offset", snap_offset); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_set_snap_off_y(real_t p_val) { snap_offset.y = p_val; EditorSettings::get_singleton()->set_project_metadata("polygon_2d_uv_editor", "snap_offset", snap_offset); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_set_snap_step_x(real_t p_val) { snap_step.x = p_val; EditorSettings::get_singleton()->set_project_metadata("polygon_2d_uv_editor", "snap_step", snap_step); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_set_snap_step_y(real_t p_val) { snap_step.y = p_val; EditorSettings::get_singleton()->set_project_metadata("polygon_2d_uv_editor", "snap_step", snap_step); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_uv_mode(int p_mode) { @@ -495,7 +495,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { node->set_uv(points_prev); node->set_internal_vertex_count(0); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } else { Vector2 tuv = mtx.affine_inverse().xform(snap_point(mb->get_position())); @@ -514,8 +514,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->add_undo_method(node, "_set_bones", uv_create_bones_prev); undo_redo->add_do_method(this, "_update_polygon_editing_state"); undo_redo->add_undo_method(this, "_update_polygon_editing_state"); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); uv_drag = false; uv_create = false; @@ -566,8 +566,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->add_undo_method(node, "set_internal_vertex_count", internal_vertices); undo_redo->add_do_method(this, "_update_polygon_editing_state"); undo_redo->add_undo_method(this, "_update_polygon_editing_state"); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } @@ -621,8 +621,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->add_undo_method(node, "set_internal_vertex_count", internal_vertices); undo_redo->add_do_method(this, "_update_polygon_editing_state"); undo_redo->add_undo_method(this, "_update_polygon_editing_state"); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } @@ -679,8 +679,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->create_action(TTR("Add Custom Polygon")); undo_redo->add_do_method(node, "set_polygons", polygons); undo_redo->add_undo_method(node, "set_polygons", node->get_polygons()); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } @@ -720,8 +720,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->create_action(TTR("Remove Custom Polygon")); undo_redo->add_do_method(node, "set_polygons", polygons); undo_redo->add_undo_method(node, "set_polygons", node->get_polygons()); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } } @@ -748,15 +748,15 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->create_action(TTR("Transform UV Map")); undo_redo->add_do_method(node, "set_uv", node->get_uv()); undo_redo->add_undo_method(node, "set_uv", points_prev); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } else if (uv_edit_mode[1]->is_pressed() && uv_move_current == UV_MODE_EDIT_POINT) { // Edit polygon. undo_redo->create_action(TTR("Transform Polygon")); undo_redo->add_do_method(node, "set_polygon", node->get_polygon()); undo_redo->add_undo_method(node, "set_polygon", points_prev); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } @@ -767,8 +767,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->create_action(TTR("Paint Bone Weights")); undo_redo->add_do_method(node, "set_bone_weights", bone_painting_bone, node->get_bone_weights(bone_painting_bone)); undo_redo->add_undo_method(node, "set_bone_weights", bone_painting_bone, prev_weights); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); bone_painting = false; } @@ -780,7 +780,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { node->set_bone_weights(bone_painting_bone, prev_weights); } - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } } @@ -906,14 +906,14 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { node->set_bone_weights(bone_painting_bone, painted_weights); } - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); CanvasItemEditor::get_singleton()->update_viewport(); } else if (polygon_create.size()) { uv_create_to = mtx.affine_inverse().xform(mm->get_position()); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } else if (uv_mode == UV_MODE_PAINT_WEIGHT || uv_mode == UV_MODE_CLEAR_WEIGHT) { bone_paint_pos = mm->get_position(); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } } @@ -954,7 +954,7 @@ void Polygon2DEditor::_uv_scroll_changed(real_t) { uv_draw_ofs.x = uv_hscroll->get_value(); uv_draw_ofs.y = uv_vscroll->get_value(); uv_draw_zoom = uv_zoom->get_value(); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_uv_draw() { diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 80566419b1..21647d1b69 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -196,7 +196,7 @@ void ResourcePreloaderEditor::_update_library() { String type = r->get_class(); ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(type, "Object")); - ti->set_tooltip(0, TTR("Instance:") + " " + r->get_path() + "\n" + TTR("Type:") + " " + type); + ti->set_tooltip_text(0, TTR("Instance:") + " " + r->get_path() + "\n" + TTR("Type:") + " " + type); ti->set_text(1, r->get_path()); ti->set_editable(1, false); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 98be34cb86..aa1d630372 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1540,7 +1540,7 @@ void ScriptEditor::_show_save_theme_as_dialog() { file_dialog_option = THEME_SAVE_AS; file_dialog->clear_filters(); file_dialog->add_filter("*.tet"); - file_dialog->set_current_path(EditorPaths::get_singleton()->get_text_editor_themes_dir().plus_file(EditorSettings::get_singleton()->get("text_editor/theme/color_theme"))); + file_dialog->set_current_path(EditorPaths::get_singleton()->get_text_editor_themes_dir().path_join(EditorSettings::get_singleton()->get("text_editor/theme/color_theme"))); file_dialog->popup_file_dialog(); file_dialog->set_title(TTR("Save Theme As...")); } @@ -2038,7 +2038,7 @@ void ScriptEditor::_update_script_names() { } break; case DISPLAY_DIR_AND_NAME: { if (!path.get_base_dir().get_file().is_empty()) { - sd.name = path.get_base_dir().get_file().plus_file(name); + sd.name = path.get_base_dir().get_file().path_join(name); } else { sd.name = name; } @@ -2064,7 +2064,7 @@ void ScriptEditor::_update_script_names() { name = name.get_file(); } break; case DISPLAY_DIR_AND_NAME: { - name = name.get_base_dir().get_file().plus_file(name.get_file()); + name = name.get_base_dir().get_file().path_join(name.get_file()); } break; default: break; @@ -3267,7 +3267,7 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) { p_layout->set_value("ScriptEditor", "list_split_offset", list_split->get_split_offset()); // Save the cache. - script_editor_cache->save(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("script_editor_cache.cfg")); + script_editor_cache->save(EditorPaths::get_singleton()->get_project_settings_dir().path_join("script_editor_cache.cfg")); } void ScriptEditor::_help_class_open(const String &p_class) { @@ -3648,7 +3648,7 @@ ScriptEditor::ScriptEditor() { current_theme = ""; script_editor_cache.instantiate(); - script_editor_cache->load(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("script_editor_cache.cfg")); + script_editor_cache->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("script_editor_cache.cfg")); completion_cache = memnew(EditorScriptCodeCompletionCache); restoring_layout = false; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 5e7db17edf..fff956a05e 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -942,7 +942,7 @@ void ScriptTextEditor::_validate_symbol(const String &p_symbol) { String ScriptTextEditor::_get_absolute_path(const String &rel_path) { String base_path = script->get_path().get_base_dir(); - String path = base_path.plus_file(rel_path); + String path = base_path.path_join(rel_path); return path.replace("///", "//").simplify_path(); } @@ -1124,15 +1124,15 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case EDIT_TOGGLE_FOLD_LINE: { tx->toggle_foldable_line(tx->get_caret_line()); - tx->update(); + tx->queue_redraw(); } break; case EDIT_FOLD_ALL_LINES: { tx->fold_all_lines(); - tx->update(); + tx->queue_redraw(); } break; case EDIT_UNFOLD_ALL_LINES: { tx->unfold_all_lines(); - tx->update(); + tx->queue_redraw(); } break; case EDIT_TOGGLE_COMMENT: { _edit_option_toggle_inline_comment(); @@ -1590,7 +1590,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data } } - String variable_name = String(node->get_name()).camelcase_to_underscore(true).validate_identifier(); + String variable_name = String(node->get_name()).to_snake_case().validate_identifier(); if (use_type) { text_to_drop += vformat("@onready var %s: %s = %s%s\n", variable_name, node->get_class_name(), is_unique ? "%" : "$", path); } else { @@ -1760,7 +1760,7 @@ void ScriptTextEditor::_color_changed(const Color &p_color) { code_editor->get_text_editor()->begin_complex_operation(); code_editor->get_text_editor()->set_line(color_position.x, line_with_replaced_args); code_editor->get_text_editor()->end_complex_operation(); - code_editor->get_text_editor()->update(); + code_editor->get_text_editor()->queue_redraw(); } void ScriptTextEditor::_prepare_edit_menu() { diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 53bc6fbdf4..6674d15268 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -1398,12 +1398,12 @@ void ShaderEditorPlugin::_menu_item_pressed(int p_index) { switch (p_index) { case FILE_NEW: { String base_path = FileSystemDock::get_singleton()->get_current_path().get_base_dir(); - shader_create_dialog->config(base_path.plus_file("new_shader"), false, false, 0); + shader_create_dialog->config(base_path.path_join("new_shader"), false, false, 0); shader_create_dialog->popup_centered(); } break; case FILE_NEW_INCLUDE: { String base_path = FileSystemDock::get_singleton()->get_current_path().get_base_dir(); - shader_create_dialog->config(base_path.plus_file("new_shader"), false, false, 2); + shader_create_dialog->config(base_path.path_join("new_shader"), false, false, 2); shader_create_dialog->popup_centered(); } break; case FILE_OPEN: { diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index f21adabffb..026d957407 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -182,27 +182,27 @@ void BoneTransformEditor::_update_properties() { if (split[2] == "enabled") { enabled_checkbox->set_read_only(E.usage & PROPERTY_USAGE_READ_ONLY); enabled_checkbox->update_property(); - enabled_checkbox->update(); + enabled_checkbox->queue_redraw(); } if (split[2] == "position") { position_property->set_read_only(E.usage & PROPERTY_USAGE_READ_ONLY); position_property->update_property(); - position_property->update(); + position_property->queue_redraw(); } if (split[2] == "rotation") { rotation_property->set_read_only(E.usage & PROPERTY_USAGE_READ_ONLY); rotation_property->update_property(); - rotation_property->update(); + rotation_property->queue_redraw(); } if (split[2] == "scale") { scale_property->set_read_only(E.usage & PROPERTY_USAGE_READ_ONLY); scale_property->update_property(); - scale_property->update(); + scale_property->queue_redraw(); } if (split[2] == "rest") { rest_matrix->set_read_only(E.usage & PROPERTY_USAGE_READ_ONLY); rest_matrix->update_property(); - rest_matrix->update(); + rest_matrix->queue_redraw(); } } } @@ -690,8 +690,6 @@ void Skeleton3DEditor::update_editors() { void Skeleton3DEditor::create_editors() { set_h_size_flags(SIZE_EXPAND_FILL); - add_theme_constant_override("separation", 0); - set_focus_mode(FOCUS_ALL); Node3DEditor *ne = Node3DEditor::get_singleton(); @@ -823,20 +821,11 @@ void Skeleton3DEditor::create_editors() { void Skeleton3DEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_READY: { - edit_mode_button->set_icon(get_theme_icon(SNAME("ToolBoneSelect"), SNAME("EditorIcons"))); - key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons"))); - key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons"))); - key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons"))); - key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons"))); - key_insert_all_button->set_icon(get_theme_icon(SNAME("NewKey"), SNAME("EditorIcons"))); - get_tree()->connect("node_removed", callable_mp(this, &Skeleton3DEditor::_node_removed), Object::CONNECT_ONESHOT); - break; - } case NOTIFICATION_ENTER_TREE: { create_editors(); update_joint_tree(); update_editors(); + joint_tree->connect("item_selected", callable_mp(this, &Skeleton3DEditor::_joint_tree_selection_changed)); joint_tree->connect("item_mouse_selected", callable_mp(this, &Skeleton3DEditor::_joint_tree_rmb_select)); #ifdef TOOLS_ENABLED @@ -845,8 +834,23 @@ void Skeleton3DEditor::_notification(int p_what) { skeleton->connect("bone_enabled_changed", callable_mp(this, &Skeleton3DEditor::_bone_enabled_changed)); skeleton->connect("show_rest_only_changed", callable_mp(this, &Skeleton3DEditor::_update_gizmo_visible)); #endif - break; - } + + get_tree()->connect("node_removed", callable_mp(this, &Skeleton3DEditor::_node_removed), Object::CONNECT_ONESHOT); + } break; + case NOTIFICATION_READY: { + // Will trigger NOTIFICATION_THEME_CHANGED, but won't cause any loops if called here. + add_theme_constant_override("separation", 0); + } break; + case NOTIFICATION_THEME_CHANGED: { + edit_mode_button->set_icon(get_theme_icon(SNAME("ToolBoneSelect"), SNAME("EditorIcons"))); + key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons"))); + key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons"))); + key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons"))); + key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons"))); + key_insert_all_button->set_icon(get_theme_icon(SNAME("NewKey"), SNAME("EditorIcons"))); + + update_joint_tree(); + } break; } } diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index e45c907e86..615fd5dba9 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -128,7 +128,7 @@ void Sprite2DEditor::_menu_option(int p_option) { _update_mesh_data(); debug_uv_dialog->popup_centered(); - debug_uv->update(); + debug_uv->queue_redraw(); } break; case MENU_OPTION_CONVERT_TO_POLYGON_2D: { @@ -137,7 +137,7 @@ void Sprite2DEditor::_menu_option(int p_option) { _update_mesh_data(); debug_uv_dialog->popup_centered(); - debug_uv->update(); + debug_uv->queue_redraw(); } break; case MENU_OPTION_CREATE_COLLISION_POLY_2D: { debug_uv_dialog->set_ok_button_text(TTR("Create CollisionPolygon2D")); @@ -145,7 +145,7 @@ void Sprite2DEditor::_menu_option(int p_option) { _update_mesh_data(); debug_uv_dialog->popup_centered(); - debug_uv->update(); + debug_uv->queue_redraw(); } break; case MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D: { @@ -154,7 +154,7 @@ void Sprite2DEditor::_menu_option(int p_option) { _update_mesh_data(); debug_uv_dialog->popup_centered(); - debug_uv->update(); + debug_uv->queue_redraw(); } break; } @@ -302,7 +302,7 @@ void Sprite2DEditor::_update_mesh_data() { } } - debug_uv->update(); + debug_uv->queue_redraw(); } void Sprite2DEditor::_create_node() { diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 87f0fc4ad0..9508835442 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -182,7 +182,7 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) { if (last_frame_selected != idx || idx != -1) { last_frame_selected = idx; - split_sheet_preview->update(); + split_sheet_preview->queue_redraw(); } } @@ -208,7 +208,7 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) { } last_frame_selected = idx; - split_sheet_preview->update(); + split_sheet_preview->queue_redraw(); } } } @@ -307,7 +307,7 @@ void SpriteFramesEditor::_sheet_select_clear_all_frames() { frames_selected.clear(); } - split_sheet_preview->update(); + split_sheet_preview->queue_redraw(); } void SpriteFramesEditor::_sheet_spin_changed(double p_value, int p_dominant_param) { @@ -363,7 +363,7 @@ void SpriteFramesEditor::_sheet_spin_changed(double p_value, int p_dominant_para frames_selected.clear(); last_frame_selected = -1; - split_sheet_preview->update(); + split_sheet_preview->queue_redraw(); } void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) { diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index d4baff34e2..fffcce6d9a 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -36,7 +36,7 @@ bool StyleBoxPreview::grid_preview_enabled = true; void StyleBoxPreview::_grid_preview_toggled(bool p_active) { grid_preview_enabled = p_active; - preview->update(); + preview->queue_redraw(); } bool EditorInspectorPluginStyleBox::can_handle(Object *p_object) { @@ -66,7 +66,7 @@ void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) { } void StyleBoxPreview::_sb_changed() { - preview->update(); + preview->queue_redraw(); } void StyleBoxPreview::_notification(int p_what) { diff --git a/editor/plugins/sub_viewport_preview_editor_plugin.cpp b/editor/plugins/sub_viewport_preview_editor_plugin.cpp index c8bb0cd56f..074a9708b7 100644 --- a/editor/plugins/sub_viewport_preview_editor_plugin.cpp +++ b/editor/plugins/sub_viewport_preview_editor_plugin.cpp @@ -39,7 +39,7 @@ void EditorInspectorPluginSubViewportPreview::parse_begin(Object *p_object) { TexturePreview *sub_viewport_preview = memnew(TexturePreview(sub_viewport->get_texture(), false)); // Otherwise `sub_viewport_preview`'s `texture_display` doesn't update properly when `sub_viewport`'s size changes. - sub_viewport->connect("size_changed", callable_mp((CanvasItem *)sub_viewport_preview->get_texture_display(), &CanvasItem::update)); + sub_viewport->connect("size_changed", callable_mp((CanvasItem *)sub_viewport_preview->get_texture_display(), &CanvasItem::queue_redraw)); add_custom_control(sub_viewport_preview); } diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 0900415b04..76332b2d10 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -339,15 +339,15 @@ void TextEditor::_edit_option(int p_op) { } break; case EDIT_TOGGLE_FOLD_LINE: { tx->toggle_foldable_line(tx->get_caret_line()); - tx->update(); + tx->queue_redraw(); } break; case EDIT_FOLD_ALL_LINES: { tx->fold_all_lines(); - tx->update(); + tx->queue_redraw(); } break; case EDIT_UNFOLD_ALL_LINES: { tx->unfold_all_lines(); - tx->update(); + tx->queue_redraw(); } break; case EDIT_TRIM_TRAILING_WHITESAPCE: { trim_trailing_whitespace(); diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp index 64cafa17f3..c2517b4b79 100644 --- a/editor/plugins/texture_3d_editor_plugin.cpp +++ b/editor/plugins/texture_3d_editor_plugin.cpp @@ -53,7 +53,7 @@ void Texture3DEditor::_texture_changed() { if (!is_visible()) { return; } - update(); + queue_redraw(); } void Texture3DEditor::_update_material() { @@ -124,7 +124,7 @@ void Texture3DEditor::edit(Ref<Texture3D> p_texture) { } texture->connect("changed", callable_mp(this, &Texture3DEditor::_texture_changed)); - update(); + queue_redraw(); texture_rect->set_material(material); setting = true; layer->set_max(texture->get_depth() - 1); diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index 2c6f70463d..1118f18605 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -64,7 +64,7 @@ void TextureLayeredEditor::_texture_changed() { if (!is_visible()) { return; } - update(); + queue_redraw(); } void TextureLayeredEditor::_update_material() { @@ -190,7 +190,7 @@ void TextureLayeredEditor::edit(Ref<TextureLayered> p_texture) { } texture->connect("changed", callable_mp(this, &TextureLayeredEditor::_texture_changed)); - update(); + queue_redraw(); texture_rect->set_material(materials[texture->get_layered_type()]); setting = true; if (texture->get_layered_type() == TextureLayered::LAYERED_TYPE_2D_ARRAY) { diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 50a7dc7f96..f0e3619060 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -381,8 +381,8 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } undo_redo->add_do_method(this, "_update_rect"); undo_redo->add_undo_method(this, "_update_rect"); - undo_redo->add_do_method(edit_draw, "update"); - undo_redo->add_undo_method(edit_draw, "update"); + undo_redo->add_do_method(edit_draw, "queue_redraw"); + undo_redo->add_undo_method(edit_draw, "queue_redraw"); undo_redo->commit_action(); break; } @@ -455,8 +455,8 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } undo_redo->add_do_method(this, "_update_rect"); undo_redo->add_undo_method(this, "_update_rect"); - undo_redo->add_do_method(edit_draw, "update"); - undo_redo->add_undo_method(edit_draw, "update"); + undo_redo->add_do_method(edit_draw, "queue_redraw"); + undo_redo->add_undo_method(edit_draw, "queue_redraw"); undo_redo->commit_action(); drag = false; creating = false; @@ -477,7 +477,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } else { apply_rect(rect_prev); rect = rect_prev; - edit_draw->update(); + edit_draw->queue_redraw(); drag_index = -1; } } @@ -546,7 +546,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { rect = Rect2(drag_from, Size2()); rect.expand_to(new_pos); apply_rect(rect); - edit_draw->update(); + edit_draw->queue_redraw(); return; } @@ -601,7 +601,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } break; } } - edit_draw->update(); + edit_draw->queue_redraw(); } } @@ -642,7 +642,7 @@ void TextureRegionEditor::_scroll_changed(float) { draw_ofs.x = hscroll->get_value(); draw_ofs.y = vscroll->get_value(); - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_mode(int p_mode) { @@ -658,37 +658,37 @@ void TextureRegionEditor::_set_snap_mode(int p_mode) { _update_autoslice(); } - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_off_x(float p_val) { snap_offset.x = p_val; - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_off_y(float p_val) { snap_offset.y = p_val; - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_step_x(float p_val) { snap_step.x = p_val; - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_step_y(float p_val) { snap_step.y = p_val; - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_sep_x(float p_val) { snap_separation.x = p_val; - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_sep_y(float p_val) { snap_separation.y = p_val; - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_zoom_on_position(float p_zoom, Point2 p_position) { @@ -702,7 +702,7 @@ void TextureRegionEditor::_zoom_on_position(float p_zoom, Point2 p_position) { ofs = ofs / prev_zoom - ofs / draw_zoom; draw_ofs = (draw_ofs + ofs).round(); - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_zoom_in() { @@ -933,7 +933,7 @@ void TextureRegionEditor::edit(Object *p_obj) { obj_styleBox = Ref<StyleBoxTexture>(nullptr); atlas_tex = Ref<AtlasTexture>(nullptr); } - edit_draw->update(); + edit_draw->queue_redraw(); popup_centered_ratio(0.5); request_center = true; } @@ -963,7 +963,7 @@ void TextureRegionEditor::_edit_region() { _zoom_reset(); hscroll->hide(); vscroll->hide(); - edit_draw->update(); + edit_draw->queue_redraw(); return; } @@ -979,7 +979,7 @@ void TextureRegionEditor::_edit_region() { } _update_rect(); - edit_draw->update(); + edit_draw->queue_redraw(); } Vector2 TextureRegionEditor::snap_point(Vector2 p_target) const { diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp index ea8da1e86d..8cc96201e7 100644 --- a/editor/plugins/theme_editor_preview.cpp +++ b/editor/plugins/theme_editor_preview.cpp @@ -56,7 +56,7 @@ void ThemeEditorPreview::add_preview_overlay(Control *p_overlay) { void ThemeEditorPreview::_propagate_redraw(Control *p_at) { p_at->notification(NOTIFICATION_THEME_CHANGED); p_at->update_minimum_size(); - p_at->update(); + p_at->queue_redraw(); for (int i = 0; i < p_at->get_child_count(); i++) { Control *a = Object::cast_to<Control>(p_at->get_child(i)); if (a) { @@ -174,7 +174,7 @@ void ThemeEditorPreview::_gui_input_picker_overlay(const Ref<InputEvent> &p_even if (mm.is_valid()) { Vector2 mp = preview_content->get_local_mouse_position(); hovered_control = _find_hovered_control(preview_content, mp); - picker_overlay->update(); + picker_overlay->queue_redraw(); } // Forward input to the scroll container underneath to allow scrolling. @@ -183,7 +183,7 @@ void ThemeEditorPreview::_gui_input_picker_overlay(const Ref<InputEvent> &p_even void ThemeEditorPreview::_reset_picker_overlay() { hovered_control = nullptr; - picker_overlay->update(); + picker_overlay->queue_redraw(); } void ThemeEditorPreview::_notification(int p_what) { diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp index 8d2b150d6d..5f0576a675 100644 --- a/editor/plugins/tiles/tile_atlas_view.cpp +++ b/editor/plugins/tiles/tile_atlas_view.cpp @@ -404,12 +404,12 @@ void TileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_ _update_zoom_and_panning(); // Update. - base_tiles_draw->update(); - base_tiles_texture_grid->update(); - base_tiles_shape_grid->update(); - alternatives_draw->update(); - background_left->update(); - background_right->update(); + base_tiles_draw->queue_redraw(); + base_tiles_texture_grid->queue_redraw(); + base_tiles_shape_grid->queue_redraw(); + alternatives_draw->queue_redraw(); + background_left->queue_redraw(); + background_right->queue_redraw(); } float TileAtlasView::get_zoom() const { @@ -493,13 +493,13 @@ Rect2i TileAtlasView::get_alternative_tile_rect(const Vector2i p_coords, int p_a return alternative_tiles_rect_cache[p_coords][p_alternative_tile]; } -void TileAtlasView::update() { - base_tiles_draw->update(); - base_tiles_texture_grid->update(); - base_tiles_shape_grid->update(); - alternatives_draw->update(); - background_left->update(); - background_right->update(); +void TileAtlasView::queue_redraw() { + base_tiles_draw->queue_redraw(); + base_tiles_texture_grid->queue_redraw(); + base_tiles_shape_grid->queue_redraw(); + alternatives_draw->queue_redraw(); + background_left->queue_redraw(); + background_right->queue_redraw(); } void TileAtlasView::_notification(int p_what) { diff --git a/editor/plugins/tiles/tile_atlas_view.h b/editor/plugins/tiles/tile_atlas_view.h index 1c0b622bb1..c710eac107 100644 --- a/editor/plugins/tiles/tile_atlas_view.h +++ b/editor/plugins/tiles/tile_atlas_view.h @@ -154,8 +154,8 @@ public: p_control->set_mouse_filter(Control::MOUSE_FILTER_PASS); }; - // Update everything. - void update(); + // Redraw everything. + void queue_redraw(); TileAtlasView(); }; diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index 73e07e6647..1bfbd342c2 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -240,12 +240,12 @@ void GenericTilePolygonEditor::_base_control_draw() { void GenericTilePolygonEditor::_center_view() { panning = Vector2(); - base_control->update(); + base_control->queue_redraw(); button_center_view->set_disabled(true); } void GenericTilePolygonEditor::_zoom_changed() { - base_control->update(); + base_control->queue_redraw(); } void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) { @@ -266,26 +266,26 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) { polygon.write[i] = polygon[i] * tile_set->get_tile_size(); } undo_redo->add_do_method(this, "add_polygon", polygon); - undo_redo->add_do_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); undo_redo->add_do_method(this, "emit_signal", "polygons_changed"); undo_redo->add_undo_method(this, "clear_polygons"); for (unsigned int i = 0; i < polygons.size(); i++) { undo_redo->add_undo_method(this, "add_polygon", polygons[i]); } - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->add_undo_method(this, "emit_signal", "polygons_changed"); undo_redo->commit_action(true); } break; case CLEAR_TILE: { undo_redo->create_action(TTR("Clear Polygons")); undo_redo->add_do_method(this, "clear_polygons"); - undo_redo->add_do_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); undo_redo->add_do_method(this, "emit_signal", "polygons_changed"); undo_redo->add_undo_method(this, "clear_polygons"); for (unsigned int i = 0; i < polygons.size(); i++) { undo_redo->add_undo_method(this, "add_polygon", polygons[i]); } - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->add_undo_method(this, "emit_signal", "polygons_changed"); undo_redo->commit_action(true); } break; @@ -318,12 +318,12 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) { } undo_redo->add_do_method(this, "set_polygon", i, new_polygon); } - undo_redo->add_do_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); undo_redo->add_do_method(this, "emit_signal", "polygons_changed"); for (unsigned int i = 0; i < polygons.size(); i++) { undo_redo->add_undo_method(this, "set_polygon", polygons[i]); } - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->add_undo_method(this, "emit_signal", "polygons_changed"); undo_redo->commit_action(true); } break; @@ -491,9 +491,9 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_do_method(this, "clear_polygons"); } undo_redo->add_do_method(this, "add_polygon", in_creation_polygon); - undo_redo->add_do_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); undo_redo->add_undo_method(this, "remove_polygon", added); - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->commit_action(false); emit_signal(SNAME("polygons_changed")); } else { @@ -539,8 +539,8 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_do_method(this, "set_polygon", closest_polygon, polygons[closest_polygon]); undo_redo->add_undo_method(this, "set_polygon", closest_polygon, old_polygon); } - undo_redo->add_do_method(base_control, "update"); - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->commit_action(false); emit_signal(SNAME("polygons_changed")); } @@ -549,9 +549,9 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) if (drag_type == DRAG_TYPE_DRAG_POINT) { undo_redo->create_action(TTR("Edit Polygons")); undo_redo->add_do_method(this, "set_polygon", drag_polygon_index, polygons[drag_polygon_index]); - undo_redo->add_do_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); undo_redo->add_undo_method(this, "set_polygon", drag_polygon_index, drag_old_polygon); - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->commit_action(false); emit_signal(SNAME("polygons_changed")); } else if (drag_type == DRAG_TYPE_CREATE_POINT) { @@ -586,8 +586,8 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_do_method(this, "set_polygon", closest_polygon, polygons[closest_polygon]); undo_redo->add_undo_method(this, "set_polygon", closest_polygon, old_polygon); } - undo_redo->add_do_method(base_control, "update"); - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->commit_action(false); emit_signal(SNAME("polygons_changed")); } else { @@ -611,7 +611,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) } } - base_control->update(); + base_control->queue_redraw(); } void GenericTilePolygonEditor::set_use_undo_redo(bool p_use_undo_redo) { @@ -659,7 +659,7 @@ void GenericTilePolygonEditor::set_background(Ref<Texture2D> p_texture, Rect2 p_ background_v_flip = p_flip_v; background_transpose = p_transpose; background_modulate = p_modulate; - base_control->update(); + base_control->queue_redraw(); } int GenericTilePolygonEditor::get_polygon_count() { @@ -672,13 +672,13 @@ int GenericTilePolygonEditor::add_polygon(Vector<Point2> p_polygon, int p_index) if (p_index < 0) { polygons.push_back(p_polygon); - base_control->update(); + base_control->queue_redraw(); button_edit->set_pressed(true); return polygons.size() - 1; } else { polygons.insert(p_index, p_polygon); button_edit->set_pressed(true); - base_control->update(); + base_control->queue_redraw(); return p_index; } } @@ -690,12 +690,12 @@ void GenericTilePolygonEditor::remove_polygon(int p_index) { if (polygons.size() == 0) { button_create->set_pressed(true); } - base_control->update(); + base_control->queue_redraw(); } void GenericTilePolygonEditor::clear_polygons() { polygons.clear(); - base_control->update(); + base_control->queue_redraw(); } void GenericTilePolygonEditor::set_polygon(int p_polygon_index, Vector<Point2> p_polygon) { @@ -703,7 +703,7 @@ void GenericTilePolygonEditor::set_polygon(int p_polygon_index, Vector<Point2> p ERR_FAIL_COND(p_polygon.size() < 3); polygons[p_polygon_index] = p_polygon; button_edit->set_pressed(true); - base_control->update(); + base_control->queue_redraw(); } Vector<Point2> GenericTilePolygonEditor::get_polygon(int p_polygon_index) { @@ -713,7 +713,7 @@ Vector<Point2> GenericTilePolygonEditor::get_polygon(int p_polygon_index) { void GenericTilePolygonEditor::set_polygons_color(Color p_color) { polygon_color = p_color; - base_control->update(); + base_control->queue_redraw(); } void GenericTilePolygonEditor::set_multiple_polygon_mode(bool p_multiple_polygon_mode) { diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 556788f50c..ec406ef9ba 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -351,7 +351,7 @@ void TileMapEditorTilesPlugin::_update_atlas_view() { tile_atlas_view->set_atlas_source(*tile_map->get_tileset(), atlas_source, source_id); TilesEditorPlugin::get_singleton()->synchronize_atlas_view(tile_atlas_view); - tile_atlas_control->update(); + tile_atlas_control->queue_redraw(); } void TileMapEditorTilesPlugin::_update_scenes_collection_view() { @@ -1651,8 +1651,8 @@ void TileMapEditorTilesPlugin::_update_tileset_selection_from_selection_pattern( } } _update_source_display(); - tile_atlas_control->update(); - alternative_tiles_control->update(); + tile_atlas_control->queue_redraw(); + alternative_tiles_control->queue_redraw(); } void TileMapEditorTilesPlugin::_tile_atlas_control_draw() { @@ -1736,7 +1736,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_mouse_exited() { hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_dragging_selection = false; - tile_atlas_control->update(); + tile_atlas_control->queue_redraw(); } void TileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref<InputEvent> &p_event) { @@ -1780,8 +1780,8 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref<InputEven Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - tile_atlas_control->update(); - alternative_tiles_control->update(); + tile_atlas_control->queue_redraw(); + alternative_tiles_control->queue_redraw(); } Ref<InputEventMouseButton> mb = p_event; @@ -1841,7 +1841,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref<InputEven } tile_set_dragging_selection = false; } - tile_atlas_control->update(); + tile_atlas_control->queue_redraw(); } } @@ -1895,7 +1895,7 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_mouse_exited() { hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_dragging_selection = false; - alternative_tiles_control->update(); + alternative_tiles_control->queue_redraw(); } void TileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref<InputEvent> &p_event) { @@ -1938,8 +1938,8 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref<In Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - tile_atlas_control->update(); - alternative_tiles_control->update(); + tile_atlas_control->queue_redraw(); + alternative_tiles_control->queue_redraw(); } Ref<InputEventMouseButton> mb = p_event; @@ -1959,8 +1959,8 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref<In } _update_selection_pattern_from_tileset_tiles_selection(); } - tile_atlas_control->update(); - alternative_tiles_control->update(); + tile_atlas_control->queue_redraw(); + alternative_tiles_control->queue_redraw(); } } @@ -3618,7 +3618,7 @@ void TileMapEditor::_tab_changed(int p_tab_id) { } // Graphical update. - tabs_data[tabs_bar->get_current_tab()].panel->update(); + tabs_data[tabs_bar->get_current_tab()].panel->queue_redraw(); CanvasItemEditor::get_singleton()->update_viewport(); } diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 46093469e3..2aea020902 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -624,8 +624,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataTextureOffsetEditor *tile_data_texture_offset_editor = memnew(TileDataTextureOffsetEditor); tile_data_texture_offset_editor->hide(); tile_data_texture_offset_editor->setup_property_editor(Variant::VECTOR2, "texture_offset"); - tile_data_texture_offset_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_texture_offset_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_texture_offset_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_texture_offset_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors["texture_offset"] = tile_data_texture_offset_editor; } @@ -634,8 +634,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataDefaultEditor *tile_data_modulate_editor = memnew(TileDataDefaultEditor()); tile_data_modulate_editor->hide(); tile_data_modulate_editor->setup_property_editor(Variant::COLOR, "modulate", "", Color(1.0, 1.0, 1.0, 1.0)); - tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors["modulate"] = tile_data_modulate_editor; } @@ -644,8 +644,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataDefaultEditor *tile_data_z_index_editor = memnew(TileDataDefaultEditor()); tile_data_z_index_editor->hide(); tile_data_z_index_editor->setup_property_editor(Variant::INT, "z_index"); - tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors["z_index"] = tile_data_z_index_editor; } @@ -654,8 +654,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataYSortEditor *tile_data_y_sort_editor = memnew(TileDataYSortEditor); tile_data_y_sort_editor->hide(); tile_data_y_sort_editor->setup_property_editor(Variant::INT, "y_sort_origin"); - tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors["y_sort_origin"] = tile_data_y_sort_editor; } @@ -665,8 +665,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataOcclusionShapeEditor *tile_data_occlusion_shape_editor = memnew(TileDataOcclusionShapeEditor()); tile_data_occlusion_shape_editor->hide(); tile_data_occlusion_shape_editor->set_occlusion_layer(i); - tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors[vformat("occlusion_layer_%d", i)] = tile_data_occlusion_shape_editor; } } @@ -680,8 +680,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { if (!tile_data_editors.has("terrain_set")) { TileDataTerrainsEditor *tile_data_terrains_editor = memnew(TileDataTerrainsEditor); tile_data_terrains_editor->hide(); - tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors["terrain_set"] = tile_data_terrains_editor; } @@ -691,8 +691,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataDefaultEditor *tile_data_probability_editor = memnew(TileDataDefaultEditor()); tile_data_probability_editor->hide(); tile_data_probability_editor->setup_property_editor(Variant::FLOAT, "probability", "", 1.0); - tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors["probability"] = tile_data_probability_editor; } @@ -704,8 +704,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataCollisionEditor *tile_data_collision_editor = memnew(TileDataCollisionEditor()); tile_data_collision_editor->hide(); tile_data_collision_editor->set_physics_layer(i); - tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors[vformat("physics_layer_%d", i)] = tile_data_collision_editor; } } @@ -722,8 +722,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataNavigationEditor *tile_data_navigation_editor = memnew(TileDataNavigationEditor()); tile_data_navigation_editor->hide(); tile_data_navigation_editor->set_navigation_layer(i); - tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors[vformat("navigation_layer_%d", i)] = tile_data_navigation_editor; } } @@ -744,8 +744,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataDefaultEditor *tile_data_custom_data_editor = memnew(TileDataDefaultEditor()); tile_data_custom_data_editor->hide(); tile_data_custom_data_editor->setup_property_editor(tile_set->get_custom_data_layer_type(i), vformat("custom_data_%d", i), tile_set->get_custom_data_layer_name(i)); - tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors[vformat("custom_data_%d", i)] = tile_data_custom_data_editor; } } @@ -872,10 +872,10 @@ void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed() { void TileSetAtlasSourceEditor::_tile_data_editors_tree_selected() { tile_data_editors_popup->call_deferred(SNAME("hide")); _update_current_tile_data_editor(); - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); } void TileSetAtlasSourceEditor::_update_atlas_view() { @@ -923,11 +923,11 @@ void TileSetAtlasSourceEditor::_update_atlas_view() { tile_atlas_view->set_padding(Side::SIDE_RIGHT, texture_region_base_size_min); // Redraw everything. - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); // Synchronize atlas view. TilesEditorPlugin::get_singleton()->synchronize_atlas_view(tile_atlas_view); @@ -961,14 +961,14 @@ void TileSetAtlasSourceEditor::_update_toolbar() { void TileSetAtlasSourceEditor::_tile_atlas_control_mouse_exited() { hovered_base_tile_coords = TileSetSource::INVALID_ATLAS_COORDS; - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); } void TileSetAtlasSourceEditor::_tile_atlas_view_transform_changed() { - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); } void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEvent> &p_event) { @@ -983,11 +983,11 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven // Update only what's needed. tile_set_changed_needs_update = false; - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); return; } else { // Handle the event. @@ -1132,11 +1132,11 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven } // Redraw for the hovered tile. - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); return; } @@ -1283,11 +1283,11 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven // Left click released. _end_dragging(); } - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); return; } else if (mb->get_button_index() == MouseButton::RIGHT) { // Right click pressed. @@ -1298,11 +1298,11 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven // Right click released. _end_dragging(); } - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); return; } } @@ -1872,20 +1872,20 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Ref<In if (current_tile_data_editor) { current_tile_data_editor->forward_painting_alternatives_gui_input(tile_atlas_view, tile_set_atlas_source, p_event); } - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); return; } Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); if (drag_type == DRAG_TYPE_MAY_POPUP_MENU) { if (Vector2(drag_start_mouse_pos).distance_to(alternative_tiles_control->get_local_mouse_position()) > 5.0 * EDSCALE) { @@ -1942,19 +1942,19 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Ref<In drag_type = DRAG_TYPE_NONE; } } - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); } } void TileSetAtlasSourceEditor::_tile_alternatives_control_mouse_exited() { hovered_alternative_tile_coords = Vector3i(TileSetSource::INVALID_ATLAS_COORDS.x, TileSetSource::INVALID_ATLAS_COORDS.y, TileSetSource::INVALID_TILE_ALTERNATIVE); - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); } void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() { diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 83341b3016..2fb8bbe86b 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -6263,7 +6263,7 @@ void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, Visua type = p_type; port = p_port; node = p_node; - update(); + queue_redraw(); _shader_changed(); } diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index cdd088f0b1..83275a2a7b 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -41,9 +41,7 @@ const int ERROR_CODE = 77; #include "core/os/time.h" #include "core/templates/hash_map.h" #include "core/templates/list.h" - -const uint64_t CONVERSION_MAX_FILE_SIZE_MB = 4; -const uint64_t CONVERSION_MAX_FILE_SIZE = 1024 * 1024 * CONVERSION_MAX_FILE_SIZE_MB; +#include "core/templates/local_vector.h" static const char *enum_renames[][2] = { //// constants @@ -230,7 +228,6 @@ static const char *gdscript_function_renames[][2] = { { "add_stylebox_override", "add_theme_stylebox_override" }, // Control { "add_torque", "apply_torque" }, //RigidBody2D { "apply_changes", "_apply_changes" }, // EditorPlugin - { "bind_child_node_to_bone", "set_bone_children" }, // Skeleton3D { "body_add_force", "body_apply_force" }, // PhysicsServer2D { "body_add_torque", "body_apply_torque" }, // PhysicsServer2D { "bumpmap_to_normalmap", "bump_map_to_normal_map" }, // Image @@ -298,11 +295,11 @@ static const char *gdscript_function_renames[][2] = { { "get_d", "get_distance" }, // LineShape2D { "get_drag_data", "_get_drag_data" }, // Control { "get_drag_data_fw", "_get_drag_data_fw" }, // ScriptEditor - { "get_editor_description", "_get_editor_description" }, // Node { "get_editor_viewport", "get_viewport" }, // EditorPlugin { "get_enabled_focus_mode", "get_focus_mode" }, // BaseButton { "get_endian_swap", "is_big_endian" }, // File { "get_error_string", "get_error_message" }, // JSON + { "get_filename", "get_scene_file_path" }, // Node, WARNING, this may be used in a lot of other places { "get_focus_neighbour", "get_focus_neighbor" }, // Control { "get_font_types", "get_font_type_list" }, // Theme { "get_frame_color", "get_color" }, // ColorRect @@ -398,7 +395,6 @@ static const char *gdscript_function_renames[][2] = { { "has_stylebox_override", "has_theme_stylebox_override" }, // Control { "http_escape", "uri_encode" }, // String { "http_unescape", "uri_decode" }, // String - { "import_animation_from_other_importer", "_import_animation" }, //EditorSceneFormatImporter { "import_scene_from_other_importer", "_import_scene" }, //EditorSceneFormatImporter { "instance_set_surface_material", "instance_set_surface_override_material" }, // RenderingServer { "intersect_polygons_2d", "intersect_polygons" }, // Geometry2D @@ -546,7 +542,6 @@ static const char *gdscript_function_renames[][2] = { { "targeting_property", "tween_property" }, // Tween { "track_remove_key_at_position", "track_remove_key_at_time" }, // Animation { "triangulate_delaunay_2d", "triangulate_delaunay" }, // Geometry2D - { "unbind_child_node_from_bone", "remove_bone_child" }, // Skeleton3D { "unselect", "deselect" }, // ItemList { "unselect_all", "deselect_all" }, // ItemList { "update_configuration_warning", "update_configuration_warnings" }, // Node @@ -555,6 +550,7 @@ static const char *gdscript_function_renames[][2] = { { "warp_mouse_position", "warp_mouse" }, // Input // Builtin types + // Remember to add them to builtin_types_excluded_functions variable, because for now this functions cannot be listed // { "empty", "is_empty" }, // Array - Used as custom rule // Be careful, this will be used everywhere { "clamped", "clamp" }, // Vector2 // Be careful, this will be used everywhere { "get_rotation_quat", "get_rotation_quaternion" }, // Basis @@ -568,6 +564,7 @@ static const char *gdscript_function_renames[][2] = { { "to_wchar", "to_utf32_buffer" }, // String // TODO - utf32 or utf16? // @GlobalScope + // Remember to add them to builtin_types_excluded_functions variable, because for now this functions cannot be listed { "bytes2var", "bytes_to_var" }, { "bytes2var_with_objects", "bytes_to_var_with_objects" }, { "db2linear", "db_to_linear" }, @@ -582,6 +579,7 @@ static const char *gdscript_function_renames[][2] = { { "var2bytes_with_objects", "var_to_bytes_with_objects" }, // @GDScript + // Remember to add them to builtin_types_excluded_functions variable, because for now this functions cannot be listed { "dict2inst", "dict_to_inst" }, { "inst2dict", "inst_to_dict" }, @@ -1057,6 +1055,14 @@ static const char *gdscript_properties_renames[][2] = { { "pause_mode", "process_mode" }, // Node { "physical_scancode", "physical_keycode" }, // InputEventKey { "popup_exclusive", "exclusive" }, // Window + { "rect_position", "position" }, // Control + { "rect_global_position", "global_position" }, // Control + { "rect_size", "size" }, // Control + { "rect_min_size", "minimum_size" }, // Control + { "rect_rotation", "rotation" }, // Control + { "rect_scale", "scale" }, // Control + { "rect_pivot_offset", "pivot_offset" }, // Control + { "rect_clip_content", "clip_contents" }, // Control { "refuse_new_network_connections", "refuse_new_connections" }, // MultiplayerAPI { "region_filter_clip", "region_filter_clip_enabled" }, // Sprite2D { "selectedframe", "selected_frame" }, // Theme @@ -1271,9 +1277,19 @@ static const char *builtin_types_renames[][2] = { static const char *shaders_renames[][2] = { { "ALPHA_SCISSOR", "ALPHA_SCISSOR_THRESHOLD" }, + { "CAMERA_MATRIX", "INV_VIEW_MATRIX" }, + { "INV_CAMERA_MATRIX", "VIEW_MATRIX" }, { "NORMALMAP", "NORMAL_MAP" }, { "NORMALMAP_DEPTH", "NORMAL_MAP_DEPTH" }, - { "TRANSMISSION", "SSS_TRANSMITTANCE_COLOR" }, + { "TRANSMISSION", "BACKLIGHT" }, + { "WORLD_MATRIX", "MODEL_MATRIX" }, + { "depth_draw_alpha_prepass", "depth_draw_opaque" }, + { "hint_albedo", "source_color" }, + { "hint_aniso", "hint_anisotropy" }, + { "hint_black", "hint_default_black" }, + { "hint_black_albedo", "hint_default_black" }, + { "hint_color", "source_color" }, + { "hint_white", "hint_default_white" }, { nullptr, nullptr }, }; @@ -1494,7 +1510,7 @@ static const char *class_renames[][2] = { }; // TODO - this colors needs to be validated(not all are valid) -static const char *colors_renames[][2] = { +static const char *color_renames[][2] = { { "aliceblue", "ALICE_BLUE" }, { "antiquewhite", "ANTIQUE_WHITE" }, { "aqua", "AQUA" }, @@ -1647,6 +1663,7 @@ static const char *colors_renames[][2] = { class ProjectConverter3To4::RegExContainer { public: + // Custom GDScript RegEx reg_is_empty = RegEx("\\bempty\\("); RegEx reg_super = RegEx("([\t ])\\.([a-zA-Z_])"); RegEx reg_json_to = RegEx("\\bto_json\\b"); @@ -1658,24 +1675,196 @@ public: 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]+)"); RegEx reg_instantiate = RegEx("\\.instance\\(([^\\)]*)\\)"); + + // GDScript keywords + RegEx keyword_gdscript_tool = RegEx("^tool"); + RegEx keyword_gdscript_export_single = RegEx("^export"); + RegEx keyword_gdscript_export_mutli = RegEx("([\t]+)export\\b"); + RegEx keyword_gdscript_onready = RegEx("^onready"); + RegEx keyword_gdscript_remote = RegEx("^remote func"); + RegEx keyword_gdscript_remotesync = RegEx("^remotesync func"); + RegEx keyword_gdscript_sync = RegEx("^sync func"); + RegEx keyword_gdscript_slave = RegEx("^slave func"); + RegEx keyword_gdscript_puppet = RegEx("^puppet func"); + RegEx keyword_gdscript_puppetsync = RegEx("^puppetsync func"); + RegEx keyword_gdscript_master = RegEx("^master func"); + RegEx keyword_gdscript_mastersync = RegEx("^mastersync func"); + + // CSharp keywords + RegEx keyword_csharp_remote = RegEx("\\[Remote(Attribute)?(\\(\\))?\\]"); + RegEx keyword_csharp_remotesync = RegEx("\\[(Remote)?Sync(Attribute)?(\\(\\))?\\]"); + RegEx keyword_csharp_puppet = RegEx("\\[(Puppet|Slave)(Attribute)?(\\(\\))?\\]"); + RegEx keyword_csharp_puppetsync = RegEx("\\[PuppetSync(Attribute)?(\\(\\))?\\]"); + RegEx keyword_csharp_master = RegEx("\\[Master(Attribute)?(\\(\\))?\\]"); + RegEx keyword_csharp_mastersync = RegEx("\\[MasterSync(Attribute)?(\\(\\))?\\]"); + + // Colors + LocalVector<RegEx *> color_regexes; + LocalVector<String> color_renamed; + + // Classes + LocalVector<RegEx *> class_tscn_regexes; + LocalVector<RegEx *> class_gd_regexes; + LocalVector<RegEx *> class_shader_regexes; + + LocalVector<RegEx *> class_regexes; + + RegEx class_temp_tscn = RegEx("\\bTEMP_RENAMED_CLASS.tscn\\b"); + RegEx class_temp_gd = RegEx("\\bTEMP_RENAMED_CLASS.gd\\b"); + RegEx class_temp_shader = RegEx("\\bTEMP_RENAMED_CLASS.shader\\b"); + + LocalVector<String> class_temp_tscn_renames; + LocalVector<String> class_temp_gd_renames; + LocalVector<String> class_temp_shader_renames; + + // Common + LocalVector<RegEx *> enum_regexes; + LocalVector<RegEx *> gdscript_function_regexes; + LocalVector<RegEx *> project_settings_regexes; + LocalVector<RegEx *> gdscript_properties_regexes; + LocalVector<RegEx *> gdscript_signals_regexes; + LocalVector<RegEx *> shaders_regexes; + LocalVector<RegEx *> builtin_types_regexes; + LocalVector<RegEx *> csharp_function_regexes; + LocalVector<RegEx *> csharp_properties_regexes; + LocalVector<RegEx *> csharp_signal_regexes; + + RegExContainer() { + // Common + { + // Enum + for (unsigned int current_index = 0; enum_renames[current_index][0]; current_index++) { + enum_regexes.push_back(memnew(RegEx(String("\\b") + enum_renames[current_index][0] + "\\b"))); + } + // GDScript functions + for (unsigned int current_index = 0; gdscript_function_renames[current_index][0]; current_index++) { + gdscript_function_regexes.push_back(memnew(RegEx(String("\\b") + gdscript_function_renames[current_index][0] + "\\b"))); + } + // Project Settings + for (unsigned int current_index = 0; project_settings_renames[current_index][0]; current_index++) { + project_settings_regexes.push_back(memnew(RegEx(String("\\b") + project_settings_renames[current_index][0] + "\\b"))); + } + // GDScript properties + for (unsigned int current_index = 0; gdscript_properties_renames[current_index][0]; current_index++) { + gdscript_properties_regexes.push_back(memnew(RegEx(String("\\b") + gdscript_properties_renames[current_index][0] + "\\b"))); + } + // GDScript Signals + for (unsigned int current_index = 0; gdscript_signals_renames[current_index][0]; current_index++) { + gdscript_signals_regexes.push_back(memnew(RegEx(String("\\b") + gdscript_signals_renames[current_index][0] + "\\b"))); + } + // Shaders + for (unsigned int current_index = 0; shaders_renames[current_index][0]; current_index++) { + shaders_regexes.push_back(memnew(RegEx(String("\\b") + shaders_renames[current_index][0] + "\\b"))); + } + // Builtin types + for (unsigned int current_index = 0; builtin_types_renames[current_index][0]; current_index++) { + builtin_types_regexes.push_back(memnew(RegEx(String("\\b") + builtin_types_renames[current_index][0] + "\\b"))); + } + // CSharp function renames + for (unsigned int current_index = 0; csharp_function_renames[current_index][0]; current_index++) { + csharp_function_regexes.push_back(memnew(RegEx(String("\\b") + csharp_function_renames[current_index][0] + "\\b"))); + } + // CSharp properties renames + for (unsigned int current_index = 0; csharp_properties_renames[current_index][0]; current_index++) { + csharp_properties_regexes.push_back(memnew(RegEx(String("\\b") + csharp_properties_renames[current_index][0] + "\\b"))); + } + // CSharp signals renames + for (unsigned int current_index = 0; csharp_signals_renames[current_index][0]; current_index++) { + csharp_signal_regexes.push_back(memnew(RegEx(String("\\b") + csharp_signals_renames[current_index][0] + "\\b"))); + } + } + + // Colors + { + for (unsigned int current_index = 0; color_renames[current_index][0]; current_index++) { + color_regexes.push_back(memnew(RegEx(String("\\bColor.") + color_renames[current_index][0] + "\\b"))); + color_renamed.push_back(String("Color.") + color_renames[current_index][1]); + } + } + // Classes + { + for (unsigned int current_index = 0; class_renames[current_index][0]; current_index++) { + class_tscn_regexes.push_back(memnew(RegEx(String("\\b") + class_renames[current_index][0] + ".tscn\\b"))); + class_gd_regexes.push_back(memnew(RegEx(String("\\b") + class_renames[current_index][0] + ".gd\\b"))); + class_shader_regexes.push_back(memnew(RegEx(String("\\b") + class_renames[current_index][0] + ".shader\\b"))); + + class_regexes.push_back(memnew(RegEx(String("\\b") + class_renames[current_index][0] + "\\b"))); + + class_temp_tscn_renames.push_back(String(class_renames[current_index][0]) + ".tscn"); + class_temp_gd_renames.push_back(String(class_renames[current_index][0]) + ".gd"); + class_temp_shader_renames.push_back(String(class_renames[current_index][0]) + ".shader"); + } + } + } + ~RegExContainer() { + for (unsigned int i = 0; i < color_regexes.size(); i++) { + memdelete(color_regexes[i]); + } + for (unsigned int i = 0; i < class_tscn_regexes.size(); i++) { + memdelete(class_tscn_regexes[i]); + memdelete(class_gd_regexes[i]); + memdelete(class_shader_regexes[i]); + memdelete(class_regexes[i]); + } + for (unsigned int i = 0; i < enum_regexes.size(); i++) { + memdelete(enum_regexes[i]); + } + for (unsigned int i = 0; i < gdscript_function_regexes.size(); i++) { + memdelete(gdscript_function_regexes[i]); + } + for (unsigned int i = 0; i < project_settings_regexes.size(); i++) { + memdelete(project_settings_regexes[i]); + } + for (unsigned int i = 0; i < gdscript_properties_regexes.size(); i++) { + memdelete(gdscript_properties_regexes[i]); + } + for (unsigned int i = 0; i < gdscript_signals_regexes.size(); i++) { + memdelete(gdscript_signals_regexes[i]); + } + for (unsigned int i = 0; i < shaders_regexes.size(); i++) { + memdelete(shaders_regexes[i]); + } + for (unsigned int i = 0; i < builtin_types_regexes.size(); i++) { + memdelete(builtin_types_regexes[i]); + } + for (unsigned int i = 0; i < csharp_function_regexes.size(); i++) { + memdelete(csharp_function_regexes[i]); + } + for (unsigned int i = 0; i < csharp_properties_regexes.size(); i++) { + memdelete(csharp_properties_regexes[i]); + } + for (unsigned int i = 0; i < csharp_signal_regexes.size(); i++) { + memdelete(csharp_signal_regexes[i]); + } + } }; +ProjectConverter3To4::ProjectConverter3To4(int maximum_file_size_kb, int maximum_line_length) { + this->maximum_file_size = maximum_file_size_kb * 1024; + this->maximum_line_length = maximum_line_length; +} + // Function responsible for converting project int ProjectConverter3To4::convert() { print_line("Starting conversion."); + uint64_t conversion_start_time = Time::get_singleton()->get_ticks_msec(); RegExContainer reg_container = RegExContainer(); + int cached_maximum_line_length = maximum_line_length; + maximum_line_length = 10000; // Use only for tests bigger value, to not break them + 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(reg_container), ERROR_CODE, "Cannot start converting due to problems with converting arrays."); + maximum_line_length = cached_maximum_line_length; + // Checking if folder contains valid Godot 3 project. - // Project cannot be converted 2 times + // Project should not be converted more than 1 times { String conventer_text = "; Project was converted by built-in tool to Godot 4.0"; @@ -1685,7 +1874,7 @@ int ProjectConverter3To4::convert() { String project_godot_content = FileAccess::get_file_as_string("project.godot", &err); ERR_FAIL_COND_V_MSG(err != OK, ERROR_CODE, "Failed to read content of \"project.godot\" file."); - ERR_FAIL_COND_V_MSG(project_godot_content.find(conventer_text) != -1, ERROR_CODE, "Project already was converted with this tool."); + ERR_FAIL_COND_V_MSG(project_godot_content.contains(conventer_text), ERROR_CODE, "Project already was converted with this tool."); Ref<FileAccess> file = FileAccess::open("project.godot", FileAccess::WRITE); ERR_FAIL_COND_V_MSG(file.is_null(), ERROR_CODE, "Failed to open project.godot file."); @@ -1700,11 +1889,19 @@ int ProjectConverter3To4::convert() { // Check file by file for (int i = 0; i < collected_files.size(); i++) { String file_name = collected_files[i]; - Error err = OK; - String file_content = FileAccess::get_file_as_string(file_name, &err); - ERR_CONTINUE_MSG(err != OK, "Failed to read content of \"" + file_name + "\"."); - uint64_t hash_before = file_content.hash64(); - uint64_t file_size = file_content.size(); + Vector<String> lines; + uint32_t ignored_lines = 0; + { + Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::READ); + ERR_CONTINUE_MSG(file.is_null(), "Failed to read content of \"" + file_name + "\"."); + while (!file->eof_reached()) { + String line = file->get_line(); + lines.append(line); + } + } + String file_content_before = collect_string_from_vector(lines); + uint64_t hash_before = file_content_before.hash(); + uint64_t file_size = file_content_before.size(); print_line("Trying to convert\t" + itos(i + 1) + "/" + itos(collected_files.size()) + " file - \"" + file_name.trim_prefix("res://") + "\" with size - " + itos(file_size / 1024) + " KB"); Vector<String> reason; @@ -1716,78 +1913,87 @@ int ProjectConverter3To4::convert() { file_name = file_name.replace(".shader", ".gdshader"); } - if (file_size < CONVERSION_MAX_FILE_SIZE) { + if (file_size < uint64_t(maximum_file_size)) { // TSCN must be the same work exactly same as .gd file because it may contains builtin script if (file_name.ends_with(".gd")) { - rename_classes(file_content); // Using only specialized function + rename_classes(lines, reg_container); // Using only specialized function - rename_common(enum_renames, file_content); - rename_enums(file_content); // Require to additional rename + rename_common(enum_renames, reg_container.enum_regexes, lines); + rename_colors(lines, reg_container); // Require to additional rename - rename_common(gdscript_function_renames, file_content); - rename_gdscript_functions(file_content, reg_container, false); // Require to additional rename + rename_common(gdscript_function_renames, reg_container.gdscript_function_regexes, lines); + rename_gdscript_functions(lines, reg_container, false); // Require to additional rename - rename_common(project_settings_renames, file_content); - rename_gdscript_keywords(file_content); - rename_common(gdscript_properties_renames, file_content); - rename_common(gdscript_signals_renames, file_content); - rename_common(shaders_renames, file_content); - rename_common(builtin_types_renames, file_content); + rename_common(project_settings_renames, reg_container.project_settings_regexes, lines); + rename_gdscript_keywords(lines, reg_container); + rename_common(gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines); + rename_common(gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines); + rename_common(shaders_renames, reg_container.shaders_regexes, lines); + rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines); - custom_rename(file_content, "\\.shader", ".gdshader"); + custom_rename(lines, "\\.shader", ".gdshader"); } else if (file_name.ends_with(".tscn")) { - rename_classes(file_content); // Using only specialized function + rename_classes(lines, reg_container); // Using only specialized function - rename_common(enum_renames, file_content); - rename_enums(file_content); // Require to additional rename + rename_common(enum_renames, reg_container.enum_regexes, lines); + rename_colors(lines, reg_container); // Require to additional rename - rename_common(gdscript_function_renames, file_content); - rename_gdscript_functions(file_content, reg_container, true); // Require to additional rename + rename_common(gdscript_function_renames, reg_container.gdscript_function_regexes, lines); + rename_gdscript_functions(lines, reg_container, true); // Require to additional rename - rename_common(project_settings_renames, file_content); - rename_gdscript_keywords(file_content); - rename_common(gdscript_properties_renames, file_content); - rename_common(gdscript_signals_renames, file_content); - rename_common(shaders_renames, file_content); - rename_common(builtin_types_renames, file_content); + rename_common(project_settings_renames, reg_container.project_settings_regexes, lines); + rename_gdscript_keywords(lines, reg_container); + rename_common(gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines); + rename_common(gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines); + rename_common(shaders_renames, reg_container.shaders_regexes, lines); + rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines); - custom_rename(file_content, "\\.shader", ".gdshader"); + custom_rename(lines, "\\.shader", ".gdshader"); } else if (file_name.ends_with(".cs")) { // TODO, C# should use different methods - rename_classes(file_content); // Using only specialized function - rename_common(csharp_function_renames, file_content); - rename_common(builtin_types_renames, file_content); - rename_common(csharp_properties_renames, file_content); - rename_common(csharp_signals_renames, file_content); - rename_csharp_functions(file_content); - rename_csharp_attributes(file_content); - custom_rename(file_content, "public class ", "public partial class "); + rename_classes(lines, reg_container); // Using only specialized function + rename_common(csharp_function_renames, reg_container.csharp_function_regexes, lines); + rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines); + rename_common(csharp_properties_renames, reg_container.csharp_properties_regexes, lines); + rename_common(csharp_signals_renames, reg_container.csharp_signal_regexes, lines); + rename_csharp_functions(lines, reg_container); + rename_csharp_attributes(lines, reg_container); + custom_rename(lines, "public class ", "public partial class "); } else if (file_name.ends_with(".gdshader") || file_name.ends_with(".shader")) { - rename_common(shaders_renames, file_content); + rename_common(shaders_renames, reg_container.shaders_regexes, lines); } else if (file_name.ends_with("tres")) { - rename_classes(file_content); // Using only specialized function + rename_classes(lines, reg_container); // Using only specialized function - rename_common(shaders_renames, file_content); - rename_common(builtin_types_renames, file_content); + rename_common(shaders_renames, reg_container.shaders_regexes, lines); + rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines); - custom_rename(file_content, "\\.shader", ".gdshader"); + custom_rename(lines, "\\.shader", ".gdshader"); } else if (file_name.ends_with("project.godot")) { - rename_common(project_settings_renames, file_content); - rename_common(builtin_types_renames, file_content); + rename_common(project_settings_renames, reg_container.project_settings_regexes, lines); + rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines); } else if (file_name.ends_with(".csproj")) { // TODO } else { ERR_PRINT(file_name + " is not supported!"); continue; } + + for (String &line : lines) { + if (uint64_t(line.length()) > maximum_line_length) { + ignored_lines += 1; + } + } } else { - reason.append(" ERROR: File has exceeded the maximum size allowed - " + itos(CONVERSION_MAX_FILE_SIZE_MB) + " MB"); + reason.append(" ERROR: File has exceeded the maximum size allowed - " + itos(maximum_file_size / 1024) + " KB"); is_ignored = true; } uint64_t end_time = Time::get_singleton()->get_ticks_msec(); - - if (!is_ignored) { - uint64_t hash_after = file_content.hash64(); + if (is_ignored) { + String end_message = " Checking file took " + itos(end_time - start_time) + " ms."; + print_line(end_message); + } else { + String file_content_after = collect_string_from_vector(lines); + uint64_t hash_after = file_content_after.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.ends_with(".gdshader")) { @@ -1795,11 +2001,14 @@ int ProjectConverter3To4::convert() { Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::WRITE); ERR_CONTINUE_MSG(file.is_null(), "Failed to open \"" + file_name + "\" to save data to file."); - file->store_string(file_content); + file->store_string(file_content_after); reason.append(" File was changed, conversion took " + itos(end_time - start_time) + " ms."); } else { reason.append(" File was not changed, checking took " + itos(end_time - start_time) + " ms."); } + if (ignored_lines != 0) { + reason.append(" Ignored " + itos(ignored_lines) + " lines, because their length exceeds maximum allowed characters - " + itos(maximum_line_length)); + } } for (int k = 0; k < reason.size(); k++) { print_line(reason[k]); @@ -1807,20 +2016,28 @@ int ProjectConverter3To4::convert() { } print_line("Conversion ended - all files(" + itos(collected_files.size()) + "), converted files(" + itos(converted_files) + "), not converted files(" + itos(collected_files.size() - converted_files) + ")."); + uint64_t conversion_end_time = Time::get_singleton()->get_ticks_msec(); + print_line("Conversion of all files took " + itos(conversion_end_time - conversion_start_time) + " ms."); return 0; }; // Function responsible for validating project conversion. int ProjectConverter3To4::validate_conversion() { print_line("Starting checking if project conversion can be done."); + uint64_t conversion_start_time = Time::get_singleton()->get_ticks_msec(); RegExContainer reg_container = RegExContainer(); + int cached_maximum_line_length = maximum_line_length; + maximum_line_length = 10000; // Use only for tests bigger value, to not break them + 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(reg_container), ERROR_CODE, "Cannot start converting due to problems with converting arrays."); + maximum_line_length = cached_maximum_line_length; + // Checking if folder contains valid Godot 3 project. - // Project cannot be converted 2 times + // Project should not be converted more than 1 times { String conventer_text = "; Project was converted by built-in tool to Godot 4.0"; @@ -1830,7 +2047,7 @@ int ProjectConverter3To4::validate_conversion() { String project_godot_content = FileAccess::get_file_as_string("project.godot", &err); ERR_FAIL_COND_V_MSG(err != OK, ERROR_CODE, "Failed to read content of \"project.godot\" file."); - ERR_FAIL_COND_V_MSG(project_godot_content.find(conventer_text) != -1, ERROR_CODE, "Project already was converted with this tool."); + ERR_FAIL_COND_V_MSG(project_godot_content.contains(conventer_text), ERROR_CODE, "Project already was converted with this tool."); } Vector<String> collected_files = check_for_files(); @@ -1840,7 +2057,8 @@ int ProjectConverter3To4::validate_conversion() { // Check file by file for (int i = 0; i < collected_files.size(); i++) { String file_name = collected_files[i]; - Vector<String> file_content; + Vector<String> lines; + uint32_t ignored_lines = 0; uint64_t file_size = 0; { Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::READ); @@ -1848,7 +2066,7 @@ int ProjectConverter3To4::validate_conversion() { while (!file->eof_reached()) { String line = file->get_line(); file_size += line.size(); - file_content.append(line); + lines.append(line); } } print_line("Checking for conversion - " + itos(i + 1) + "/" + itos(collected_files.size()) + " file - \"" + file_name.trim_prefix("res://") + "\" with size - " + itos(file_size / 1024) + " KB"); @@ -1862,75 +2080,85 @@ int ProjectConverter3To4::validate_conversion() { reason.append("\tFile extension will be renamed from `shader` to `gdshader`."); } - if (file_size < CONVERSION_MAX_FILE_SIZE) { + if (file_size < uint64_t(maximum_file_size)) { if (file_name.ends_with(".gd")) { - changed_elements.append_array(check_for_rename_classes(file_content)); + changed_elements.append_array(check_for_rename_classes(lines, reg_container)); - changed_elements.append_array(check_for_rename_common(enum_renames, file_content)); - changed_elements.append_array(check_for_rename_enums(file_content)); + changed_elements.append_array(check_for_rename_common(enum_renames, reg_container.enum_regexes, lines)); + changed_elements.append_array(check_for_rename_colors(lines, reg_container)); - changed_elements.append_array(check_for_rename_common(gdscript_function_renames, file_content)); - changed_elements.append_array(check_for_rename_gdscript_functions(file_content, reg_container, false)); + changed_elements.append_array(check_for_rename_common(gdscript_function_renames, reg_container.gdscript_function_regexes, lines)); + changed_elements.append_array(check_for_rename_gdscript_functions(lines, 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)); - changed_elements.append_array(check_for_rename_common(gdscript_properties_renames, file_content)); - changed_elements.append_array(check_for_rename_common(gdscript_signals_renames, file_content)); - changed_elements.append_array(check_for_rename_common(shaders_renames, file_content)); - changed_elements.append_array(check_for_rename_common(builtin_types_renames, file_content)); + changed_elements.append_array(check_for_rename_common(project_settings_renames, reg_container.project_settings_regexes, lines)); + changed_elements.append_array(check_for_rename_gdscript_keywords(lines, reg_container)); + changed_elements.append_array(check_for_rename_common(gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines)); + changed_elements.append_array(check_for_rename_common(gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines)); + changed_elements.append_array(check_for_rename_common(shaders_renames, reg_container.shaders_regexes, lines)); + changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines)); - changed_elements.append_array(check_for_custom_rename(file_content, "\\.shader", ".gdshader")); + changed_elements.append_array(check_for_custom_rename(lines, "\\.shader", ".gdshader")); } else if (file_name.ends_with(".tscn")) { - changed_elements.append_array(check_for_rename_classes(file_content)); + changed_elements.append_array(check_for_rename_classes(lines, reg_container)); - changed_elements.append_array(check_for_rename_common(enum_renames, file_content)); - changed_elements.append_array(check_for_rename_enums(file_content)); + changed_elements.append_array(check_for_rename_common(enum_renames, reg_container.enum_regexes, lines)); + changed_elements.append_array(check_for_rename_colors(lines, reg_container)); - changed_elements.append_array(check_for_rename_common(gdscript_function_renames, file_content)); - changed_elements.append_array(check_for_rename_gdscript_functions(file_content, reg_container, true)); + changed_elements.append_array(check_for_rename_common(gdscript_function_renames, reg_container.gdscript_function_regexes, lines)); + changed_elements.append_array(check_for_rename_gdscript_functions(lines, 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)); - changed_elements.append_array(check_for_rename_common(gdscript_properties_renames, file_content)); - changed_elements.append_array(check_for_rename_common(gdscript_signals_renames, file_content)); - changed_elements.append_array(check_for_rename_common(shaders_renames, file_content)); - changed_elements.append_array(check_for_rename_common(builtin_types_renames, file_content)); + changed_elements.append_array(check_for_rename_common(project_settings_renames, reg_container.project_settings_regexes, lines)); + changed_elements.append_array(check_for_rename_gdscript_keywords(lines, reg_container)); + changed_elements.append_array(check_for_rename_common(gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines)); + changed_elements.append_array(check_for_rename_common(gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines)); + changed_elements.append_array(check_for_rename_common(shaders_renames, reg_container.shaders_regexes, lines)); + changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines)); - changed_elements.append_array(check_for_custom_rename(file_content, "\\.shader", ".gdshader")); + changed_elements.append_array(check_for_custom_rename(lines, "\\.shader", ".gdshader")); } else if (file_name.ends_with(".cs")) { - changed_elements.append_array(check_for_rename_common(class_renames, file_content)); - changed_elements.append_array(check_for_rename_common(csharp_function_renames, file_content)); - changed_elements.append_array(check_for_rename_common(builtin_types_renames, file_content)); - changed_elements.append_array(check_for_rename_common(csharp_properties_renames, file_content)); - changed_elements.append_array(check_for_rename_common(csharp_signals_renames, file_content)); - changed_elements.append_array(check_for_rename_csharp_functions(file_content)); - changed_elements.append_array(check_for_rename_csharp_attributes(file_content)); - changed_elements.append_array(check_for_custom_rename(file_content, "public class ", "public partial class ")); + changed_elements.append_array(check_for_rename_classes(lines, reg_container)); + changed_elements.append_array(check_for_rename_common(csharp_function_renames, reg_container.csharp_function_regexes, lines)); + changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines)); + changed_elements.append_array(check_for_rename_common(csharp_properties_renames, reg_container.csharp_properties_regexes, lines)); + changed_elements.append_array(check_for_rename_common(csharp_signals_renames, reg_container.csharp_signal_regexes, lines)); + changed_elements.append_array(check_for_rename_csharp_functions(lines, reg_container)); + changed_elements.append_array(check_for_rename_csharp_attributes(lines, reg_container)); + changed_elements.append_array(check_for_custom_rename(lines, "public class ", "public partial class ")); } else if (file_name.ends_with(".gdshader") || file_name.ends_with(".shader")) { - changed_elements.append_array(check_for_rename_common(shaders_renames, file_content)); + changed_elements.append_array(check_for_rename_common(shaders_renames, reg_container.shaders_regexes, lines)); } else if (file_name.ends_with("tres")) { - changed_elements.append_array(check_for_rename_classes(file_content)); + changed_elements.append_array(check_for_rename_classes(lines, reg_container)); - changed_elements.append_array(check_for_rename_common(shaders_renames, file_content)); - changed_elements.append_array(check_for_rename_common(builtin_types_renames, file_content)); + changed_elements.append_array(check_for_rename_common(shaders_renames, reg_container.shaders_regexes, lines)); + changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines)); - changed_elements.append_array(check_for_custom_rename(file_content, "\\.shader", ".gdshader")); + changed_elements.append_array(check_for_custom_rename(lines, "\\.shader", ".gdshader")); } else if (file_name.ends_with("project.godot")) { - changed_elements.append_array(check_for_rename_common(project_settings_renames, file_content)); - changed_elements.append_array(check_for_rename_common(builtin_types_renames, file_content)); + changed_elements.append_array(check_for_rename_common(project_settings_renames, reg_container.project_settings_regexes, lines)); + changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines)); } else if (file_name.ends_with(".csproj")) { // TODO } else { ERR_PRINT(file_name + " is not supported!"); continue; } + + for (String &line : lines) { + if (uint64_t(line.length()) > maximum_line_length) { + ignored_lines += 1; + } + } } else { - reason.append("\tERROR: File has exceeded the maximum size allowed - " + itos(CONVERSION_MAX_FILE_SIZE_MB) + " MB"); + reason.append("\tERROR: File has exceeded the maximum size allowed - " + itos(maximum_file_size / 1024) + " KB"); is_ignored = true; } uint64_t end_time = Time::get_singleton()->get_ticks_msec(); - print_line(" Checking file took " + itos(end_time - start_time) + " ms."); + String end_message = " Checking file took " + itos(end_time - start_time) + " ms."; + if (ignored_lines != 0) { + end_message += " Ignored " + itos(ignored_lines) + " lines, because their length exceeds maximum allowed characters - " + itos(maximum_line_length); + } + print_line(end_message); for (int k = 0; k < reason.size(); k++) { print_line(reason[k]); @@ -1946,6 +2174,8 @@ int ProjectConverter3To4::validate_conversion() { } print_line("Checking for valid conversion ended - all files(" + itos(collected_files.size()) + "), files which would be converted(" + itos(converted_files) + "), files which would not be converted(" + itos(collected_files.size() - converted_files) + ")."); + uint64_t conversion_end_time = Time::get_singleton()->get_ticks_msec(); + print_line("Conversion of all files took " + itos(conversion_end_time - conversion_start_time) + " ms."); return 0; } @@ -1972,14 +2202,14 @@ Vector<String> ProjectConverter3To4::check_for_files() { continue; } if (dir.current_is_dir()) { - directories_to_check.append(current_dir.plus_file(file_name) + "/"); + directories_to_check.append(current_dir.path_join(file_name) + "/"); } else { bool proper_extension = false; if (file_name.ends_with(".gd") || file_name.ends_with(".shader") || file_name.ends_with(".tscn") || file_name.ends_with(".tres") || file_name.ends_with(".godot") || file_name.ends_with(".cs") || file_name.ends_with(".csproj")) proper_extension = true; if (proper_extension) { - collected_files.append(current_dir.plus_file(file_name)); + collected_files.append(current_dir.path_join(file_name)); } } file_name = dir.get_next(); @@ -1991,218 +2221,230 @@ Vector<String> ProjectConverter3To4::check_for_files() { return collected_files; } -bool ProjectConverter3To4::test_conversion_single_additional(String name, String expected, void (ProjectConverter3To4::*func)(String &), String what) { - String got = name; - (this->*func)(got); - if (expected != got) { - ERR_PRINT("Failed to convert " + what + " `" + name + "` to `" + expected + "`, got instead `" + got + "`"); +// Test expected results of gdscript +bool ProjectConverter3To4::test_conversion_gdscript_builtin(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin_script) { + Vector<String> got = name.split("\n"); + (this->*func)(got, reg_container, builtin_script); + String got_str = collect_string_from_vector(got); + if (expected != got_str) { + ERR_PRINT("Failed to convert " + what + " `" + name + "` to `" + expected + "`, got instead `" + got_str + "`"); return false; } 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 + "`"); +bool ProjectConverter3To4::test_conversion_with_regex(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &), String what, const RegExContainer ®_container) { + Vector<String> got = name.split("\n"); + (this->*func)(got, reg_container); + String got_str = collect_string_from_vector(got); + if (expected != got_str) { + ERR_PRINT("Failed to convert " + what + " `" + name + "` to `" + expected + "`, got instead `" + got_str + "`"); 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); - if (expected != got) { - ERR_PRINT("Failed to convert " + what + " `" + name + "` to `" + expected + "`, got instead `" + got + "`"); +bool ProjectConverter3To4::test_conversion_basic(String name, String expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, String what) { + Vector<String> got = name.split("\n"); + rename_common(array, regex_cache, got); + String got_str = collect_string_from_vector(got); + if (expected != got_str) { + ERR_PRINT("Failed to convert " + what + " `" + name + "` to `" + expected + "`, got instead `" + got_str + "`"); return false; } return true; } // Validate if conversions are proper -bool ProjectConverter3To4::test_conversion(const RegExContainer ®_container) { +bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) { bool valid = true; - valid = valid & test_conversion_single_normal("Spatial", "Node3D", class_renames, "class"); + valid = valid & test_conversion_basic("TYPE_REAL", "TYPE_FLOAT", enum_renames, reg_container.enum_regexes, "enum"); - valid = valid & test_conversion_single_normal("TYPE_REAL", "TYPE_FLOAT", enum_renames, "enum"); + valid = valid & test_conversion_basic("can_instance", "can_instantiate", gdscript_function_renames, reg_container.gdscript_function_regexes, "gdscript function"); - valid = valid & test_conversion_single_normal("can_instance", "can_instantiate", gdscript_function_renames, "gdscript function"); + valid = valid & test_conversion_basic("CanInstance", "CanInstantiate", csharp_function_renames, reg_container.csharp_function_regexes, "csharp function"); - valid = valid & test_conversion_single_normal("CanInstance", "CanInstantiate", csharp_function_renames, "csharp function"); + valid = valid & test_conversion_basic("translation", "position", gdscript_properties_renames, reg_container.gdscript_properties_regexes, "gdscript property"); - valid = valid & test_conversion_single_normal("translation", "position", gdscript_properties_renames, "gdscript property"); + valid = valid & test_conversion_basic("Translation", "Position", csharp_properties_renames, reg_container.csharp_properties_regexes, "csharp property"); - valid = valid & test_conversion_single_normal("Translation", "Position", csharp_properties_renames, "csharp property"); + valid = valid & test_conversion_basic("NORMALMAP", "NORMAL_MAP", shaders_renames, reg_container.shaders_regexes, "shader"); - valid = valid & test_conversion_single_normal("NORMALMAP", "NORMAL_MAP", shaders_renames, "shader"); + valid = valid & test_conversion_basic("text_entered", "text_submitted", gdscript_signals_renames, reg_container.gdscript_signals_regexes, "gdscript signal"); - valid = valid & test_conversion_single_normal("text_entered", "text_submitted", gdscript_signals_renames, "gdscript signal"); + valid = valid & test_conversion_basic("TextEntered", "TextSubmitted", csharp_signals_renames, reg_container.csharp_signal_regexes, "csharp signal"); - valid = valid & test_conversion_single_normal("TextEntered", "TextSubmitted", csharp_signals_renames, "csharp signal"); + valid = valid & test_conversion_basic("audio/channel_disable_threshold_db", "audio/buses/channel_disable_threshold_db", project_settings_renames, reg_container.project_settings_regexes, "project setting"); - valid = valid & test_conversion_single_normal("audio/channel_disable_threshold_db", "audio/buses/channel_disable_threshold_db", project_settings_renames, "project setting"); - - valid = valid & test_conversion_single_normal("Transform", "Transform3D", builtin_types_renames, "builtin type"); + valid = valid & test_conversion_basic("Transform", "Transform3D", builtin_types_renames, reg_container.builtin_types_regexes, "builtin type"); // Custom Renames - valid = valid & test_conversion_single_additional("(Connect(A,B,C,D,E,F,G) != OK):", "(Connect(A,new Callable(B,C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp"); - 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("[Remote]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[RemoteSync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[Sync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[Slave]", "[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[Puppet]", "[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[PuppetSync]", "[RPC(CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[Master]", "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[MasterSync]", "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n[RPC(CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - - 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_builtin("\tvar aa = roman(r.move_and_slide( a, b, c, d, e, f )) # Roman", "\tr.set_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\tr.move_and_slide()\n\tvar aa = roman(r.velocity) # 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_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\tr.move_and_slide()\n\tvar aa = roman(r.velocity) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - 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_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_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_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_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"); - valid = valid & test_conversion_single_additional(" onready", " onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\nexport", "\n@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\texport", "\t@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\texport_dialog", "\texport_dialog", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("export", "@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional(" export", " export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - 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\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\nsync func", "\n\n@rpc(any_peer, call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\nslave func", "\n\n@rpc 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("(connect(A,B,C,[D,E],F) != OK):", "(connect(A,Callable(B,C).bind(D,E),F) != 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("func start(A,B):", "func start(A,B):", &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("(tween_method(A,B,C,D,E).foo())", "(tween_method(Callable(A,B),C,D,E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("(tween_method(A,B,C,D,E,[F,G]).foo())", "(tween_method(Callable(A,B).bind(F,G),C,D,E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("(tween_callback(A,B).foo())", "(tween_callback(Callable(A,B)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("(tween_callback(A,B,[C,D]).foo())", "(tween_callback(Callable(A,B).bind(C,D)).foo())", &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"); + valid = valid & test_conversion_with_regex("(Connect(A,B,C,D,E,F,G) != OK):", "(Connect(A,new Callable(B,C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("(Disconnect(A,B,C) != OK):", "(Disconnect(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("(IsConnected(A,B,C) != OK):", "(IsConnected(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename", reg_container); + + valid = valid & test_conversion_with_regex("[Remote]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[RemoteSync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[Sync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[Slave]", "[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[Puppet]", "[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[PuppetSync]", "[RPC(CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[Master]", "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[MasterSync]", "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n[RPC(CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + + valid = valid & test_conversion_gdscript_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_gdscript_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_gdscript_builtin("OS.get_window_safe_area()", "DisplayServer.get_display_safe_area()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("\tvar aa = roman(r.move_and_slide( a, b, c, d, e, f )) # Roman", "\tr.set_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\tr.move_and_slide()\n\tvar aa = roman(r.velocity) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("\tvar aa = roman(r.move_and_slide_with_snap( a, g, b, c, d, e, f )) # Roman", "\tr.set_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\tr.move_and_slide()\n\tvar aa = roman(r.velocity) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_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_gdscript_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_gdscript_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_gdscript_builtin("sort_custom( a , b )", "sort_custom(Callable(a,b))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("func c(var a, var b)", "func c(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_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_gdscript_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_gdscript_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_gdscript_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_gdscript_builtin("\tmtx.lock()", "\tmtx.lock()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("\tmutex.unlock()", "\tmutex.unlock()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_with_regex("extends CSGBox", "extends CSGBox3D", &ProjectConverter3To4::rename_classes, "classes", reg_container); + valid = valid & test_conversion_with_regex("CSGBox", "CSGBox3D", &ProjectConverter3To4::rename_classes, "classes", reg_container); + valid = valid & test_conversion_with_regex("Spatial", "Node3D", &ProjectConverter3To4::rename_classes, "classes", reg_container); + valid = valid & test_conversion_with_regex("Spatial.tscn", "Spatial.tscn", &ProjectConverter3To4::rename_classes, "classes", reg_container); + valid = valid & test_conversion_with_regex("Spatial.gd", "Spatial.gd", &ProjectConverter3To4::rename_classes, "classes", reg_container); + valid = valid & test_conversion_with_regex("Spatial.shader", "Spatial.shader", &ProjectConverter3To4::rename_classes, "classes", reg_container); + valid = valid & test_conversion_with_regex("Spatial.other", "Node3D.other", &ProjectConverter3To4::rename_classes, "classes", reg_container); + + valid = valid & test_conversion_with_regex("\nonready", "\n@onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("onready", "@onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex(" onready", " onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\nexport", "\n@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\texport", "\t@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\texport_dialog", "\texport_dialog", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("export", "@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex(" export", " export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("tool", "@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n tool", "\n tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\ntool", "\n\n@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\nremote func", "\n\n@rpc(any_peer) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\nremotesync func", "\n\n@rpc(any_peer, call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\nsync func", "\n\n@rpc(any_peer, call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\nslave func", "\n\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\npuppet func", "\n\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\npuppetsync func", "\n\n@rpc(call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\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", reg_container); + valid = valid & test_conversion_with_regex("\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", reg_container); + + valid = valid & test_conversion_gdscript_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_gdscript_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_gdscript_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_gdscript_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_gdscript_builtin("get_node(@", "get_node(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("yield(this, \"timeout\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("yield(this, \\\"timeout\\\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, true); + + valid = valid & test_conversion_gdscript_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_gdscript_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_gdscript_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_gdscript_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_gdscript_builtin("export(PackedScene) var mob_scene", "export var mob_scene: PackedScene", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_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_gdscript_builtin("to_json( AA ) szon", "JSON.new().stringify( AA ) szon", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("s to_json", "s JSON.new().stringify", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("AF to_json2", "AF to_json2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_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_gdscript_builtin("empty()", "is_empty()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin(".empty", ".empty", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin(").roman(", ").roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("\t.roman(", "\tsuper.roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin(" .roman(", " super.roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin(".1", ".1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin(" .1", " .1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("'.'", "'.'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("'.a'", "'.a'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("\t._input(_event)", "\tsuper._input(_event)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_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_gdscript_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_gdscript_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_gdscript_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_gdscript_builtin("(connect(A,B,C,[D,E],F) != OK):", "(connect(A,Callable(B,C).bind(D,E),F) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_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_gdscript_builtin("(start(A,B) != OK):", "(start(Callable(A,B)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("func start(A,B):", "func start(A,B):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_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_gdscript_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_gdscript_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_gdscript_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_gdscript_builtin("(tween_method(A,B,C,D,E).foo())", "(tween_method(Callable(A,B),C,D,E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("(tween_method(A,B,C,D,E,[F,G]).foo())", "(tween_method(Callable(A,B).bind(F,G),C,D,E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("(tween_callback(A,B).foo())", "(tween_callback(Callable(A,B)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("(tween_callback(A,B,[C,D]).foo())", "(tween_callback(Callable(A,B).bind(C,D)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("func _init(", "func _init(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_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_gdscript_builtin("q_PackedDataContainer._iter_init(variable1)", "q_PackedDataContainer._iter_init(variable1)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_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_gdscript_builtin("assert(speed < 2)", "assert(speed < 2)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_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_gdscript_builtin("create_from_image(aa, bb)", "create_from_image(aa) #,bb", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_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_gdscript_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_gdscript_builtin("set_cell_item(a, b)", "set_cell_item(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_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_gdscript_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_gdscript_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_gdscript_builtin("PackedStringArray(req_godot).join('.')", "'.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("=PackedStringArray(req_godot).join('.')", "='.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("apply_force(position, impulse)", "apply_force(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("apply_impulse(position, impulse)", "apply_impulse(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("draw_rect(a,b,c,d,e).abc", "draw_rect(a,b,c,d).abc# e) TODOGODOT4 Antialiasing argument is missing", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("get_focus_owner()", "get_viewport().gui_get_focus_owner()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("button.pressed = 1", "button.button_pressed = 1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("button.pressed=1", "button.button_pressed=1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("button.pressed SF", "button.pressed SF", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_with_regex("AAA Color.white AF", "AAA Color.WHITE AF", &ProjectConverter3To4::rename_colors, "custom rename", reg_container); // Custom rule conversion { String from = "instance"; String to = "instantiate"; String name = "AA.instance()"; - String got = "AA.instance()"; + Vector<String> got = String("AA.instance()").split("\n"); String expected = "AA.instantiate()"; custom_rename(got, from, to); - if (got != expected) { - ERR_PRINT("Failed to convert custom rename `" + name + "` to `" + expected + "`, got instead `" + got + "`"); + String got_str = collect_string_from_vector(got); + if (got_str != expected) { + ERR_PRINT("Failed to convert custom rename `" + name + "` to `" + expected + "`, got instead `" + got_str + "`"); } - valid = valid & (got == expected); + valid = valid & (got_str == expected); } // get_object_of_execution @@ -2317,8 +2559,7 @@ bool ProjectConverter3To4::test_array_names() { // Validate if all classes are valid { - int current_index = 0; - while (class_renames[current_index][0]) { + for (unsigned int current_index = 0; class_renames[current_index][0]; current_index++) { const String old_class = class_renames[current_index][0]; const String new_class = class_renames[current_index][1]; @@ -2333,84 +2574,65 @@ bool ProjectConverter3To4::test_array_names() { ERR_PRINT(String("Class `") + new_class + "` doesn't exists in Godot 4.0, so cannot be used in conversion."); valid = false; // This probably should be only a warning, but not 100% sure - this would need to be added to CI } - current_index++; - } - } - - // // TODO To be able to fully work, it needs https://github.com/godotengine/godot/pull/49053 - // // TODO this needs to be changed to hashset when available https://github.com/godotengine/godot-proposals/issues/867, to speedup searchng - // { - // OrderedHashMap<String, bool> all_functions; - - // List<StringName> classes_list; - // ClassDB::get_class_list(&classes_list); - // for (StringName &name_of_class : classes_list) { - // List<MethodInfo> method_list; - // ClassDB::get_method_list(name_of_class, &method_list, true); - // for (MethodInfo &function_data : method_list) { - // if (!all_functions.has(function_data.name)) { - // all_functions.insert(function_data.name, false); - // } - // } - // } - - // for (int type = Variant::Type::NIL + 1; type < Variant::Type::VARIANT_MAX; type++) { - // List<MethodInfo> method_list; - // Variant::get_method_list_by_type(&method_list, Variant::Type(type)); - // for (MethodInfo &function_data : method_list) { - // if (!all_functions.has(function_data.name)) { - // all_functions.insert(function_data.name, false); - // } - // } - // } - - // int current_element = 0; - // while (gdscript_function_renames[current_element][0] != nullptr) { - // if (!all_functions.has(gdscript_function_renames[current_element][1])) { - // ERR_PRINT(String("Missing gdscript function in pair (") + gdscript_function_renames[current_element][0] + " - ===> " + gdscript_function_renames[current_element][1] + " <===)"); - // valid = false; - // } - // // // DEBUG, disable below after tests - // // if (all_functions.has(gdscript_function_renames[current_element][0])) { - // // String used_in_classes = ""; - // // - // // for (StringName &name_of_class : classes_list) { - // // List<MethodInfo> method_list; - // // ClassDB::get_method_list(name_of_class, &method_list, true); - // // for (MethodInfo &function_data : method_list) { - // // if (function_data.name == gdscript_function_renames[current_element][0]) { - // // used_in_classes += String(name_of_class) + ", "; - // // } - // // } - // // } - // // for (int type = Variant::Type::NIL + 1; type < Variant::Type::VARIANT_MAX; type++) { - // // List<MethodInfo> method_list; - // // Variant::get_method_list_by_type(&method_list, Variant::Type(type)); - // // for (MethodInfo &function_data : method_list) { - // // if (function_data.name == gdscript_function_renames[current_element][0]) { - // // used_in_classes += Variant::get_type_name(Variant::Type(type)) + ", "; - // // } - // // } - // // } - // // used_in_classes = used_in_classes.trim_suffix(", "); - // // - // // WARN_PRINT(String("Godot contains function which will be renamed in pair ( ===> ") + gdscript_function_renames[current_element][0] + " <=== - " + gdscript_function_renames[current_element][1] + ") in class " + used_in_classes + " - check for possible invalid rule."); - // // } - // current_element++; - // } - // } + } + } + + { + HashSet<String> all_functions; + + // List of excluded functions from builtin types and global namespace, because currently it is not possible to get list of functions from them + // This will be available when https://github.com/godotengine/godot/pull/49053 or similar will be included into Godot + static const char *builtin_types_excluded_functions[] = { "dict_to_inst", "inst_to_dict", "bytes_to_var", "bytes_to_var_with_objects", "db_to_linear", "deg_to_rad", "linear_to_db", "rad_to_deg", "randf_range", "snapped", "str_to_var", "var_to_str", "var_to_bytes", "var_to_bytes_with_objects", "move_toward", "uri_encode", "uri_decode", "remove_at", "get_rotation_quaternion", "clamp", "grow_side", "is_absolute_path", "is_valid_int", "lerp", "to_ascii_buffer", "to_utf8_buffer", "to_utf32_buffer", "snapped", nullptr }; + for (int current_index = 0; builtin_types_excluded_functions[current_index]; current_index++) { + all_functions.insert(builtin_types_excluded_functions[current_index]); + } + + // for (int type = Variant::Type::NIL + 1; type < Variant::Type::VARIANT_MAX; type++) { + // List<MethodInfo> method_list; + // Variant::get_method_list_by_type(&method_list, Variant::Type(type)); + // for (MethodInfo &function_data : method_list) { + // if (!all_functions.has(function_data.name)) { + // all_functions.insert(function_data.name); + // } + // } + // } + + List<StringName> classes_list; + ClassDB::get_class_list(&classes_list); + for (StringName &name_of_class : classes_list) { + List<MethodInfo> method_list; + ClassDB::get_method_list(name_of_class, &method_list, true); + for (MethodInfo &function_data : method_list) { + if (!all_functions.has(function_data.name)) { + all_functions.insert(function_data.name); + } + } + } + + int current_element = 0; + while (gdscript_function_renames[current_element][0] != nullptr) { + if (!all_functions.has(gdscript_function_renames[current_element][1])) { + ERR_PRINT(String("Missing gdscript function in pair (") + gdscript_function_renames[current_element][0] + " - ===> " + gdscript_function_renames[current_element][1] + " <===)"); + valid = false; + } + current_element++; + } + } + if (!valid) { + ERR_PRINT("Found function which is used in converter, but cannot be found in Godot 4. Rename this element to new name or remove entire rule about it if is obsolete."); + } valid = valid & test_single_array(enum_renames); valid = valid & test_single_array(class_renames, true); valid = valid & test_single_array(gdscript_function_renames, true); valid = valid & test_single_array(csharp_function_renames, true); - valid = valid & test_single_array(gdscript_properties_renames); + valid = valid & test_single_array(gdscript_properties_renames, true); valid = valid & test_single_array(csharp_properties_renames); - valid = valid & test_single_array(shaders_renames); + valid = valid & test_single_array(shaders_renames, true); valid = valid & test_single_array(gdscript_signals_renames); valid = valid & test_single_array(project_settings_renames); valid = valid & test_single_array(builtin_types_renames); - valid = valid & test_single_array(colors_renames); + valid = valid & test_single_array(color_renames); return valid; } @@ -2419,10 +2641,9 @@ bool ProjectConverter3To4::test_array_names() { // Also checks if in name contains spaces at the end or beginning bool ProjectConverter3To4::test_single_array(const char *array[][2], bool ignore_second_check) { bool valid = true; - int current_index = 0; Vector<String> names = Vector<String>(); - while (array[current_index][0]) { + for (unsigned int current_index = 0; array[current_index][0]; current_index++) { if (String(array[current_index][0]).begins_with(" ") || String(array[current_index][0]).ends_with(" ")) { { ERR_PRINT(String("Entry \"") + array[current_index][0] + "\" ends or stars with space."); @@ -2448,7 +2669,6 @@ bool ProjectConverter3To4::test_single_array(const char *array[][2], bool ignore if (!ignore_second_check) { names.append(array[current_index][1]); } - current_index++; } return valid; }; @@ -2458,18 +2678,17 @@ bool ProjectConverter3To4::test_single_array(const char *array[][2], bool ignore Vector<String> ProjectConverter3To4::parse_arguments(const String &line) { Vector<String> parts; int string_size = line.length(); - int current_index = 0; int start_part = 0; // Index of beginning of start par int parts_counter = 0; char32_t previous_character = '\0'; bool is_inside_string = false; // if true, it ignore this 3 characters ( , ) inside string if (line.count("(") != line.count(")")) { - ERR_PRINT("Bug: substring should have equal number of open and close parenthess - `" + line + "`"); + ERR_PRINT("Converter internal bug: substring should have equal number of open and close parenthess in line - `" + line + "`"); return parts; } - while (current_index < string_size) { + for (int current_index = 0; current_index < string_size; current_index++) { char32_t character = line.get(current_index); switch (character) { case '(': { @@ -2514,7 +2733,6 @@ Vector<String> ProjectConverter3To4::parse_arguments(const String &line) { is_inside_string = !is_inside_string; } } - current_index++; previous_character = character; } @@ -2532,9 +2750,8 @@ Vector<String> ProjectConverter3To4::parse_arguments(const String &line) { // Finds latest parenthess owned by function // `function(abc(a,b),DD)):` finds this parenthess `function(abc(a,b),DD => ) <= ):` int ProjectConverter3To4::get_end_parenthess(const String &line) const { - int current_index = 0; int current_state = 0; - while (line.length() > current_index) { + for (int current_index = 0; line.length() > current_index; current_index++) { char32_t character = line.get(current_index); if (character == '(') { current_state++; @@ -2545,7 +2762,6 @@ int ProjectConverter3To4::get_end_parenthess(const String &line) const { return current_index; } } - current_index++; } return -1; } @@ -2647,229 +2863,217 @@ String ProjectConverter3To4::get_object_of_execution(const String &line) const { return line.substr(variable_start, (end - variable_start)); } -void ProjectConverter3To4::rename_enums(String &file_content) { - int current_index = 0; - - // Rename colors - if (file_content.find("Color.") != -1) { - while (colors_renames[current_index][0]) { - RegEx reg = RegEx(String("\\bColor.") + colors_renames[current_index][0] + "\\b"); - CRASH_COND(!reg.is_valid()); - file_content = reg.sub(file_content, String("Color.") + colors_renames[current_index][1], true); - current_index++; +void ProjectConverter3To4::rename_colors(Vector<String> &lines, const RegExContainer ®_container) { + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + if (line.contains("Color.")) { + for (unsigned int current_index = 0; color_renames[current_index][0]; current_index++) { + line = reg_container.color_regexes[current_index]->sub(line, reg_container.color_renamed[current_index], true); + } + } } } }; -Vector<String> ProjectConverter3To4::check_for_rename_enums(Vector<String> &file_content) { - int current_index = 0; - - Vector<String> found_things; +Vector<String> ProjectConverter3To4::check_for_rename_colors(Vector<String> &lines, const RegExContainer ®_container) { + Vector<String> found_renames; - // Rename colors - if (file_content.find("Color.") != -1) { - while (colors_renames[current_index][0]) { - RegEx reg = RegEx(String("\\bColor.") + colors_renames[current_index][0] + "\\b"); - CRASH_COND(!reg.is_valid()); - - int current_line = 1; - for (String &line : file_content) { - TypedArray<RegExMatch> reg_match = reg.search_all(line); - if (reg_match.size() > 0) { - found_things.append(line_formatter(current_line, colors_renames[current_index][0], colors_renames[current_index][1], line)); + int current_line = 1; + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + if (line.contains("Color.")) { + for (unsigned int current_index = 0; color_renames[current_index][0]; current_index++) { + TypedArray<RegExMatch> reg_match = reg_container.color_regexes[current_index]->search_all(line); + if (reg_match.size() > 0) { + found_renames.append(line_formatter(current_line, color_renames[current_index][0], color_renames[current_index][1], line)); + } } - current_line++; } - current_index++; } + current_line++; } - return found_things; + return found_renames; } -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 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"); - CRASH_COND(!reg_before.is_valid()); - file_content = reg_before.sub(file_content, "TEMP_RENAMED_CLASS.tscn", true); - RegEx reg_before2 = RegEx(String("\\b") + class_renames[current_index][0] + ".gd\\b"); - CRASH_COND(!reg_before2.is_valid()); - file_content = reg_before2.sub(file_content, "TEMP_RENAMED_CLASS.gd", true); - RegEx reg_before3 = RegEx(String("\\b") + class_renames[current_index][0] + ".shader\\b"); - CRASH_COND(!reg_before3.is_valid()); - file_content = reg_before3.sub(file_content, "TEMP_RENAMED_CLASS.gd", true); - // End - - RegEx reg = RegEx(String("\\b") + class_renames[current_index][0] + "\\b"); - CRASH_COND(!reg.is_valid()); - file_content = reg.sub(file_content, class_renames[current_index][1], true); - - // Begin renaming workaround `Resource.gd` -> `RefCounter.gd` - RegEx reg_after = RegEx("\\bTEMP_RENAMED_CLASS.tscn\\b"); - CRASH_COND(!reg_after.is_valid()); - file_content = reg_after.sub(file_content, String(class_renames[current_index][0]) + ".tscn", true); - RegEx reg_after2 = RegEx("\\bTEMP_RENAMED_CLASS.gd\\b"); - CRASH_COND(!reg_after2.is_valid()); - file_content = reg_after2.sub(file_content, String(class_renames[current_index][0]) + ".gd", true); - RegEx reg_after3 = RegEx("\\bTEMP_RENAMED_CLASS.gd\\b"); - CRASH_COND(!reg_after3.is_valid()); - file_content = reg_after3.sub(file_content, String(class_renames[current_index][0]) + ".shader", true); - // End - - current_index++; - } - - // OS.get_ticks_msec -> Time.get_ticks_msec - RegEx reg_time1 = RegEx("OS.get_ticks_msec"); - CRASH_COND(!reg_time1.is_valid()); - file_content = reg_time1.sub(file_content, "Time.get_ticks_msec", true); - RegEx reg_time2 = RegEx("OS.get_ticks_usec"); - CRASH_COND(!reg_time2.is_valid()); - file_content = reg_time2.sub(file_content, "Time.get_ticks_usec", true); -}; - -Vector<String> ProjectConverter3To4::check_for_rename_classes(Vector<String> &file_content) { - int current_index = 0; - - Vector<String> found_things; - - while (class_renames[current_index][0]) { - RegEx reg_before = RegEx(String("\\b") + class_renames[current_index][0] + ".tscn\\b"); - CRASH_COND(!reg_before.is_valid()); - RegEx reg_before2 = RegEx(String("\\b") + class_renames[current_index][0] + ".gd\\b"); - CRASH_COND(!reg_before2.is_valid()); - - RegEx reg = RegEx(String("\\b") + class_renames[current_index][0] + "\\b"); - CRASH_COND(!reg.is_valid()); +void ProjectConverter3To4::rename_classes(Vector<String> &lines, const RegExContainer ®_container) { + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + for (unsigned int current_index = 0; class_renames[current_index][0]; current_index++) { + if (line.contains(class_renames[current_index][0])) { + bool found_ignored_items = false; + // Renaming Spatial.tscn to TEMP_RENAMED_CLASS.tscn + if (line.contains(String(class_renames[current_index][0]) + ".")) { + found_ignored_items = true; + line = reg_container.class_tscn_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.tscn", true); + line = reg_container.class_gd_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.gd", true); + line = reg_container.class_shader_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.shader", true); + } - int current_line = 1; - for (String &line : file_content) { - line = reg_before.sub(line, "TEMP_RENAMED_CLASS.tscn", true); - line = reg_before2.sub(line, "TEMP_RENAMED_CLASS.gd", true); + // Causal renaming Spatial -> Node3D + line = reg_container.class_regexes[current_index]->sub(line, class_renames[current_index][1], true); - TypedArray<RegExMatch> reg_match = reg.search_all(line); - if (reg_match.size() > 0) { - found_things.append(line_formatter(current_line, class_renames[current_index][0], class_renames[current_index][1], line)); + // Restore Spatial.tscn from TEMP_RENAMED_CLASS.tscn + if (found_ignored_items) { + line = reg_container.class_temp_tscn.sub(line, reg_container.class_temp_tscn_renames[current_index], true); + line = reg_container.class_temp_gd.sub(line, reg_container.class_temp_gd_renames[current_index], true); + line = reg_container.class_temp_shader.sub(line, reg_container.class_temp_shader_renames[current_index], true); + } + } } - current_line++; } - current_index++; } +}; + +Vector<String> ProjectConverter3To4::check_for_rename_classes(Vector<String> &lines, const RegExContainer ®_container) { + Vector<String> found_renames; - // TODO OS -> TIME int current_line = 1; - RegEx reg_time1 = RegEx("OS.get_ticks_msec"); - CRASH_COND(!reg_time1.is_valid()); - RegEx reg_time2 = RegEx("OS.get_ticks_usec"); - CRASH_COND(!reg_time2.is_valid()); - for (String &line : file_content) { - String old = line; - line = reg_time1.sub(line, "Time.get_ticks_msec", true); - line = reg_time2.sub(line, "Time.get_ticks_usec", true); + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + for (unsigned int current_index = 0; class_renames[current_index][0]; current_index++) { + if (line.contains(class_renames[current_index][0])) { + String old_line = line; + bool found_ignored_items = false; + // Renaming Spatial.tscn to TEMP_RENAMED_CLASS.tscn + if (line.contains(String(class_renames[current_index][0]) + ".")) { + found_ignored_items = true; + line = reg_container.class_tscn_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.tscn", true); + line = reg_container.class_gd_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.gd", true); + line = reg_container.class_shader_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.shader", true); + } - if (old != line) { - found_things.append(simple_line_formatter(current_line, old, line)); + // Causal renaming Spatial -> Node3D + TypedArray<RegExMatch> reg_match = reg_container.class_regexes[current_index]->search_all(line); + if (reg_match.size() > 0) { + found_renames.append(line_formatter(current_line, class_renames[current_index][0], class_renames[current_index][1], old_line)); + } + + // Restore Spatial.tscn from TEMP_RENAMED_CLASS.tscn + if (found_ignored_items) { + line = reg_container.class_temp_tscn.sub(line, reg_container.class_temp_tscn_renames[current_index], true); + line = reg_container.class_temp_gd.sub(line, reg_container.class_temp_gd_renames[current_index], true); + line = reg_container.class_temp_shader.sub(line, reg_container.class_temp_shader_renames[current_index], true); + } + } + } } current_line++; } - return found_things; + return found_renames; } -void ProjectConverter3To4::rename_gdscript_functions(String &file_content, const RegExContainer ®_container, bool builtin) { - Vector<String> lines = file_content.split("\n"); - +void ProjectConverter3To4::rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin) { for (String &line : lines) { - process_gdscript_line(line, reg_container, builtin); - } - - // Collect vector to string - file_content = ""; - for (int i = 0; i < lines.size(); i++) { - file_content += lines[i]; - - if (i != lines.size() - 1) { - file_content += "\n"; + if (uint64_t(line.length()) <= maximum_line_length) { + process_gdscript_line(line, reg_container, builtin); } } }; -Vector<String> ProjectConverter3To4::check_for_rename_gdscript_functions(Vector<String> &file_content, const RegExContainer ®_container, bool builtin) { +Vector<String> ProjectConverter3To4::check_for_rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin) { int current_line = 1; - Vector<String> found_things; + Vector<String> found_renames; - for (String &line : file_content) { - String old_line = line; - process_gdscript_line(line, reg_container, builtin); - if (old_line != line) { - found_things.append(simple_line_formatter(current_line, old_line, line)); + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + String old_line = line; + process_gdscript_line(line, reg_container, builtin); + if (old_line != line) { + found_renames.append(simple_line_formatter(current_line, old_line, line)); + } } } - return found_things; + return found_renames; } + +// TODO, this function should run only on all .gd files and also on lines in tscn files which 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) { + // In this and other functions, reg.sub are used only after checking line with str.contains function which is sometimes few times faster with bigger line lengths + + if ((line.contains(".lock") || line.contains(".unlock")) && !line.contains("mtx") && !line.contains("mutex") && !line.contains("Mutex")) { 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); } - // 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); - // PackedStringArray(req_godot).join('.') -> '.'.join(PackedStringArray(req_godot)) PoolStringArray - line = reg_container.reg_join.sub(line, "$2.join($1)", true); + if (line.contains(".join")) { + line = reg_container.reg_join.sub(line, "$2.join($1)", true); + } // -- empty() -> is_empty() Pool*Array - line = reg_container.reg_is_empty.sub(line, "is_empty(", true); + if (line.contains("empty")) { + line = reg_container.reg_is_empty.sub(line, "is_empty(", 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" + if (line.contains("(") && line.contains(".")) { + line = reg_container.reg_super.sub(line, "$1super.$2", true); // TODO, not sure if possible, but for now this broke String text e.g. "Choosen .gitignore" -> "Choosen super.gitignore" + } // -- 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); + if (line.contains("parse")) { + 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); + } // -- to_json(a) -> JSON.new().stringify(a) Object - line = reg_container.reg_json_to.sub(line, "JSON.new().stringify", true); - + if (line.contains("to_json")) { + line = reg_container.reg_json_to.sub(line, "JSON.new().stringify", true); + } // -- 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); + if (line.contains("parse_json")) { + 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); + } // -- get_node(@ -> get_node( Node - line = line.replace("get_node(@", "get_node("); + if (line.contains("get_node")) { + line = line.replace("get_node(@", "get_node("); + } // export(float) var lifetime = 3.0 -> export var lifetime: float = 3.0 GDScript - line = reg_container.reg_export.sub(line, "export var $2: $1"); + if (line.contains("export")) { + line = reg_container.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_container.reg_export_advanced.sub(line, "export var $2$3 # ($1)"); + if (line.contains("export")) { + line = reg_container.reg_export_advanced.sub(line, "export var $2$3 # ($1)"); + } // 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); + if (line.contains("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 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); + if (line.contains("setget")) { + 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); + } // 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); + if (line.contains("setget")) { + 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); + } // 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); + if (line.contains("window_fullscreen")) { + 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); + } } // Instantiate - line = reg_container.reg_instantiate.sub(line, ".instantiate($1)", true); + if (line.contains("instance")) { + line = reg_container.reg_instantiate.sub(line, ".instantiate($1)", true); + } // -- r.move_and_slide( a, b, c, d, e ) -> r.set_velocity(a) ... r.move_and_slide() KinematicBody - if (line.find("move_and_slide(") != -1) { + if (line.contains(("move_and_slide("))) { int start = line.find("move_and_slide("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -2915,7 +3119,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- r.move_and_slide_with_snap( a, b, c, d, e ) -> r.set_velocity(a) ... r.move_and_slide() KinematicBody - if (line.find("move_and_slide_with_snap(") != -1) { + if (line.contains("move_and_slide_with_snap(")) { int start = line.find("move_and_slide_with_snap("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -2966,7 +3170,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- sort_custom( a , b ) -> sort_custom(Callable( a , b )) Object - if (line.find("sort_custom(") != -1) { + if (line.contains("sort_custom(")) { int start = line.find("sort_custom("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -2978,7 +3182,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- list_dir_begin( ) -> list_dir_begin() Object - if (line.find("list_dir_begin(") != -1) { + if (line.contains("list_dir_begin(")) { int start = line.find("list_dir_begin("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -2987,7 +3191,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- draw_line(1,2,3,4,5) -> draw_line(1,2,3,4) CanvasItem - if (line.find("draw_line(") != -1) { + if (line.contains("draw_line(")) { int start = line.find("draw_line("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -2999,7 +3203,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- func c(var a, var b) -> func c(a, b) - if (line.find("func ") != -1 && line.find("var ") != -1) { + if (line.contains("func ") && line.contains("var ")) { int start = line.find("func "); start = line.substr(start).find("(") + start; int end = get_end_parenthess(line.substr(start)) + 1; @@ -3018,7 +3222,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- yield(this, \"timeout\") -> await this.timeout GDScript - if (line.find("yield(") != -1) { + if (line.contains("yield(")) { int start = line.find("yield("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3034,7 +3238,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- parse_json( AA ) -> TODO Object - if (line.find("parse_json(") != -1) { + if (line.contains("parse_json(")) { int start = line.find("parse_json("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3044,7 +3248,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- .xform(Vector3(a,b,c)) -> * Vector3(a,b,c) Transform - if (line.find(".xform(") != -1) { + if (line.contains(".xform(")) { int start = line.find(".xform("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3056,12 +3260,12 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- .xform_inv(Vector3(a,b,c)) -> * Vector3(a,b,c) Transform - if (line.find(".xform_inv(") != -1) { + if (line.contains(".xform_inv(")) { 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) { + if (line.contains(object_exec + ".xform")) { int start2 = line.find(object_exec + ".xform"); Vector<String> parts = parse_arguments(line.substr(start, end)); if (parts.size() == 1) { @@ -3072,7 +3276,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- "(connect(A,B,C,D,E) != OK):", "(connect(A,Callable(B,C).bind(D),E) Object - if (line.find("connect(") != -1) { + if (line.contains("connect(")) { int start = line.find("connect("); // Protection from disconnect if (start == 0 || line.get(start - 1) != 's') { @@ -3088,7 +3292,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // -- disconnect(a,b,c) -> disconnect(a,Callable(b,c)) Object - if (line.find("disconnect(") != -1) { + if (line.contains("disconnect(")) { int start = line.find("disconnect("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3099,7 +3303,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // -- is_connected(a,b,c) -> is_connected(a,Callable(b,c)) Object - if (line.find("is_connected(") != -1) { + if (line.contains("is_connected(")) { int start = line.find("is_connected("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3111,7 +3315,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- "(tween_method(A,B,C,D,E) != OK):", "(tween_method(Callable(A,B),C,D,E) Object // -- "(tween_method(A,B,C,D,E,[F,G]) != OK):", "(tween_method(Callable(A,B).bind(F,G),C,D,E) Object - if (line.find("tween_method(") != -1) { + if (line.contains("tween_method(")) { int start = line.find("tween_method("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3124,7 +3328,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // -- "(tween_callback(A,B,[C,D]) != OK):", "(connect(Callable(A,B).bind(C,D)) Object - if (line.find("tween_callback(") != -1) { + if (line.contains("tween_callback(")) { int start = line.find("tween_callback("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3138,7 +3342,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- 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) { + if (line.contains("start(")) { int start = line.find("start("); int end = get_end_parenthess(line.substr(start)) + 1; // Protection from 'func start' @@ -3154,16 +3358,18 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // -- func _init(p_x:int)->void: -> func _init(p_x:int): Object # https://github.com/godotengine/godot/issues/50589 - if (line.find(" _init(") != -1) { + if (line.contains(" _init(")) { 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); + if (line.contains(":")) { + 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) { + if (line.contains("assert(")) { int start = line.find("assert("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3174,7 +3380,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // create_from_image(aa, bb) -> create_from_image(aa) #, bb ImageTexture - if (line.find("create_from_image(") != -1) { + if (line.contains("create_from_image(")) { int start = line.find("create_from_image("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3185,7 +3391,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // set_cell_item(a, b, c, d ,e) -> set_cell_item(Vector3(a, b, c), d ,e) - if (line.find("set_cell_item(") != -1) { + if (line.contains("set_cell_item(")) { int start = line.find("set_cell_item("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3196,7 +3402,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // get_cell_item(a, b, c) -> get_cell_item(Vector3i(a, b, c)) - if (line.find("get_cell_item(") != -1) { + if (line.contains("get_cell_item(")) { int start = line.find("get_cell_item("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3207,7 +3413,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // get_cell_item_orientation(a, b, c) -> get_cell_item_orientation(Vector3i(a, b, c)) - if (line.find("get_cell_item_orientation(") != -1) { + if (line.contains("get_cell_item_orientation(")) { int start = line.find("get_cell_item_orientation("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3218,7 +3424,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // apply_impulse(A, B) -> apply_impulse(B, A) - if (line.find("apply_impulse(") != -1) { + if (line.contains("apply_impulse(")) { int start = line.find("apply_impulse("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3229,7 +3435,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // apply_force(A, B) -> apply_force(B, A) - if (line.find("apply_force(") != -1) { + if (line.contains("apply_force(")) { int start = line.find("apply_force("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3240,7 +3446,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // map_to_world(a, b, c) -> map_to_world(Vector3i(a, b, c)) - if (line.find("map_to_world(") != -1) { + if (line.contains("map_to_world(")) { int start = line.find("map_to_world("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3251,7 +3457,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // OS.get_window_safe_area() -> DisplayServer.get_display_safe_area() - if (line.find("OS.get_window_safe_area(") != -1) { + if (line.contains("OS.get_window_safe_area(")) { int start = line.find("OS.get_window_safe_area("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3261,14 +3467,59 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } } + // draw_rect(a,b,c,d,e) -> draw_rect(a,b,c,d)#e) TODOGODOT4 Antialiasing argument is missing + if (line.contains("draw_rect(")) { + int start = line.find("draw_rect("); + 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_rect(" + parts[0] + "," + parts[1] + "," + parts[2] + "," + parts[3] + ")" + line.substr(end + start) + "# " + parts[4] + ") TODOGODOT4 Antialiasing argument is missing"; + } + } + } + // get_focus_owner() -> get_viewport().gui_get_focus_owner() + if (line.contains("get_focus_owner()")) { + line = line.replace("get_focus_owner()", "get_viewport().gui_get_focus_owner()"); + } + + // button.pressed = 1 -> button.button_pressed = 1 + if (line.contains(".pressed")) { + int start = line.find(".pressed"); + bool foundNextEqual = false; + String line_to_check = line.substr(start + String(".pressed").length()); + for (int current_index = 0; line_to_check.length() > current_index; current_index++) { + char32_t chr = line_to_check.get(current_index); + if (chr == '\t' || chr == ' ') { + continue; + } else if (chr == '=') { + foundNextEqual = true; + } else { + break; + } + } + if (foundNextEqual) { + line = line.substr(0, start) + ".button_pressed" + line.substr(start + String(".pressed").length()); + } + } + + // OS -> Time functions + if (line.contains("OS.get_ticks_msec")) { + line = line.replace("OS.get_ticks_msec", "Time.get_ticks_msec"); + } + if (line.contains("OS.get_ticks_usec")) { + line = line.replace("OS.get_ticks_usec", "Time.get_ticks_usec"); + } + if (line.contains("OS.get_unix_time")) { + line = line.replace("OS.get_unix_time", "Time.get_unix_time_from_system"); + } } -void ProjectConverter3To4::process_csharp_line(String &line) { - // TODO maybe this can be changed to normal rule +void ProjectConverter3To4::process_csharp_line(String &line, const RegExContainer ®_container) { line = line.replace("OS.GetWindowSafeArea()", "DisplayServer.ScreenGetUsableRect()"); // -- Connect(,,,things) -> Connect(,Callable(,),things) Object - if (line.find("Connect(") != -1) { + if (line.contains("Connect(")) { int start = line.find("Connect("); // Protection from disconnect if (start == 0 || line.get(start - 1) != 's') { @@ -3282,7 +3533,7 @@ void ProjectConverter3To4::process_csharp_line(String &line) { } } // -- Disconnect(a,b,c) -> Disconnect(a,Callable(b,c)) Object - if (line.find("Disconnect(") != -1) { + if (line.contains("Disconnect(")) { int start = line.find("Disconnect("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3293,7 +3544,7 @@ void ProjectConverter3To4::process_csharp_line(String &line) { } } // -- IsConnected(a,b,c) -> IsConnected(a,Callable(b,c)) Object - if (line.find("IsConnected(") != -1) { + if (line.contains("IsConnected(")) { int start = line.find("IsConnected("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3305,415 +3556,317 @@ void ProjectConverter3To4::process_csharp_line(String &line) { } } -void ProjectConverter3To4::rename_csharp_functions(String &file_content) { - Vector<String> lines = file_content.split("\n"); - +void ProjectConverter3To4::rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container) { for (String &line : lines) { - process_csharp_line(line); - } - - // Collect vector to string - file_content = ""; - for (int i = 0; i < lines.size(); i++) { - file_content += lines[i]; - - if (i != lines.size() - 1) { - file_content += "\n"; + if (uint64_t(line.length()) <= maximum_line_length) { + process_csharp_line(line, reg_container); } } }; -// This is almost 1:1 copy of function which rename gdscript functions -Vector<String> ProjectConverter3To4::check_for_rename_csharp_functions(Vector<String> &file_content) { +Vector<String> ProjectConverter3To4::check_for_rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container) { int current_line = 1; - Vector<String> found_things; + Vector<String> found_renames; - for (String &line : file_content) { - String old_line = line; - process_csharp_line(line); - if (old_line != line) { - found_things.append(simple_line_formatter(current_line, old_line, line)); + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + String old_line = line; + process_csharp_line(line, reg_container); + if (old_line != line) { + found_renames.append(simple_line_formatter(current_line, old_line, line)); + } } } - return found_things; + return found_renames; } -void ProjectConverter3To4::rename_csharp_attributes(String &file_content) { - // -- [Remote] -> [RPC(MultiplayerAPI.RPCMode.AnyPeer)] - { - RegEx reg_remote = RegEx("\\[Remote(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!reg_remote.is_valid()); - file_content = reg_remote.sub(file_content, "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", true); - } - // -- [RemoteSync] -> [RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)] - { - RegEx reg_remotesync = RegEx("\\[(Remote)?Sync(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!reg_remotesync.is_valid()); - file_content = reg_remotesync.sub(file_content, "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", true); - } - // -- [Puppet] -> [RPC] - { - RegEx reg_puppet = RegEx("\\[(Puppet|Slave)(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!reg_puppet.is_valid()); - file_content = reg_puppet.sub(file_content, "[RPC]", true); - } - // -- [PuppetSync] -> [RPC(CallLocal = true)] - { - RegEx reg_puppetsync = RegEx("\\[PuppetSync(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!reg_puppetsync.is_valid()); - file_content = reg_puppetsync.sub(file_content, "[RPC(CallLocal = true)]", true); - } - String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n"; - // -- [Master] -> [RPC] - { - RegEx reg_remote = RegEx("\\[Master(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!reg_remote.is_valid()); - file_content = reg_remote.sub(file_content, error_message + "[RPC]", true); - } - // -- [MasterSync] -> [RPC(CallLocal = true)] - { - RegEx reg_remote = RegEx("\\[MasterSync(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!reg_remote.is_valid()); - file_content = reg_remote.sub(file_content, error_message + "[RPC(CallLocal = true)]", true); +void ProjectConverter3To4::rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container) { + static String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n"; + + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + line = reg_container.keyword_csharp_remote.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", true); + line = reg_container.keyword_csharp_remotesync.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", true); + line = reg_container.keyword_csharp_puppet.sub(line, "[RPC]", true); + line = reg_container.keyword_csharp_puppetsync.sub(line, "[RPC(CallLocal = true)]", true); + line = reg_container.keyword_csharp_master.sub(line, error_message + "[RPC]", true); + line = reg_container.keyword_csharp_mastersync.sub(line, error_message + "[RPC(CallLocal = true)]", true); + } } } -Vector<String> ProjectConverter3To4::check_for_rename_csharp_attributes(Vector<String> &file_content) { +Vector<String> ProjectConverter3To4::check_for_rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container) { int current_line = 1; - Vector<String> found_things; + Vector<String> found_renames; - for (String &line : file_content) { - String old; - old = line; - { - RegEx regex = RegEx("\\[Remote(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "[Remote]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", line)); - } - old = line; - { - RegEx regex = RegEx("\\[(Remote)?Sync(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "[RemoteSync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", line)); - } - old = line; - { - RegEx regex = RegEx("\\[Puppet(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "[RPC]", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "[Puppet]", "[RPC]", line)); - } - old = line; - { - RegEx regex = RegEx("\\[(Puppet|Slave)Sync(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "[RPC(CallLocal = true)]", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "[PuppetSync]", "[RPC(CallLocal = true)]", line)); - } - old = line; - { - RegEx regex = RegEx("\\[Master(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "[RPC]", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "[Master]", "[RPC]", line)); - } - old = line; - { - RegEx regex = RegEx("\\[MasterSync(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "[RPC(CallLocal = true)]", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "[MasterSync]", "[RPC(CallLocal = true)]", line)); - } + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + String old; + old = line; + line = reg_container.keyword_csharp_remote.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "[Remote]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", line)); + } + old = line; + line = reg_container.keyword_csharp_remotesync.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "[RemoteSync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", line)); + } + + old = line; + line = reg_container.keyword_csharp_puppet.sub(line, "[RPC]", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "[Puppet]", "[RPC]", line)); + } + + old = line; + line = reg_container.keyword_csharp_puppetsync.sub(line, "[RPC(CallLocal = true)]", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "[PuppetSync]", "[RPC(CallLocal = true)]", line)); + } + + old = line; + line = reg_container.keyword_csharp_master.sub(line, "[RPC]", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "[Master]", "[RPC]", line)); + } + + old = line; + line = reg_container.keyword_csharp_mastersync.sub(line, "[RPC(CallLocal = true)]", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "[MasterSync]", "[RPC(CallLocal = true)]", line)); + } + } current_line++; } - return found_things; + return found_renames; } -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]+)sync 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("^sync 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]+)slave func"); - CRASH_COND(!reg_first.is_valid()); - file_content = reg_first.sub(file_content, "$1@rpc func", true); - RegEx reg_second = RegEx("^slave func"); - CRASH_COND(!reg_second.is_valid()); - file_content = reg_second.sub(file_content, "@rpc 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); +void ProjectConverter3To4::rename_gdscript_keywords(Vector<String> &lines, const RegExContainer ®_container) { + static 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"; + + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + if (line.contains("tool")) { + line = reg_container.keyword_gdscript_tool.sub(line, "@tool", true); + } + if (line.contains("export")) { + line = reg_container.keyword_gdscript_export_single.sub(line, "@export", true); + } + if (line.contains("export")) { + line = reg_container.keyword_gdscript_export_mutli.sub(line, "$1@export", true); + } + if (line.contains("onready")) { + line = reg_container.keyword_gdscript_onready.sub(line, "@onready", true); + } + if (line.contains("remote")) { + line = reg_container.keyword_gdscript_remote.sub(line, "@rpc(any_peer) func", true); + } + if (line.contains("remote")) { + line = reg_container.keyword_gdscript_remotesync.sub(line, "@rpc(any_peer, call_local) func", true); + } + if (line.contains("sync")) { + line = reg_container.keyword_gdscript_sync.sub(line, "@rpc(any_peer, call_local) func", true); + } + if (line.contains("slave")) { + line = reg_container.keyword_gdscript_slave.sub(line, "@rpc func", true); + } + if (line.contains("puppet")) { + line = reg_container.keyword_gdscript_puppet.sub(line, "@rpc func", true); + } + if (line.contains("puppet")) { + line = reg_container.keyword_gdscript_puppetsync.sub(line, "@rpc(call_local) func", true); + } + if (line.contains("master")) { + line = reg_container.keyword_gdscript_master.sub(line, error_message + "@rpc func", true); + } + if (line.contains("master")) { + line = reg_container.keyword_gdscript_mastersync.sub(line, error_message + "@rpc(call_local) func", true); + } + } } } -Vector<String> ProjectConverter3To4::check_for_rename_gdscript_keywords(Vector<String> &file_content) { - Vector<String> found_things; +Vector<String> ProjectConverter3To4::check_for_rename_gdscript_keywords(Vector<String> &lines, const RegExContainer ®_container) { + Vector<String> found_renames; int current_line = 1; + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + String old; + + if (line.contains("tool")) { + old = line; + line = reg_container.keyword_gdscript_tool.sub(line, "@tool", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "tool", "@tool", line)); + } + } - for (String &line : file_content) { - String old; - old = line; - { - 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_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_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 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, "remote func", "@rpc(any_peer) func", line)); - } - old = line; - { - 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, "remotesync func", "@rpc(any_peer, call_local)) func", line)); - } - old = line; - { - RegEx regex = RegEx("^sync 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, "sync func", "@rpc(any_peer, call_local)) func", line)); - } - old = line; - { - RegEx regex = RegEx("^slave func"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "@rpc func", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "slave func", "@rpc func", line)); - } - old = line; - { - 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, "puppet func", "@rpc func", line)); - } - old = line; - { - 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, "puppetsync func", "@rpc(call_local) func", line)); - } - old = line; - { - 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, "master func", "@rpc func", line)); - } - old = line; - { - 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 func", "@rpc(call_local) func", line)); - } - old = line; + if (line.contains("export")) { + old = line; + line = reg_container.keyword_gdscript_export_single.sub(line, "$1@export", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "export", "@export", line)); + } + } + if (line.contains("export")) { + old = line; + line = reg_container.keyword_gdscript_export_mutli.sub(line, "@export", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "export", "@export", line)); + } + } + + if (line.contains("onready")) { + old = line; + line = reg_container.keyword_gdscript_tool.sub(line, "@onready", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "onready", "@onready", line)); + } + } + + if (line.contains("remote")) { + old = line; + line = reg_container.keyword_gdscript_remote.sub(line, "@rpc(any_peer) func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "remote func", "@rpc(any_peer) func", line)); + } + } + + if (line.contains("remote")) { + old = line; + line = reg_container.keyword_gdscript_remotesync.sub(line, "@rpc(any_peer, call_local)) func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "remotesync func", "@rpc(any_peer, call_local)) func", line)); + } + } + + if (line.contains("sync")) { + old = line; + line = reg_container.keyword_gdscript_sync.sub(line, "@rpc(any_peer, call_local)) func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "sync func", "@rpc(any_peer, call_local)) func", line)); + } + } + + if (line.contains("slave")) { + old = line; + line = reg_container.keyword_gdscript_slave.sub(line, "@rpc func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "slave func", "@rpc func", line)); + } + } + + if (line.contains("puppet")) { + old = line; + line = reg_container.keyword_gdscript_puppet.sub(line, "@rpc func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "puppet func", "@rpc func", line)); + } + } + + if (line.contains("puppet")) { + old = line; + line = reg_container.keyword_gdscript_puppetsync.sub(line, "@rpc(call_local) func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "puppetsync func", "@rpc(call_local) func", line)); + } + } + + if (line.contains("master")) { + old = line; + line = reg_container.keyword_gdscript_master.sub(line, "@rpc func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "master func", "@rpc func", line)); + } + } + + if (line.contains("master")) { + old = line; + line = reg_container.keyword_gdscript_master.sub(line, "@rpc(call_local) func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "mastersync func", "@rpc(call_local) func", line)); + } + } + } current_line++; } - return found_things; + return found_renames; } -void ProjectConverter3To4::custom_rename(String &file_content, String from, String to) { +void ProjectConverter3To4::custom_rename(Vector<String> &lines, String from, String to) { RegEx reg = RegEx(String("\\b") + from + "\\b"); CRASH_COND(!reg.is_valid()); - file_content = reg.sub(file_content, to, true); + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + line = reg.sub(line, to, true); + } + } }; -Vector<String> ProjectConverter3To4::check_for_custom_rename(Vector<String> &file_content, String from, String to) { - Vector<String> found_things; +Vector<String> ProjectConverter3To4::check_for_custom_rename(Vector<String> &lines, String from, String to) { + Vector<String> found_renames; RegEx reg = RegEx(String("\\b") + from + "\\b"); CRASH_COND(!reg.is_valid()); int current_line = 1; - for (String &line : file_content) { - TypedArray<RegExMatch> reg_match = reg.search_all(line); - if (reg_match.size() > 0) { - found_things.append(line_formatter(current_line, from.replace("\\.", "."), to, line)); // Without replacing it will print "\.shader" instead ".shader" + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + TypedArray<RegExMatch> reg_match = reg.search_all(line); + if (reg_match.size() > 0) { + found_renames.append(line_formatter(current_line, from.replace("\\.", "."), to, line)); // Without replacing it will print "\.shader" instead ".shader" + } } current_line++; } - return found_things; + return found_renames; } -void ProjectConverter3To4::rename_common(const char *array[][2], String &file_content) { - int current_index = 0; - while (array[current_index][0]) { - RegEx reg = RegEx(String("\\b") + array[current_index][0] + "\\b"); - CRASH_COND(!reg.is_valid()); - file_content = reg.sub(file_content, array[current_index][1], true); - current_index++; +void ProjectConverter3To4::rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines) { + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + for (unsigned int current_index = 0; current_index < cached_regexes.size(); current_index++) { + if (line.contains(array[current_index][0])) { + line = cached_regexes[current_index]->sub(line, array[current_index][1], true); + } + } + } } } -// Common renaming, -Vector<String> ProjectConverter3To4::check_for_rename_common(const char *array[][2], Vector<String> &file_content) { - int current_index = 0; - - Vector<String> found_things; +Vector<String> ProjectConverter3To4::check_for_rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines) { + Vector<String> found_renames; - while (array[current_index][0]) { - RegEx reg = RegEx(String("\\b") + array[current_index][0] + "\\b"); - CRASH_COND(!reg.is_valid()); + int current_line = 1; - int current_line = 1; - for (String &line : file_content) { - TypedArray<RegExMatch> reg_match = reg.search_all(line); - if (reg_match.size() > 0) { - found_things.append(line_formatter(current_line, array[current_index][0], array[current_index][1], line)); + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + for (unsigned int current_index = 0; current_index < cached_regexes.size(); current_index++) { + if (line.contains(array[current_index][0])) { + TypedArray<RegExMatch> reg_match = cached_regexes[current_index]->search_all(line); + if (reg_match.size() > 0) { + found_renames.append(line_formatter(current_line, array[current_index][0], array[current_index][1], line)); + } + } } - current_line++; } - current_index++; + current_line++; } - return found_things; + + return found_renames; } -// Formats data to print them into user console when trying to convert data +// Prints full info about renamed things e.g.: +// Line (67) remove -> remove_at - LINE """ doubler._blacklist.remove(0) """ String ProjectConverter3To4::line_formatter(int current_line, String from, String to, String line) { if (from.size() > 200) { from = from.substr(0, 197) + "..."; @@ -3727,6 +3880,8 @@ String ProjectConverter3To4::line_formatter(int current_line, String from, Strin return String("Line (") + itos(current_line) + ") " + from.replace("\r", "").replace("\n", "") + " -> " + to.replace("\r", "").replace("\n", "") + " - LINE \"\"\" " + line.replace("\r", "").replace("\n", "").strip_edges() + " \"\"\""; } +// Prints only full lines e.g.: +// Line (1) - FULL LINES - """yield(get_tree().create_timer(3), 'timeout')""" =====> """ await get_tree().create_timer(3).timeout """ String ProjectConverter3To4::simple_line_formatter(int current_line, String old_line, String line) { if (old_line.size() > 1000) { old_line = old_line.substr(0, 997) + "..."; @@ -3737,6 +3892,19 @@ String ProjectConverter3To4::simple_line_formatter(int current_line, String old_ return String("Line (") + itos(current_line) + ") - FULL LINES - \"\"\"" + old_line.replace("\r", "").replace("\n", "").strip_edges() + "\"\"\" =====> \"\"\" " + line.replace("\r", "").replace("\n", "").strip_edges() + " \"\"\""; } +// Collects string from vector strings +String ProjectConverter3To4::collect_string_from_vector(Vector<String> &vector) { + String string = ""; + for (int i = 0; i < vector.size(); i++) { + string += vector[i]; + + if (i != vector.size() - 1) { + string += "\n"; + } + } + return string; +} + #else // No regex. int ProjectConverter3To4::convert() { diff --git a/editor/project_converter_3_to_4.h b/editor/project_converter_3_to_4.h index 8526e2ceb9..fc6d66c9a8 100644 --- a/editor/project_converter_3_to_4.h +++ b/editor/project_converter_3_to_4.h @@ -35,37 +35,43 @@ #include "core/io/file_access.h" #include "core/object/ref_counted.h" #include "core/string/ustring.h" +#include "core/templates/local_vector.h" + +class RegEx; class ProjectConverter3To4 { public: class RegExContainer; private: - void rename_enums(String &file_content); - Vector<String> check_for_rename_enums(Vector<String> &file_content); + uint64_t maximum_file_size; + uint64_t maximum_line_length; + + void rename_colors(Vector<String> &lines, const RegExContainer ®_container); + Vector<String> check_for_rename_colors(Vector<String> &lines, const RegExContainer ®_container); - void rename_classes(String &file_content); - Vector<String> check_for_rename_classes(Vector<String> &file_content); + void rename_classes(Vector<String> &lines, const RegExContainer ®_container); + Vector<String> check_for_rename_classes(Vector<String> &lines, const RegExContainer ®_container); - 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 rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin); + Vector<String> check_for_rename_gdscript_functions(Vector<String> &lines, 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_csharp_functions(Vector<String> &lines, const RegExContainer ®_container); + Vector<String> check_for_rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container); + void process_csharp_line(String &line, const RegExContainer ®_container); - void rename_csharp_attributes(String &file_content); - Vector<String> check_for_rename_csharp_attributes(Vector<String> &file_content); + void rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container); + Vector<String> check_for_rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container); - void rename_gdscript_keywords(String &file_content); - Vector<String> check_for_rename_gdscript_keywords(Vector<String> &file_content); + void rename_gdscript_keywords(Vector<String> &lines, const RegExContainer ®_container); + Vector<String> check_for_rename_gdscript_keywords(Vector<String> &lines, const RegExContainer ®_container); - void custom_rename(String &file_content, String from, String to); - Vector<String> check_for_custom_rename(Vector<String> &file_content, String from, String to); + void custom_rename(Vector<String> &lines, String from, String to); + Vector<String> check_for_custom_rename(Vector<String> &lines, String from, String to); - void rename_common(const char *array[][2], String &file_content); - Vector<String> check_for_rename_common(const char *array[][2], Vector<String> &file_content); + void rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines); + Vector<String> check_for_rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines); Vector<String> check_for_files(); @@ -77,15 +83,17 @@ private: String line_formatter(int current_line, String from, String to, String line); String simple_line_formatter(int current_line, String old_line, String line); + String collect_string_from_vector(Vector<String> &vector); 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_conversion_gdscript_builtin(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin); + bool test_conversion_with_regex(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &), String what, const RegExContainer ®_container); + bool test_conversion_basic(String name, String expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, String what); bool test_array_names(); - bool test_conversion(const RegExContainer ®_container); + bool test_conversion(RegExContainer ®_container); public: + ProjectConverter3To4(int, int); int validate_conversion(); int convert(); }; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 6623792fc0..9909ab378a 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -438,7 +438,7 @@ private: ProjectSettings::CustomMap edited_settings; edited_settings["application/config/name"] = project_name->get_text().strip_edges(); - if (current->save_custom(dir2.plus_file("project.godot"), edited_settings, Vector<String>(), true) != OK) { + if (current->save_custom(dir2.path_join("project.godot"), edited_settings, Vector<String>(), true) != OK) { set_message(TTR("Couldn't edit project.godot in project path."), MESSAGE_ERROR); } } @@ -486,12 +486,12 @@ private: initial_settings["application/config/name"] = project_name->get_text().strip_edges(); initial_settings["application/config/icon"] = "res://icon.svg"; - if (ProjectSettings::get_singleton()->save_custom(dir.plus_file("project.godot"), initial_settings, Vector<String>(), false) != OK) { + if (ProjectSettings::get_singleton()->save_custom(dir.path_join("project.godot"), initial_settings, Vector<String>(), false) != OK) { set_message(TTR("Couldn't create project.godot in project path."), MESSAGE_ERROR); } else { // Store default project icon in SVG format. Error err; - Ref<FileAccess> fa_icon = FileAccess::open(dir.plus_file("icon.svg"), FileAccess::WRITE, &err); + Ref<FileAccess> fa_icon = FileAccess::open(dir.path_join("icon.svg"), FileAccess::WRITE, &err); fa_icon->store_string(get_default_project_icon()); if (err != OK) { @@ -556,7 +556,7 @@ private: String rel_path = path.substr(zip_root.length()); Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - da->make_dir(dir.plus_file(rel_path)); + da->make_dir(dir.path_join(rel_path)); } else { Vector<uint8_t> data; data.resize(info.uncompressed_size); @@ -568,7 +568,7 @@ private: ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", rel_path)); unzCloseCurrentFile(pkg); - Ref<FileAccess> f = FileAccess::open(dir.plus_file(rel_path), FileAccess::WRITE); + Ref<FileAccess> f = FileAccess::open(dir.path_join(rel_path), FileAccess::WRITE); if (f.is_valid()) { f->store_buffer(data.ptr(), data.size()); } else { @@ -962,12 +962,12 @@ public: switch (p_what) { case NOTIFICATION_MOUSE_ENTER: { hover = true; - update(); + queue_redraw(); } break; case NOTIFICATION_MOUSE_EXIT: { hover = false; - update(); + queue_redraw(); } break; case NOTIFICATION_DRAW: { @@ -1126,7 +1126,7 @@ ProjectList::ProjectList() { _icon_load_index = 0; project_opening_initiated = false; - _config_path = EditorPaths::get_singleton()->get_data_dir().plus_file("projects.cfg"); + _config_path = EditorPaths::get_singleton()->get_data_dir().path_join("projects.cfg"); } ProjectList::~ProjectList() { @@ -1185,7 +1185,7 @@ void ProjectList::load_project_icon(int p_index) { // Load project data from p_property_key and return it in a ProjectList::Item. p_favorite is passed directly into the Item. ProjectList::Item ProjectList::load_project_data(const String &p_path, bool p_favorite) { - String conf = p_path.plus_file("project.godot"); + String conf = p_path.path_join("project.godot"); bool grayed = false; bool missing = false; @@ -1221,7 +1221,7 @@ ProjectList::Item ProjectList::load_project_data(const String &p_path, bool p_fa // when editing a project (but not when running it). last_edited = FileAccess::get_modified_time(conf); - String fscache = p_path.plus_file(".fscache"); + String fscache = p_path.path_join(".fscache"); if (FileAccess::exists(fscache)) { uint64_t cache_modified = FileAccess::get_modified_time(fscache); if (cache_modified > last_edited) { @@ -1341,7 +1341,7 @@ void ProjectList::_global_menu_open_project(const Variant &p_tag) { int idx = (int)p_tag; if (idx >= 0 && idx < _projects.size()) { - String conf = _projects[idx].path.plus_file("project.godot"); + String conf = _projects[idx].path.path_join("project.godot"); List<String> args; args.push_back(conf); OS::get_singleton()->create_instance(args); @@ -1682,7 +1682,7 @@ void ProjectList::select_project(int p_index) { _selected_project_paths.clear(); for (int i = 0; i < previous_selected_items.size(); ++i) { - previous_selected_items[i].control->update(); + previous_selected_items[i].control->queue_redraw(); } toggle_select(p_index); @@ -1728,7 +1728,7 @@ void ProjectList::toggle_select(int p_index) { } else { _selected_project_paths.insert(item.path); } - item.control->update(); + item.control->queue_redraw(); } void ProjectList::erase_selected_projects(bool p_delete_project_contents) { @@ -1860,7 +1860,7 @@ void ProjectManager::_notification(int p_what) { case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { settings_hb->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT); - update(); + queue_redraw(); } break; case NOTIFICATION_ENTER_TREE: { @@ -2112,7 +2112,7 @@ void ProjectManager::_open_selected_projects() { const HashSet<String> &selected_list = _project_list->get_selected_project_keys(); for (const String &path : selected_list) { - String conf = path.plus_file("project.godot"); + String conf = path.path_join("project.godot"); if (!FileAccess::exists(conf)) { dialog_error->set_text(vformat(TTR("Can't open project at '%s'."), path)); @@ -2162,7 +2162,7 @@ void ProjectManager::_open_selected_projects_ask() { } // Update the project settings or don't open - const String conf = project.path.plus_file("project.godot"); + const String conf = project.path.path_join("project.godot"); const int config_version = project.version; PackedStringArray unsupported_features = project.unsupported_features; @@ -2235,7 +2235,7 @@ void ProjectManager::_run_project_confirm() { const String &path = selected_list[i].path; // `.substr(6)` on `ProjectSettings::get_singleton()->get_imported_files_path()` strips away the leading "res://". - if (!DirAccess::exists(path.plus_file(ProjectSettings::get_singleton()->get_imported_files_path().substr(6)))) { + if (!DirAccess::exists(path.path_join(ProjectSettings::get_singleton()->get_imported_files_path().substr(6)))) { run_error_diag->set_text(TTR("Can't run project: Assets need to be imported.\nPlease edit the project to trigger the initial import.")); run_error_diag->popup_centered(); continue; @@ -2280,7 +2280,7 @@ void ProjectManager::_scan_dir(const String &path) { String n = da->get_next(); while (!n.is_empty()) { if (da->current_is_dir() && !n.begins_with(".")) { - _scan_dir(da->get_current_dir().plus_file(n)); + _scan_dir(da->get_current_dir().path_join(n)); } else if (n == "project.godot") { _project_list->add_project(da->get_current_dir(), false); } diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 7b4df696b7..300a3d0f05 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -500,7 +500,7 @@ String RenameDialog::_postprocess(const String &subject) { if (style_id == 1) { // PascalCase to snake_case - result = result.camelcase_to_underscore(true); + result = result.to_snake_case(); result = _regex("_+", result, "_"); } else if (style_id == 2) { @@ -521,7 +521,7 @@ String RenameDialog::_postprocess(const String &subject) { end = start + 1; } buffer += result.substr(end, result.size() - (end + 1)); - result = buffer.replace("_", "").capitalize(); + result = buffer.to_pascal_case(); } } diff --git a/editor/scene_create_dialog.cpp b/editor/scene_create_dialog.cpp index 94a5c07709..9b8684b7b8 100644 --- a/editor/scene_create_dialog.cpp +++ b/editor/scene_create_dialog.cpp @@ -111,7 +111,7 @@ void SceneCreateDialog::update_dialog() { } if (is_valid) { - scene_name = directory.plus_file(scene_name); + scene_name = directory.path_join(scene_name); Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES); if (da->file_exists(scene_name)) { update_error(file_error_label, MSG_ERROR, TTR("File already exists.")); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index c7c713fc67..e2265f2f83 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -240,7 +240,7 @@ void SceneTreeDock::_perform_instantiate_scenes(const Vector<String> &p_files, N String new_name = parent->validate_child_name(instantiated_scene); EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton(); editor_data->get_undo_redo()->add_do_method(ed, "live_debug_instance_node", edited_scene->get_path_to(parent), p_files[i], new_name); - editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).plus_file(new_name))); + editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).path_join(new_name))); } editor_data->get_undo_redo()->commit_action(); @@ -691,7 +691,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton(); editor_data->get_undo_redo()->add_do_method(ed, "live_debug_duplicate_node", edited_scene->get_path_to(node), dup->get_name()); - editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).plus_file(dup->get_name()))); + editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).path_join(dup->get_name()))); add_below_node = dup; } @@ -1068,24 +1068,61 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } break; case TOOL_TOGGLE_SCENE_UNIQUE_NAME: { - List<Node *> selection = editor_selection->get_selected_node_list(); - List<Node *>::Element *e = selection.front(); - if (e) { - Ref<EditorUndoRedoManager> undo_redo = editor_data->get_undo_redo(); - Node *node = e->get(); - bool enabled = node->is_unique_name_in_owner(); - if (!enabled && get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(node->get_name())) != nullptr) { - accept->set_text(TTR("Another node already uses this unique name in the scene.")); + // Enabling/disabling based on the same node based on which the checkbox in the menu is checked/unchecked. + List<Node *>::Element *first_selected = editor_selection->get_selected_node_list().front(); + if (first_selected == nullptr) { + return; + } + bool enabling = !first_selected->get()->is_unique_name_in_owner(); + + List<Node *> full_selection = editor_selection->get_full_selected_node_list(); + Ref<EditorUndoRedoManager> undo_redo = editor_data->get_undo_redo(); + + if (enabling) { + Vector<Node *> new_unique_nodes; + Vector<StringName> new_unique_names; + Vector<StringName> cant_be_set_unique_names; + + for (Node *node : full_selection) { + if (node->is_unique_name_in_owner()) { + continue; + } + StringName name = node->get_name(); + if (new_unique_names.find(name) != -1 || get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(name)) != nullptr) { + cant_be_set_unique_names.push_back(name); + } else { + new_unique_nodes.push_back(node); + new_unique_names.push_back(name); + } + } + + if (new_unique_nodes.size()) { + undo_redo->create_action(TTR("Enable Scene Unique Name(s)")); + for (Node *node : new_unique_nodes) { + undo_redo->add_do_method(node, "set_unique_name_in_owner", true); + undo_redo->add_undo_method(node, "set_unique_name_in_owner", false); + } + undo_redo->commit_action(); + } + + if (cant_be_set_unique_names.size()) { + String popup_text = TTR("Unique names already used by another node in the scene:"); + popup_text += "\n"; + for (StringName name : cant_be_set_unique_names) { + popup_text += "\n" + String(name); + } + accept->set_text(popup_text); accept->popup_centered(); - return; } - if (!enabled) { - undo_redo->create_action(TTR("Enable Scene Unique Name")); - } else { - undo_redo->create_action(TTR("Disable Scene Unique Name")); + } else { // Disabling. + undo_redo->create_action(TTR("Disable Scene Unique Name(s)")); + for (Node *node : full_selection) { + if (!node->is_unique_name_in_owner()) { + continue; + } + undo_redo->add_do_method(node, "set_unique_name_in_owner", false); + undo_redo->add_undo_method(node, "set_unique_name_in_owner", true); } - undo_redo->add_do_method(node, "set_unique_name_in_owner", !enabled); - undo_redo->add_undo_method(node, "set_unique_name_in_owner", enabled); undo_redo->commit_action(); } } break; @@ -1200,7 +1237,7 @@ void SceneTreeDock::_notification(int p_what) { if (canvas_item_plugin) { canvas_item_plugin->get_canvas_item_editor()->connect("item_lock_status_changed", Callable(scene_tree, "_update_tree")); canvas_item_plugin->get_canvas_item_editor()->connect("item_group_status_changed", Callable(scene_tree, "_update_tree")); - scene_tree->connect("node_changed", callable_mp((CanvasItem *)canvas_item_plugin->get_canvas_item_editor()->get_viewport_control(), &CanvasItem::update)); + scene_tree->connect("node_changed", callable_mp((CanvasItem *)canvas_item_plugin->get_canvas_item_editor()->get_viewport_control(), &CanvasItem::queue_redraw)); } Node3DEditorPlugin *spatial_editor_plugin = Object::cast_to<Node3DEditorPlugin>(editor_data->get_editor("3D")); @@ -1469,7 +1506,7 @@ bool SceneTreeDock::_update_node_path(Node *p_root_node, NodePath &r_node_path, if (found_root_path) { NodePath root_path_new = found_root_path->value; if (!root_path_new.is_empty()) { - NodePath old_abs_path = NodePath(String(p_root_node->get_path()).plus_file(r_node_path)); + NodePath old_abs_path = NodePath(String(p_root_node->get_path()).path_join(r_node_path)); old_abs_path.simplify(); r_node_path = root_path_new.rel_path_to(old_abs_path); } @@ -1839,7 +1876,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V } editor_data->get_undo_redo()->add_do_method(ed, "live_debug_reparent_node", edited_scene->get_path_to(node), edited_scene->get_path_to(new_parent), new_name, p_position_in_parent + inc); - editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_reparent_node", NodePath(String(edited_scene->get_path_to(new_parent)).plus_file(new_name)), edited_scene->get_path_to(node->get_parent()), node->get_name(), node->get_index()); + editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_reparent_node", NodePath(String(edited_scene->get_path_to(new_parent)).path_join(new_name)), edited_scene->get_path_to(node->get_parent()), node->get_name(), node->get_index()); if (p_keep_global_xform) { if (Object::cast_to<Node2D>(node)) { @@ -2127,7 +2164,7 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { // hack, force 2d editor viewport to refresh after deletion if (CanvasItemEditor *editor = CanvasItemEditor::get_singleton()) { - editor->get_viewport_control()->update(); + editor->get_viewport_control()->queue_redraw(); } _push_item(nullptr); @@ -2202,7 +2239,7 @@ void SceneTreeDock::_do_create(Node *p_parent) { String new_name = p_parent->validate_child_name(child); EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton(); editor_data->get_undo_redo()->add_do_method(ed, "live_debug_create_node", edited_scene->get_path_to(p_parent), child->get_class(), new_name); - editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(p_parent)).plus_file(new_name))); + editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(p_parent)).path_join(new_name))); } else { editor_data->get_undo_redo()->add_do_method(EditorNode::get_singleton(), "set_edited_scene", child); @@ -2821,14 +2858,26 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_separator(); menu->add_icon_shortcut(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); } + } - if (selection[0]->get_owner() == EditorNode::get_singleton()->get_edited_scene()) { - // Only for nodes owned by the edited scene root. + if (profile_allow_editing) { + // Allow multi-toggling scene unique names but only if all selected nodes are owned by the edited scene root. + bool all_owned = true; + for (Node *node : full_selection) { + if (node->get_owner() != EditorNode::get_singleton()->get_edited_scene()) { + all_owned = false; + break; + } + } + if (all_owned) { menu->add_separator(); menu->add_icon_check_item(get_theme_icon(SNAME("SceneUniqueName"), SNAME("EditorIcons")), TTR("Access as Scene Unique Name"), TOOL_TOGGLE_SCENE_UNIQUE_NAME); + // Checked based on `selection[0]` because `full_selection` has undesired ordering. menu->set_item_checked(menu->get_item_index(TOOL_TOGGLE_SCENE_UNIQUE_NAME), selection[0]->is_unique_name_in_owner()); } + } + if (selection.size() == 1) { bool is_external = (!selection[0]->get_scene_file_path().is_empty()); if (is_external) { bool is_inherited = selection[0]->get_scene_inherited_state() != nullptr; @@ -2938,9 +2987,9 @@ void SceneTreeDock::attach_script_to_selected(bool p_extend) { if (path.is_empty()) { String root_path = editor_data->get_edited_scene_root()->get_scene_file_path(); if (root_path.is_empty()) { - path = String("res://").plus_file(selected->get_name()); + path = String("res://").path_join(selected->get_name()); } else { - path = root_path.get_base_dir().plus_file(selected->get_name()); + path = root_path.get_base_dir().path_join(selected->get_name()); } } @@ -2997,9 +3046,9 @@ void SceneTreeDock::attach_shader_to_selected(int p_preferred_mode) { shader_name = selected_shader_material->get_name(); } if (root_path.is_empty()) { - path = String("res://").plus_file(shader_name); + path = String("res://").path_join(shader_name); } else { - path = root_path.get_base_dir().plus_file(shader_name); + path = root_path.get_base_dir().path_join(shader_name); } } @@ -3199,7 +3248,7 @@ void SceneTreeDock::_update_create_root_dialog() { favorite_nodes->get_child(i)->queue_delete(); } - Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("favorites.Node"), FileAccess::READ); + Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().path_join("favorites.Node"), FileAccess::READ); if (f.is_valid()) { while (!f->eof_reached()) { String l = f->get_line().strip_edges(); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 00fd0c3aac..88ca371fac 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -354,7 +354,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { tooltip += "\n\n" + p_node->get_editor_description(); } - item->set_tooltip(0, tooltip); + item->set_tooltip_text(0, tooltip); } else if (p_node != get_scene_node() && !p_node->get_scene_file_path().is_empty() && can_open_instance) { item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); @@ -363,7 +363,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { tooltip += "\n\n" + p_node->get_editor_description(); } - item->set_tooltip(0, tooltip); + item->set_tooltip_text(0, tooltip); } else { StringName type = EditorNode::get_singleton()->get_object_custom_type_name(p_node); if (type == StringName()) { @@ -375,7 +375,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { tooltip += "\n\n" + p_node->get_editor_description(); } - item->set_tooltip(0, tooltip); + item->set_tooltip_text(0, tooltip); } if (can_open_instance && undo_redo.is_valid()) { //Show buttons only when necessary(SceneTreeDock) to avoid crashes @@ -505,7 +505,7 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) { if (p_node->is_class("CanvasItem") || p_node->is_class("CanvasLayer") || p_node->is_class("Window")) { visible = p_node->call("is_visible"); - CanvasItemEditor::get_singleton()->get_viewport_control()->update(); + CanvasItemEditor::get_singleton()->get_viewport_control()->queue_redraw(); } else if (p_node->is_class("Node3D")) { visible = p_node->call("is_visible"); } diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 15e992ce18..7d065b4920 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -824,7 +824,7 @@ Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(c Vector<ScriptLanguage::ScriptTemplate> user_templates; String extension = language->get_extension(); - String dir_path = p_dir.plus_file(p_object); + String dir_path = p_dir.path_join(p_object); Ref<DirAccess> d = DirAccess::open(dir_path); if (d.is_valid()) { @@ -860,7 +860,7 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptL // Parse file for meta-information and script content Error err; - Ref<FileAccess> file = FileAccess::open(p_path.plus_file(p_filename), FileAccess::READ, &err); + Ref<FileAccess> file = FileAccess::open(p_path.path_join(p_filename), FileAccess::READ, &err); if (!err) { while (!file->eof_reached()) { String line = file->get_line(); @@ -898,7 +898,7 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptL // Get name from file name if no name in meta information if (script_template.name == String()) { - script_template.name = p_filename.get_basename().replace("_", " ").capitalize(); + script_template.name = p_filename.get_basename().capitalize(); } return script_template; diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index 8c4a231e8a..522fd7c645 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -161,7 +161,7 @@ void ShaderCreateDialog::_create_new() { shader = text_shader; StringBuilder code; - code += vformat("shader_type %s;\n", mode_menu->get_text().replace(" ", "").camelcase_to_underscore()); + code += vformat("shader_type %s;\n", mode_menu->get_text().to_snake_case()); if (current_template == 0) { // Default template. code += "\n"; diff --git a/editor/translations/extract.py b/editor/translations/extract.py index 7f3da400e7..07026baee2 100755 --- a/editor/translations/extract.py +++ b/editor/translations/extract.py @@ -139,7 +139,7 @@ theme_property_patterns = { } -# See String::camelcase_to_underscore(). +# See String::_camelcase_to_underscore(). capitalize_re = re.compile(r"(?<=\D)(?=\d)|(?<=\d)(?=\D([a-z]|\d))") diff --git a/main/main.cpp b/main/main.cpp index 7964ba8e3e..d0170d8093 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -156,6 +156,8 @@ static OS::ProcessID editor_pid = 0; #ifdef TOOLS_ENABLED static bool auto_build_solutions = false; static String debug_server_uri; +static int converter_max_kb_file = 4 * 1024; // 4MB +static int converter_max_line_length = 100000; HashMap<Main::CLIScope, Vector<String>> forwardable_cli_arguments; #endif @@ -403,8 +405,8 @@ void Main::print_help(const char *p_binary) { OS::get_singleton()->print(" <path> should be absolute or relative to the project directory, and include the filename for the binary (e.g. 'builds/game.exe'). The target directory should exist.\n"); OS::get_singleton()->print(" --export-debug <preset> <path> Same as --export, but using the debug template.\n"); OS::get_singleton()->print(" --export-pack <preset> <path> Same as --export, but only export the game pack for the given preset. The <path> extension determines whether it will be in PCK or ZIP format.\n"); - OS::get_singleton()->print(" --convert-3to4 Converts project from Godot 3.x to Godot 4.x.\n"); - OS::get_singleton()->print(" --validate-conversion-3to4 Shows what elements will be renamed when converting project from Godot 3.x to Godot 4.x.\n"); + OS::get_singleton()->print(" --convert-3to4 [<max_file_kb>] [<max_line_size>] Converts project from Godot 3.x to Godot 4.x.\n"); + OS::get_singleton()->print(" --validate-conversion-3to4 [<max_file_kb>] [<max_line_size>] Shows what elements will be renamed when converting project from Godot 3.x to Godot 4.x.\n"); OS::get_singleton()->print(" --doctool [<path>] Dump the engine API reference to the given <path> (defaults to current dir) in XML format, merging if existing files are found.\n"); OS::get_singleton()->print(" --no-docbase Disallow dumping the base types (used with --doctool).\n"); OS::get_singleton()->print(" --build-solutions Build the scripting solutions (e.g. for C# projects). Implies --editor and requires a valid project to edit.\n"); @@ -1086,10 +1088,32 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph // Actually handling is done in start(). cmdline_tool = true; main_args.push_back(I->get()); + + if (I->next() && !I->next()->get().begins_with("-")) { + if (itos(I->next()->get().to_int()) == I->next()->get()) { + converter_max_kb_file = I->next()->get().to_int(); + } + if (I->next()->next() && !I->next()->next()->get().begins_with("-")) { + if (itos(I->next()->next()->get().to_int()) == I->next()->next()->get()) { + converter_max_line_length = I->next()->next()->get().to_int(); + } + } + } } else if (I->get() == "--validate-conversion-3to4") { // Actually handling is done in start(). cmdline_tool = true; main_args.push_back(I->get()); + + if (I->next() && !I->next()->get().begins_with("-")) { + if (itos(I->next()->get().to_int()) == I->next()->get()) { + converter_max_kb_file = I->next()->get().to_int(); + } + if (I->next()->next() && !I->next()->next()->get().begins_with("-")) { + if (itos(I->next()->next()->get().to_int()) == I->next()->next()->get()) { + converter_max_line_length = I->next()->next()->get().to_int(); + } + } + } } else if (I->get() == "--doctool") { // Actually handling is done in start(). cmdline_tool = true; @@ -2342,7 +2366,7 @@ bool Main::start() { // Custom modules are always located by absolute path. String path = _doc_data_class_paths[i].path; if (path.is_relative_path()) { - path = doc_tool_path.plus_file(path); + path = doc_tool_path.path_join(path); } String name = _doc_data_class_paths[i].name; doc_data_classes[name] = path; @@ -2360,7 +2384,7 @@ bool Main::start() { } } - String index_path = doc_tool_path.plus_file("doc/classes"); + String index_path = doc_tool_path.path_join("doc/classes"); // Create the main documentation directory if it doesn't exist Ref<DirAccess> da = DirAccess::create_for_path(index_path); err = da->make_dir_recursive(index_path); @@ -2394,12 +2418,12 @@ bool Main::start() { } if (converting_project) { - int exit_code = ProjectConverter3To4().convert(); + int exit_code = ProjectConverter3To4(converter_max_kb_file, converter_max_line_length).convert(); OS::get_singleton()->set_exit_code(exit_code); return false; } if (validating_converting_project) { - int exit_code = ProjectConverter3To4().validate_conversion(); + int exit_code = ProjectConverter3To4(converter_max_kb_file, converter_max_line_length).validate_conversion(); OS::get_singleton()->set_exit_code(exit_code); return false; } @@ -2730,11 +2754,11 @@ bool Main::start() { if (sep == -1) { Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - local_game_path = da->get_current_dir().plus_file(local_game_path); + local_game_path = da->get_current_dir().path_join(local_game_path); } else { Ref<DirAccess> da = DirAccess::open(local_game_path.substr(0, sep)); if (da.is_valid()) { - local_game_path = da->get_current_dir().plus_file( + local_game_path = da->get_current_dir().path_join( local_game_path.substr(sep + 1, local_game_path.length())); } } diff --git a/misc/hooks/README.md b/misc/hooks/README.md index 8732237244..ea94b3f5f3 100644 --- a/misc/hooks/README.md +++ b/misc/hooks/README.md @@ -35,3 +35,8 @@ so they should work out of the box on Linux/macOS. ##### black - Python installation: make sure Python is added to the `PATH` - Install `black` - in any console: `pip3 install black` + +## Custom hooks + +The pre-commit hook will run any other script in `.git/hooks` whose filename +matches `pre-commit-custom-*`, after the Godot ones. diff --git a/misc/hooks/pre-commit b/misc/hooks/pre-commit index ab0fc8176f..6359161260 100755 --- a/misc/hooks/pre-commit +++ b/misc/hooks/pre-commit @@ -13,8 +13,8 @@ # pre-commit hooks to be executed. They should be in the same .git/hooks/ folder # as this script. Hooks should return 0 if successful and nonzero to cancel the # commit. They are executed in the order in which they are listed. -#HOOKS="pre-commit-compile pre-commit-uncrustify" HOOKS="pre-commit-clang-format pre-commit-black pre-commit-make-rst" +HOOKS="$HOOKS $(find $(dirname -- "$0") -type f -name 'pre-commit-custom-*' -exec basename {} \;)" ########################################################### # There should be no need to change anything below this line. diff --git a/misc/hooks/pre-commit-black b/misc/hooks/pre-commit-black index fd93bfe73c..b7335685ae 100755 --- a/misc/hooks/pre-commit-black +++ b/misc/hooks/pre-commit-black @@ -70,7 +70,7 @@ if [ ! -x "$BLACK" ] ; then $XMSG -center -title "Error" "Error: black executable not found." exit 1 elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then - winmessage="$(canonicalize_filename "./.git/hooks/winmessage.ps1")" + winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -center -title "Error" --text "Error: black executable not found." exit 1 fi @@ -160,7 +160,7 @@ while true; do yn="N" fi elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then - winmessage="$(canonicalize_filename "./.git/hooks/winmessage.ps1")" + winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?" choice=$? if [ "$choice" = "100" ] ; then diff --git a/misc/hooks/pre-commit-clang-format b/misc/hooks/pre-commit-clang-format index e8e62e6470..44b6f59132 100755 --- a/misc/hooks/pre-commit-clang-format +++ b/misc/hooks/pre-commit-clang-format @@ -90,7 +90,7 @@ if [ ! -x "$CLANG_FORMAT" ] ; then $XMSG -center -title "Error" "$message" exit 1 elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then - winmessage="$(canonicalize_filename "./.git/hooks/winmessage.ps1")" + winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -center -title "Error" --text "$message" exit 1 fi @@ -200,7 +200,7 @@ while true; do yn="N" fi elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then - winmessage="$(canonicalize_filename "./.git/hooks/winmessage.ps1")" + winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?" choice=$? if [ "$choice" = "100" ] ; then diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 95fc9b34a0..02922086f0 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -279,23 +279,24 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l in_number = true; } - // Special cases for numbers: Unary operators, separator '_', decimal point '.', literals '0x' and '0b', and scientific notation 'e'. + // Special cases for numbers if (in_number && !is_a_digit) { - if ((str[j] == '+' || str[j] == '-') && j > 0 && str[j - 1] == 'e' && !prev_is_digit) { - in_number = true; - } else if ((str[j] == 'e' || str[j] == '_' || str[j] == '.') && prev_is_digit) { - in_number = true; - } else if ((str[j] == 'b' || str[j] == 'x') && (j > 0 && str[j - 1] == '0')) { - in_number = true; - if (str[j] == 'b') { - is_bin_notation = true; - } else if (str[j] == 'x') { - is_hex_notation = true; - } - } else { + if (str[j] == 'b' && str[j - 1] == '0') { + is_bin_notation = true; + } else if (str[j] == 'x' && str[j - 1] == '0') { + is_hex_notation = true; + } else if (!((str[j] == '-' || str[j] == '+') && str[j - 1] == 'e' && !prev_is_digit) && + !(str[j] == '_' && (prev_is_digit || str[j - 1] == 'b' || str[j - 1] == 'x' || str[j - 1] == '.')) && + !((str[j] == 'e' || str[j] == '.') && (prev_is_digit || str[j - 1] == '_')) && + !((str[j] == '-' || str[j] == '+' || str[j] == '~') && !prev_is_binary_op && str[j - 1] != 'e')) { + /* 1st row of condition: '+' or '-' after scientific notation; + 2nd row of condition: '_' as a numeric separator; + 3rd row of condition: Scientific notation 'e' and floating points; + 4th row of condition: Multiple unary operators. */ in_number = false; } - } else if ((str[j] == '.' || str[j] == '+' || str[j] == '-' || str[j] == '~') && !is_binary_op) { + } else if ((str[j] == '-' || str[j] == '+' || str[j] == '~' || (str[j] == '.' && str[j + 1] != '.' && (j == 0 || (j > 0 && str[j - 1] != '.')))) && !is_binary_op) { + // Start a number from unary mathematical operators and floating points, except for '..' in_number = true; } diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index cf2d6ae9f8..10babad378 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -683,7 +683,7 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderSc if (base.is_empty() || base.is_relative_path()) { ERR_PRINT(("Could not resolve relative path for parent class: " + path).utf8().get_data()); } else { - path = base.get_base_dir().plus_file(path); + path = base.get_base_dir().path_join(path); } } } else if (c->extends.size() != 0) { @@ -2204,7 +2204,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b if (c->icon_path.is_empty() || c->icon_path.is_absolute_path()) { *r_icon_path = c->icon_path; } else if (c->icon_path.is_relative_path()) { - *r_icon_path = p_path.get_base_dir().plus_file(c->icon_path).simplify_path(); + *r_icon_path = p_path.get_base_dir().path_join(c->icon_path).simplify_path(); } } if (r_base_type) { @@ -2232,7 +2232,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b } String subpath = subclass->extends_path; if (subpath.is_relative_path()) { - subpath = path.get_base_dir().plus_file(subpath).simplify_path(); + subpath = path.get_base_dir().path_join(subpath).simplify_path(); } if (OK != subparser.parse(subsource, subpath, false)) { diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index a07d4855f3..c8c876369f 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -260,7 +260,7 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class, if (!p_class->extends_path.is_empty()) { if (p_class->extends_path.is_relative_path()) { - p_class->extends_path = class_type.script_path.get_base_dir().plus_file(p_class->extends_path).simplify_path(); + p_class->extends_path = class_type.script_path.get_base_dir().path_join(p_class->extends_path).simplify_path(); } Ref<GDScriptParserRef> parser = get_parser_for(p_class->extends_path); if (parser.is_null()) { @@ -3185,7 +3185,7 @@ void GDScriptAnalyzer::reduce_preload(GDScriptParser::PreloadNode *p_preload) { p_preload->resolved_path = p_preload->path->reduced_value; // TODO: Save this as script dependency. if (p_preload->resolved_path.is_relative_path()) { - p_preload->resolved_path = parser->script_path.get_base_dir().plus_file(p_preload->resolved_path); + p_preload->resolved_path = parser->script_path.get_base_dir().path_join(p_preload->resolved_path); } p_preload->resolved_path = p_preload->resolved_path.simplify_path(); if (!FileAccess::exists(p_preload->resolved_path)) { diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 44b60369ab..fd213e7b37 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -228,9 +228,9 @@ void GDScriptWorkspace::list_script_files(const String &p_root_dir, List<String> String file_name = dir->get_next(); while (file_name.length()) { if (dir->current_is_dir() && file_name != "." && file_name != ".." && file_name != "./") { - list_script_files(p_root_dir.plus_file(file_name), r_files); + list_script_files(p_root_dir.path_join(file_name), r_files); } else if (file_name.ends_with(".gd")) { - String script_file = p_root_dir.plus_file(file_name); + String script_file = p_root_dir.path_join(file_name); r_files.push_back(script_file); } file_name = dir->get_next(); diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp index e3b956369d..6c346acb7e 100644 --- a/modules/gdscript/tests/gdscript_test_runner.cpp +++ b/modules/gdscript/tests/gdscript_test_runner.cpp @@ -247,7 +247,7 @@ bool GDScriptTestRunner::make_tests_for_dir(const String &p_dir) { next = dir->get_next(); continue; } - if (!make_tests_for_dir(current_dir.plus_file(next))) { + if (!make_tests_for_dir(current_dir.path_join(next))) { return false; } } else { @@ -255,7 +255,7 @@ bool GDScriptTestRunner::make_tests_for_dir(const String &p_dir) { #ifndef DEBUG_ENABLED // On release builds, skip tests marked as debug only. Error open_err = OK; - Ref<FileAccess> script_file(FileAccess::open(current_dir.plus_file(next), FileAccess::READ, &open_err)); + Ref<FileAccess> script_file(FileAccess::open(current_dir.path_join(next), FileAccess::READ, &open_err)); if (open_err != OK) { ERR_PRINT(vformat(R"(Couldn't open test file "%s".)", next)); next = dir->get_next(); @@ -272,7 +272,7 @@ bool GDScriptTestRunner::make_tests_for_dir(const String &p_dir) { if (!is_generating && !dir->file_exists(out_file)) { ERR_FAIL_V_MSG(false, "Could not find output file for " + next); } - GDScriptTest test(current_dir.plus_file(next), current_dir.plus_file(out_file), source_dir); + GDScriptTest test(current_dir.path_join(next), current_dir.path_join(out_file), source_dir); tests.push_back(test); } } diff --git a/modules/gltf/doc_classes/GLTFCamera.xml b/modules/gltf/doc_classes/GLTFCamera.xml index b90abd105d..49efaa1564 100644 --- a/modules/gltf/doc_classes/GLTFCamera.xml +++ b/modules/gltf/doc_classes/GLTFCamera.xml @@ -10,6 +10,34 @@ <link title="GLTF camera detailed specification">https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-camera</link> <link title="GLTF camera spec and example file">https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_015_SimpleCameras.md</link> </tutorials> + <methods> + <method name="from_dictionary" qualifiers="static"> + <return type="GLTFCamera" /> + <param index="0" name="dictionary" type="Dictionary" /> + <description> + Creates a new GLTFCamera instance by parsing the given [Dictionary]. + </description> + </method> + <method name="from_node" qualifiers="static"> + <return type="GLTFCamera" /> + <param index="0" name="camera_node" type="Camera3D" /> + <description> + Create a new GLTFCamera instance from the given Godot [Camera3D] node. + </description> + </method> + <method name="to_dictionary" qualifiers="const"> + <return type="Dictionary" /> + <description> + Serializes this GLTFCamera instance into a [Dictionary]. + </description> + </method> + <method name="to_node" qualifiers="const"> + <return type="Camera3D" /> + <description> + Converts this GLTFCamera instance into a Godot [Camera3D] node. + </description> + </method> + </methods> <members> <member name="depth_far" type="float" setter="set_depth_far" getter="get_depth_far" default="4000.0"> The distance to the far culling boundary for this camera relative to its local Z axis, in meters. This maps to GLTF's [code]zfar[/code] property. diff --git a/modules/gltf/doc_classes/GLTFLight.xml b/modules/gltf/doc_classes/GLTFLight.xml index db2dfb487a..7fd59e14bc 100644 --- a/modules/gltf/doc_classes/GLTFLight.xml +++ b/modules/gltf/doc_classes/GLTFLight.xml @@ -9,6 +9,34 @@ <tutorials> <link title="KHR_lights_punctual GLTF extension spec">https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual</link> </tutorials> + <methods> + <method name="from_dictionary" qualifiers="static"> + <return type="GLTFLight" /> + <param index="0" name="dictionary" type="Dictionary" /> + <description> + Creates a new GLTFLight instance by parsing the given [Dictionary]. + </description> + </method> + <method name="from_node" qualifiers="static"> + <return type="GLTFLight" /> + <param index="0" name="light_node" type="Light3D" /> + <description> + Create a new GLTFLight instance from the given Godot [Light3D] node. + </description> + </method> + <method name="to_dictionary" qualifiers="const"> + <return type="Dictionary" /> + <description> + Serializes this GLTFLight instance into a [Dictionary]. + </description> + </method> + <method name="to_node" qualifiers="const"> + <return type="Light3D" /> + <description> + Converts this GLTFLight instance into a Godot [Light3D] node. + </description> + </method> + </methods> <members> <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> The [Color] of the light. Defaults to white. A black color causes the light to have no effect. diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp index 707769da35..ab52761e17 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.cpp +++ b/modules/gltf/editor/editor_scene_importer_blend.cpp @@ -64,7 +64,7 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_ // Escape paths to be valid Python strings to embed in the script. const String source_global = ProjectSettings::get_singleton()->globalize_path(p_path).c_escape(); - const String sink = ProjectSettings::get_singleton()->get_imported_files_path().plus_file( + const String sink = ProjectSettings::get_singleton()->get_imported_files_path().path_join( vformat("%s-%s.gltf", p_path.get_file().get_basename(), p_path.md5_text())); const String sink_global = ProjectSettings::get_singleton()->globalize_path(sink).c_escape(); @@ -193,9 +193,9 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_ String blender_path = EDITOR_GET("filesystem/import/blender/blender3_path"); #ifdef WINDOWS_ENABLED - blender_path = blender_path.plus_file("blender.exe"); + blender_path = blender_path.path_join("blender.exe"); #else - blender_path = blender_path.plus_file("blender"); + blender_path = blender_path.path_join("blender"); #endif List<String> args; @@ -287,14 +287,14 @@ void EditorSceneFormatImporterBlend::get_import_options(const String &p_path, Li static bool _test_blender_path(const String &p_path, String *r_err = nullptr) { String path = p_path; #ifdef WINDOWS_ENABLED - path = path.plus_file("blender.exe"); + path = path.path_join("blender.exe"); #else - path = path.plus_file("blender"); + path = path.path_join("blender"); #endif #if defined(MACOS_ENABLED) if (!FileAccess::exists(path)) { - path = path.plus_file("Blender"); + path = path.path_join("Blender"); } #endif @@ -485,7 +485,7 @@ bool EditorFileSystemImportFormatSupportQueryBlend::query() { bool found = false; for (const String &path : mdfind_paths) { - found = _autodetect_path(path.plus_file("Contents/MacOS")); + found = _autodetect_path(path.path_join("Contents/MacOS")); if (found) { break; } diff --git a/modules/gltf/editor/editor_scene_importer_fbx.cpp b/modules/gltf/editor/editor_scene_importer_fbx.cpp index faad2d315d..017a44cccf 100644 --- a/modules/gltf/editor/editor_scene_importer_fbx.cpp +++ b/modules/gltf/editor/editor_scene_importer_fbx.cpp @@ -57,7 +57,7 @@ Node *EditorSceneFormatImporterFBX::import_scene(const String &p_path, uint32_t // enclosed in double quotes by OS::execute(), so we only need to escape those. // `c_escape_multiline()` seems to do this (escapes `\` and `"` only). const String source_global = ProjectSettings::get_singleton()->globalize_path(p_path).c_escape_multiline(); - const String sink = ProjectSettings::get_singleton()->get_imported_files_path().plus_file( + const String sink = ProjectSettings::get_singleton()->get_imported_files_path().path_join( vformat("%s-%s.glb", p_path.get_file().get_basename(), p_path.md5_text())); const String sink_global = ProjectSettings::get_singleton()->globalize_path(sink).c_escape_multiline(); diff --git a/modules/gltf/extensions/gltf_light.cpp b/modules/gltf/extensions/gltf_light.cpp index af21a4e804..ab5a15c671 100644 --- a/modules/gltf/extensions/gltf_light.cpp +++ b/modules/gltf/extensions/gltf_light.cpp @@ -31,6 +31,12 @@ #include "gltf_light.h" void GLTFLight::_bind_methods() { + ClassDB::bind_static_method("GLTFLight", D_METHOD("from_node", "light_node"), &GLTFLight::from_node); + ClassDB::bind_method(D_METHOD("to_node"), &GLTFLight::to_node); + + ClassDB::bind_static_method("GLTFLight", D_METHOD("from_dictionary", "dictionary"), &GLTFLight::from_dictionary); + ClassDB::bind_method(D_METHOD("to_dictionary"), &GLTFLight::to_dictionary); + ClassDB::bind_method(D_METHOD("get_color"), &GLTFLight::get_color); ClassDB::bind_method(D_METHOD("set_color", "color"), &GLTFLight::set_color); ClassDB::bind_method(D_METHOD("get_intensity"), &GLTFLight::get_intensity); @@ -99,3 +105,116 @@ float GLTFLight::get_outer_cone_angle() { void GLTFLight::set_outer_cone_angle(float p_outer_cone_angle) { outer_cone_angle = p_outer_cone_angle; } + +Ref<GLTFLight> GLTFLight::from_node(const Light3D *p_light) { + Ref<GLTFLight> l; + l.instantiate(); + l->color = p_light->get_color(); + if (cast_to<DirectionalLight3D>(p_light)) { + l->light_type = "directional"; + const DirectionalLight3D *light = cast_to<const DirectionalLight3D>(p_light); + l->intensity = light->get_param(DirectionalLight3D::PARAM_ENERGY); + l->range = FLT_MAX; // Range for directional lights is infinite in Godot. + } else if (cast_to<const OmniLight3D>(p_light)) { + l->light_type = "point"; + const OmniLight3D *light = cast_to<const OmniLight3D>(p_light); + l->range = light->get_param(OmniLight3D::PARAM_RANGE); + l->intensity = light->get_param(OmniLight3D::PARAM_ENERGY); + } else if (cast_to<const SpotLight3D>(p_light)) { + l->light_type = "spot"; + const SpotLight3D *light = cast_to<const SpotLight3D>(p_light); + l->range = light->get_param(SpotLight3D::PARAM_RANGE); + l->intensity = light->get_param(SpotLight3D::PARAM_ENERGY); + l->outer_cone_angle = Math::deg_to_rad(light->get_param(SpotLight3D::PARAM_SPOT_ANGLE)); + // This equation is the inverse of the import equation (which has a desmos link). + float angle_ratio = 1 - (0.2 / (0.1 + light->get_param(SpotLight3D::PARAM_SPOT_ATTENUATION))); + angle_ratio = MAX(0, angle_ratio); + l->inner_cone_angle = l->outer_cone_angle * angle_ratio; + } + return l; +} + +Light3D *GLTFLight::to_node() const { + if (light_type == "directional") { + DirectionalLight3D *light = memnew(DirectionalLight3D); + light->set_param(Light3D::PARAM_ENERGY, intensity); + light->set_color(color); + return light; + } + const float range = CLAMP(this->range, 0, 4096); + if (light_type == "point") { + OmniLight3D *light = memnew(OmniLight3D); + light->set_param(OmniLight3D::PARAM_ENERGY, intensity); + light->set_param(OmniLight3D::PARAM_RANGE, range); + light->set_color(color); + return light; + } + if (light_type == "spot") { + SpotLight3D *light = memnew(SpotLight3D); + light->set_param(SpotLight3D::PARAM_ENERGY, intensity); + light->set_param(SpotLight3D::PARAM_RANGE, range); + light->set_param(SpotLight3D::PARAM_SPOT_ANGLE, Math::rad_to_deg(outer_cone_angle)); + light->set_color(color); + // Line of best fit derived from guessing, see https://www.desmos.com/calculator/biiflubp8b + // The points in desmos are not exact, except for (1, infinity). + float angle_ratio = inner_cone_angle / outer_cone_angle; + float angle_attenuation = 0.2 / (1 - angle_ratio) - 0.1; + light->set_param(SpotLight3D::PARAM_SPOT_ATTENUATION, angle_attenuation); + return light; + } + return memnew(Light3D); +} + +Ref<GLTFLight> GLTFLight::from_dictionary(const Dictionary p_dictionary) { + ERR_FAIL_COND_V_MSG(!p_dictionary.has("type"), Ref<GLTFLight>(), "Failed to parse GLTF light, missing required field 'type'."); + Ref<GLTFLight> light; + light.instantiate(); + const String &type = p_dictionary["type"]; + light->light_type = type; + + if (p_dictionary.has("color")) { + const Array &arr = p_dictionary["color"]; + if (arr.size() == 3) { + light->color = Color(arr[0], arr[1], arr[2]).linear_to_srgb(); + } else { + ERR_PRINT("Error parsing GLTF light: The color must have exactly 3 numbers."); + } + } + if (p_dictionary.has("intensity")) { + light->intensity = p_dictionary["intensity"]; + } + if (p_dictionary.has("range")) { + light->range = p_dictionary["range"]; + } + if (type == "spot") { + const Dictionary &spot = p_dictionary["spot"]; + light->inner_cone_angle = spot["innerConeAngle"]; + light->outer_cone_angle = spot["outerConeAngle"]; + if (light->inner_cone_angle >= light->outer_cone_angle) { + ERR_PRINT("Error parsing GLTF light: The inner angle must be smaller than the outer angle."); + } + } else if (type != "point" && type != "directional") { + ERR_PRINT("Error parsing GLTF light: Light type '" + type + "' is unknown."); + } + return light; +} + +Dictionary GLTFLight::to_dictionary() const { + Dictionary d; + Array color_array; + color_array.resize(3); + color_array[0] = color.r; + color_array[1] = color.g; + color_array[2] = color.b; + d["color"] = color_array; + d["type"] = light_type; + if (light_type == "spot") { + Dictionary spot_dict; + spot_dict["innerConeAngle"] = inner_cone_angle; + spot_dict["outerConeAngle"] = outer_cone_angle; + d["spot"] = spot_dict; + } + d["intensity"] = intensity; + d["range"] = range; + return d; +} diff --git a/modules/gltf/extensions/gltf_light.h b/modules/gltf/extensions/gltf_light.h index f0765a1bbc..04980e144c 100644 --- a/modules/gltf/extensions/gltf_light.h +++ b/modules/gltf/extensions/gltf_light.h @@ -70,6 +70,12 @@ public: float get_outer_cone_angle(); void set_outer_cone_angle(float p_outer_cone_angle); + + static Ref<GLTFLight> from_node(const Light3D *p_light); + Light3D *to_node() const; + + static Ref<GLTFLight> from_dictionary(const Dictionary p_dictionary); + Dictionary to_dictionary() const; }; #endif // GLTF_LIGHT_H diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 87ba1d9869..0ed212e21f 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -786,7 +786,7 @@ Error GLTFDocument::_parse_buffers(Ref<GLTFState> state, const String &p_base_pa } else { // Relative path to an external image file. ERR_FAIL_COND_V(p_base_path.is_empty(), ERR_INVALID_PARAMETER); uri = uri.uri_decode(); - uri = p_base_path.plus_file(uri).replace("\\", "/"); // Fix for Windows. + uri = p_base_path.path_join(uri).replace("\\", "/"); // Fix for Windows. buffer_data = FileAccess::get_file_as_array(uri); ERR_FAIL_COND_V_MSG(buffer.size() == 0, ERR_PARSE_ERROR, "glTF: Couldn't load binary file as an array: " + uri); } @@ -3039,8 +3039,8 @@ Error GLTFDocument::_serialize_images(Ref<GLTFState> state, const String &p_path if (!da->dir_exists(new_texture_dir)) { da->make_dir(new_texture_dir); } - image->save_png(new_texture_dir.plus_file(name)); - d["uri"] = texture_dir.plus_file(name).uri_encode(); + image->save_png(new_texture_dir.path_join(name)); + d["uri"] = texture_dir.path_join(name).uri_encode(); } images.push_back(d); } @@ -3118,7 +3118,7 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> state, const String &p_base_pat } else { // Relative path to an external image file. ERR_FAIL_COND_V(p_base_path.is_empty(), ERR_INVALID_PARAMETER); uri = uri.uri_decode(); - uri = p_base_path.plus_file(uri).replace("\\", "/"); // Fix for Windows. + uri = p_base_path.path_join(uri).replace("\\", "/"); // Fix for Windows. // ResourceLoader will rely on the file extension to use the relevant loader. // The spec says that if mimeType is defined, it should take precedence (e.g. // there could be a `.png` image which is actually JPEG), but there's no easy @@ -4534,28 +4534,7 @@ Error GLTFDocument::_serialize_lights(Ref<GLTFState> state) { } Array lights; for (GLTFLightIndex i = 0; i < state->lights.size(); i++) { - Dictionary d; - Ref<GLTFLight> light = state->lights[i]; - Array color; - color.resize(3); - color[0] = light->color.r; - color[1] = light->color.g; - color[2] = light->color.b; - d["color"] = color; - d["type"] = light->light_type; - if (light->light_type == "spot") { - Dictionary s; - float inner_cone_angle = light->inner_cone_angle; - s["innerConeAngle"] = inner_cone_angle; - float outer_cone_angle = light->outer_cone_angle; - s["outerConeAngle"] = outer_cone_angle; - d["spot"] = s; - } - float intensity = light->intensity; - d["intensity"] = intensity; - float range = light->range; - d["range"] = range; - lights.push_back(d); + lights.push_back(state->lights[i]->to_dictionary()); } Dictionary extensions; @@ -4577,27 +4556,7 @@ Error GLTFDocument::_serialize_cameras(Ref<GLTFState> state) { Array cameras; cameras.resize(state->cameras.size()); for (GLTFCameraIndex i = 0; i < state->cameras.size(); i++) { - Dictionary d; - - Ref<GLTFCamera> camera = state->cameras[i]; - - if (camera->get_perspective()) { - Dictionary persp; - persp["yfov"] = camera->get_fov(); - persp["zfar"] = camera->get_depth_far(); - persp["znear"] = camera->get_depth_near(); - d["perspective"] = persp; - d["type"] = "perspective"; - } else { - Dictionary ortho; - ortho["ymag"] = camera->get_size_mag(); - ortho["xmag"] = camera->get_size_mag(); - ortho["zfar"] = camera->get_depth_far(); - ortho["znear"] = camera->get_depth_near(); - d["orthographic"] = ortho; - d["type"] = "orthographic"; - } - cameras[i] = d; + cameras[i] = state->cameras[i]->to_dictionary(); } if (!state->cameras.size()) { @@ -4627,35 +4586,10 @@ Error GLTFDocument::_parse_lights(Ref<GLTFState> state) { const Array &lights = lights_punctual["lights"]; for (GLTFLightIndex light_i = 0; light_i < lights.size(); light_i++) { - const Dictionary &d = lights[light_i]; - - Ref<GLTFLight> light; - light.instantiate(); - ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR); - const String &type = d["type"]; - light->light_type = type; - - if (d.has("color")) { - const Array &arr = d["color"]; - ERR_FAIL_COND_V(arr.size() != 3, ERR_PARSE_ERROR); - const Color c = Color(arr[0], arr[1], arr[2]).linear_to_srgb(); - light->color = c; - } - if (d.has("intensity")) { - light->intensity = d["intensity"]; + Ref<GLTFLight> light = GLTFLight::from_dictionary(lights[light_i]); + if (light.is_null()) { + return Error::ERR_PARSE_ERROR; } - if (d.has("range")) { - light->range = d["range"]; - } - if (type == "spot") { - const Dictionary &spot = d["spot"]; - light->inner_cone_angle = spot["innerConeAngle"]; - light->outer_cone_angle = spot["outerConeAngle"]; - ERR_CONTINUE_MSG(light->inner_cone_angle >= light->outer_cone_angle, "The inner angle must be smaller than the outer angle."); - } else if (type != "point" && type != "directional") { - ERR_CONTINUE_MSG(true, "Light type is unknown."); - } - state->lights.push_back(light); } @@ -4672,35 +4606,7 @@ Error GLTFDocument::_parse_cameras(Ref<GLTFState> state) { const Array cameras = state->json["cameras"]; for (GLTFCameraIndex i = 0; i < cameras.size(); i++) { - const Dictionary &d = cameras[i]; - - Ref<GLTFCamera> camera; - camera.instantiate(); - ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR); - const String &type = d["type"]; - if (type == "perspective") { - camera->set_perspective(true); - if (d.has("perspective")) { - const Dictionary &persp = d["perspective"]; - camera->set_fov(persp["yfov"]); - if (persp.has("zfar")) { - camera->set_depth_far(persp["zfar"]); - } - camera->set_depth_near(persp["znear"]); - } - } else if (type == "orthographic") { - camera->set_perspective(false); - if (d.has("orthographic")) { - const Dictionary &ortho = d["orthographic"]; - camera->set_size_mag(ortho["ymag"]); - camera->set_depth_far(ortho["zfar"]); - camera->set_depth_near(ortho["znear"]); - } - } else { - ERR_FAIL_V_MSG(ERR_PARSE_ERROR, "Camera3D should be in 'orthographic' or 'perspective'"); - } - - state->cameras.push_back(camera); + state->cameras.push_back(GLTFCamera::from_dictionary(cameras[i])); } print_verbose("glTF: Total cameras: " + itos(state->cameras.size())); @@ -5148,45 +5054,7 @@ Node3D *GLTFDocument::_generate_light(Ref<GLTFState> state, const GLTFNodeIndex print_verbose("glTF: Creating light for: " + gltf_node->get_name()); Ref<GLTFLight> l = state->lights[gltf_node->light]; - - float intensity = l->intensity; - if (intensity > 10) { - // GLTF spec has the default around 1, but Blender defaults lights to 100. - // The only sane way to handle this is to check where it came from and - // handle it accordingly. If it's over 10, it probably came from Blender. - intensity /= 100; - } - - if (l->light_type == "directional") { - DirectionalLight3D *light = memnew(DirectionalLight3D); - light->set_param(Light3D::PARAM_ENERGY, intensity); - light->set_color(l->color); - return light; - } - - const float range = CLAMP(l->range, 0, 4096); - if (l->light_type == "point") { - OmniLight3D *light = memnew(OmniLight3D); - light->set_param(OmniLight3D::PARAM_ENERGY, intensity); - light->set_param(OmniLight3D::PARAM_RANGE, range); - light->set_color(l->color); - return light; - } - if (l->light_type == "spot") { - SpotLight3D *light = memnew(SpotLight3D); - light->set_param(SpotLight3D::PARAM_ENERGY, intensity); - light->set_param(SpotLight3D::PARAM_RANGE, range); - light->set_param(SpotLight3D::PARAM_SPOT_ANGLE, Math::rad_to_deg(l->outer_cone_angle)); - light->set_color(l->color); - - // Line of best fit derived from guessing, see https://www.desmos.com/calculator/biiflubp8b - // The points in desmos are not exact, except for (1, infinity). - float angle_ratio = l->inner_cone_angle / l->outer_cone_angle; - float angle_attenuation = 0.2 / (1 - angle_ratio) - 0.1; - light->set_param(SpotLight3D::PARAM_SPOT_ATTENUATION, angle_attenuation); - return light; - } - return memnew(Node3D); + return l->to_node(); } Camera3D *GLTFDocument::_generate_camera(Ref<GLTFState> state, const GLTFNodeIndex node_index) { @@ -5194,32 +5062,16 @@ Camera3D *GLTFDocument::_generate_camera(Ref<GLTFState> state, const GLTFNodeInd ERR_FAIL_INDEX_V(gltf_node->camera, state->cameras.size(), nullptr); - Camera3D *camera = memnew(Camera3D); print_verbose("glTF: Creating camera for: " + gltf_node->get_name()); Ref<GLTFCamera> c = state->cameras[gltf_node->camera]; - camera->set_projection(c->get_perspective() ? Camera3D::PROJECTION_PERSPECTIVE : Camera3D::PROJECTION_ORTHOGONAL); - // GLTF spec (yfov) is in radians, Godot's camera (fov) is in degrees. - camera->set_fov(Math::rad_to_deg(c->get_fov())); - // GLTF spec (xmag and ymag) is a radius in meters, Godot's camera (size) is a diameter in meters. - camera->set_size(c->get_size_mag() * 2.0f); - camera->set_near(c->get_depth_near()); - camera->set_far(c->get_depth_far()); - return camera; + return c->to_node(); } GLTFCameraIndex GLTFDocument::_convert_camera(Ref<GLTFState> state, Camera3D *p_camera) { print_verbose("glTF: Converting camera: " + p_camera->get_name()); - Ref<GLTFCamera> c; - c.instantiate(); - c->set_perspective(p_camera->get_projection() == Camera3D::ProjectionType::PROJECTION_PERSPECTIVE); - // GLTF spec (yfov) is in radians, Godot's camera (fov) is in degrees. - c->set_fov(Math::deg_to_rad(p_camera->get_fov())); - // GLTF spec (xmag and ymag) is a radius in meters, Godot's camera (size) is a diameter in meters. - c->set_size_mag(p_camera->get_size() * 0.5f); - c->set_depth_far(p_camera->get_far()); - c->set_depth_near(p_camera->get_near()); + Ref<GLTFCamera> c = GLTFCamera::from_node(p_camera); GLTFCameraIndex camera_index = state->cameras.size(); state->cameras.push_back(c); return camera_index; @@ -5228,31 +5080,7 @@ GLTFCameraIndex GLTFDocument::_convert_camera(Ref<GLTFState> state, Camera3D *p_ GLTFLightIndex GLTFDocument::_convert_light(Ref<GLTFState> state, Light3D *p_light) { print_verbose("glTF: Converting light: " + p_light->get_name()); - Ref<GLTFLight> l; - l.instantiate(); - l->color = p_light->get_color(); - if (cast_to<DirectionalLight3D>(p_light)) { - l->light_type = "directional"; - DirectionalLight3D *light = cast_to<DirectionalLight3D>(p_light); - l->intensity = light->get_param(DirectionalLight3D::PARAM_ENERGY); - l->range = FLT_MAX; // Range for directional lights is infinite in Godot. - } else if (cast_to<OmniLight3D>(p_light)) { - l->light_type = "point"; - OmniLight3D *light = cast_to<OmniLight3D>(p_light); - l->range = light->get_param(OmniLight3D::PARAM_RANGE); - l->intensity = light->get_param(OmniLight3D::PARAM_ENERGY); - } else if (cast_to<SpotLight3D>(p_light)) { - l->light_type = "spot"; - SpotLight3D *light = cast_to<SpotLight3D>(p_light); - l->range = light->get_param(SpotLight3D::PARAM_RANGE); - l->intensity = light->get_param(SpotLight3D::PARAM_ENERGY); - l->outer_cone_angle = Math::deg_to_rad(light->get_param(SpotLight3D::PARAM_SPOT_ANGLE)); - - // This equation is the inverse of the import equation (which has a desmos link). - float angle_ratio = 1 - (0.2 / (0.1 + light->get_param(SpotLight3D::PARAM_SPOT_ATTENUATION))); - angle_ratio = MAX(0, angle_ratio); - l->inner_cone_angle = l->outer_cone_angle * angle_ratio; - } + Ref<GLTFLight> l = GLTFLight::from_node(p_light); GLTFLightIndex light_index = state->lights.size(); state->lights.push_back(l); diff --git a/modules/gltf/structures/gltf_camera.cpp b/modules/gltf/structures/gltf_camera.cpp index c492913ea7..5069f39c4b 100644 --- a/modules/gltf/structures/gltf_camera.cpp +++ b/modules/gltf/structures/gltf_camera.cpp @@ -31,6 +31,12 @@ #include "gltf_camera.h" void GLTFCamera::_bind_methods() { + ClassDB::bind_static_method("GLTFCamera", D_METHOD("from_node", "camera_node"), &GLTFCamera::from_node); + ClassDB::bind_method(D_METHOD("to_node"), &GLTFCamera::to_node); + + ClassDB::bind_static_method("GLTFCamera", D_METHOD("from_dictionary", "dictionary"), &GLTFCamera::from_dictionary); + ClassDB::bind_method(D_METHOD("to_dictionary"), &GLTFCamera::to_dictionary); + ClassDB::bind_method(D_METHOD("get_perspective"), &GLTFCamera::get_perspective); ClassDB::bind_method(D_METHOD("set_perspective", "perspective"), &GLTFCamera::set_perspective); ClassDB::bind_method(D_METHOD("get_fov"), &GLTFCamera::get_fov); @@ -48,3 +54,78 @@ void GLTFCamera::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth_far"), "set_depth_far", "get_depth_far"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth_near"), "set_depth_near", "get_depth_near"); } + +Ref<GLTFCamera> GLTFCamera::from_node(const Camera3D *p_camera) { + Ref<GLTFCamera> c; + c.instantiate(); + c->set_perspective(p_camera->get_projection() == Camera3D::ProjectionType::PROJECTION_PERSPECTIVE); + // GLTF spec (yfov) is in radians, Godot's camera (fov) is in degrees. + c->set_fov(Math::deg_to_rad(p_camera->get_fov())); + // GLTF spec (xmag and ymag) is a radius in meters, Godot's camera (size) is a diameter in meters. + c->set_size_mag(p_camera->get_size() * 0.5f); + c->set_depth_far(p_camera->get_far()); + c->set_depth_near(p_camera->get_near()); + return c; +} + +Camera3D *GLTFCamera::to_node() const { + Camera3D *camera = memnew(Camera3D); + camera->set_projection(perspective ? Camera3D::PROJECTION_PERSPECTIVE : Camera3D::PROJECTION_ORTHOGONAL); + // GLTF spec (yfov) is in radians, Godot's camera (fov) is in degrees. + camera->set_fov(Math::rad_to_deg(fov)); + // GLTF spec (xmag and ymag) is a radius in meters, Godot's camera (size) is a diameter in meters. + camera->set_size(size_mag * 2.0f); + camera->set_near(depth_near); + camera->set_far(depth_far); + return camera; +} + +Ref<GLTFCamera> GLTFCamera::from_dictionary(const Dictionary p_dictionary) { + ERR_FAIL_COND_V_MSG(!p_dictionary.has("type"), Ref<GLTFCamera>(), "Failed to parse GLTF camera, missing required field 'type'."); + Ref<GLTFCamera> camera; + camera.instantiate(); + const String &type = p_dictionary["type"]; + if (type == "perspective") { + camera->set_perspective(true); + if (p_dictionary.has("perspective")) { + const Dictionary &persp = p_dictionary["perspective"]; + camera->set_fov(persp["yfov"]); + if (persp.has("zfar")) { + camera->set_depth_far(persp["zfar"]); + } + camera->set_depth_near(persp["znear"]); + } + } else if (type == "orthographic") { + camera->set_perspective(false); + if (p_dictionary.has("orthographic")) { + const Dictionary &ortho = p_dictionary["orthographic"]; + camera->set_size_mag(ortho["ymag"]); + camera->set_depth_far(ortho["zfar"]); + camera->set_depth_near(ortho["znear"]); + } + } else { + ERR_PRINT("Error parsing GLTF camera: Camera type '" + type + "' is unknown, should be perspective or orthographic."); + } + return camera; +} + +Dictionary GLTFCamera::to_dictionary() const { + Dictionary d; + if (perspective) { + Dictionary persp; + persp["yfov"] = fov; + persp["zfar"] = depth_far; + persp["znear"] = depth_near; + d["perspective"] = persp; + d["type"] = "perspective"; + } else { + Dictionary ortho; + ortho["ymag"] = size_mag; + ortho["xmag"] = size_mag; + ortho["zfar"] = depth_far; + ortho["znear"] = depth_near; + d["orthographic"] = ortho; + d["type"] = "orthographic"; + } + return d; +} diff --git a/modules/gltf/structures/gltf_camera.h b/modules/gltf/structures/gltf_camera.h index 8e528c063f..50ae10e17a 100644 --- a/modules/gltf/structures/gltf_camera.h +++ b/modules/gltf/structures/gltf_camera.h @@ -63,6 +63,12 @@ public: void set_depth_far(real_t p_val) { depth_far = p_val; } real_t get_depth_near() const { return depth_near; } void set_depth_near(real_t p_val) { depth_near = p_val; } + + static Ref<GLTFCamera> from_node(const Camera3D *p_light); + Camera3D *to_node() const; + + static Ref<GLTFCamera> from_dictionary(const Dictionary p_dictionary); + Dictionary to_dictionary() const; }; #endif // GLTF_CAMERA_H diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 8b135051c5..2e59987fe6 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -694,7 +694,7 @@ bool CSharpLanguage::is_assembly_reloading_needed() { } assembly_path = GodotSharpDirs::get_res_temp_assemblies_dir() - .plus_file(assembly_name + ".dll"); + .path_join(assembly_name + ".dll"); assembly_path = ProjectSettings::get_singleton()->globalize_path(assembly_path); if (!FileAccess::exists(assembly_path)) { @@ -1085,7 +1085,7 @@ void CSharpLanguage::_editor_init_callback() { const void **interop_funcs = godotsharp::get_editor_interop_funcs(interop_funcs_size); Object *editor_plugin_obj = GDMono::get_singleton()->get_plugin_callbacks().LoadToolsAssemblyCallback( - GodotSharpDirs::get_data_editor_tools_dir().plus_file("GodotTools.dll").utf16(), + GodotSharpDirs::get_data_editor_tools_dir().path_join("GodotTools.dll").utf16(), interop_funcs, interop_funcs_size); CRASH_COND(editor_plugin_obj == nullptr); diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index d70a1e6c88..0e496454a1 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -1315,7 +1315,7 @@ Error BindingsGenerator::generate_cs_api(const String &p_output_dir) { // Generate GodotSharp source files - String core_proj_dir = output_dir.plus_file(CORE_API_ASSEMBLY_NAME); + String core_proj_dir = output_dir.path_join(CORE_API_ASSEMBLY_NAME); proj_err = generate_cs_core_project(core_proj_dir); if (proj_err != OK) { @@ -1325,7 +1325,7 @@ Error BindingsGenerator::generate_cs_api(const String &p_output_dir) { // Generate GodotSharpEditor source files - String editor_proj_dir = output_dir.plus_file(EDITOR_API_ASSEMBLY_NAME); + String editor_proj_dir = output_dir.path_join(EDITOR_API_ASSEMBLY_NAME); proj_err = generate_cs_editor_project(editor_proj_dir); if (proj_err != OK) { @@ -3880,7 +3880,7 @@ static void handle_cmdline_options(String glue_dir_path) { CRASH_COND(glue_dir_path.is_empty()); - if (bindings_generator.generate_cs_api(glue_dir_path.plus_file(API_SOLUTION_NAME)) != OK) { + if (bindings_generator.generate_cs_api(glue_dir_path.path_join(API_SOLUTION_NAME)) != OK) { ERR_PRINT(generate_all_glue_option + ": Failed to generate the C# API."); } } diff --git a/modules/mono/editor/code_completion.cpp b/modules/mono/editor/code_completion.cpp index 36c46627e2..40296eef10 100644 --- a/modules/mono/editor/code_completion.cpp +++ b/modules/mono/editor/code_completion.cpp @@ -163,9 +163,9 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr } if (dir_access->dir_exists(filename)) { - directories.push_back(dir_access->get_current_dir().plus_file(filename)); + directories.push_back(dir_access->get_current_dir().path_join(filename)); } else if (filename.ends_with(".tscn") || filename.ends_with(".scn")) { - suggestions.push_back(quoted(dir_access->get_current_dir().plus_file(filename))); + suggestions.push_back(quoted(dir_access->get_current_dir().path_join(filename))); } filename = dir_access->get_next(); diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index 1ef78c3ac2..6f42ad6916 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -98,7 +98,7 @@ bool godot_icall_EditorProgress_Step(const godot_string *p_task, const godot_str } void godot_icall_Internal_FullExportTemplatesDir(godot_string *r_dest) { - String full_templates_dir = EditorPaths::get_singleton()->get_export_templates_dir().plus_file(VERSION_FULL_CONFIG); + String full_templates_dir = EditorPaths::get_singleton()->get_export_templates_dir().path_join(VERSION_FULL_CONFIG); memnew_placement(r_dest, String(full_templates_dir)); } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs index 94dda5a74b..e84bba1179 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs @@ -436,6 +436,15 @@ namespace Godot.NativeInterop public static partial void godotsharp_string_simplify_path(in godot_string p_self, out godot_string r_simplified_path); + public static partial void godotsharp_string_to_camel_case(in godot_string p_self, + out godot_string r_camel_case); + + public static partial void godotsharp_string_to_pascal_case(in godot_string p_self, + out godot_string r_pascal_case); + + public static partial void godotsharp_string_to_snake_case(in godot_string p_self, + out godot_string r_snake_case); + // NodePath public static partial void godotsharp_node_path_get_as_property_path(in godot_node_path p_self, diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs index 2ea3c18d26..26fffc079c 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs @@ -11,31 +11,31 @@ namespace Godot.NativeInterop case Variant.Type.Nil: return default; case Variant.Type.Bool: - return new godot_variant() { Bool = src.Bool }; + return new godot_variant() { Bool = src.Bool, Type = Variant.Type.Bool }; case Variant.Type.Int: - return new godot_variant() { Int = src.Int }; + return new godot_variant() { Int = src.Int, Type = Variant.Type.Int }; case Variant.Type.Float: - return new godot_variant() { Float = src.Float }; + return new godot_variant() { Float = src.Float, Type = Variant.Type.Float }; case Variant.Type.Vector2: - return new godot_variant() { Vector2 = src.Vector2 }; + return new godot_variant() { Vector2 = src.Vector2, Type = Variant.Type.Vector2 }; case Variant.Type.Vector2i: - return new godot_variant() { Vector2i = src.Vector2i }; + return new godot_variant() { Vector2i = src.Vector2i, Type = Variant.Type.Vector2i }; case Variant.Type.Rect2: - return new godot_variant() { Rect2 = src.Rect2 }; + return new godot_variant() { Rect2 = src.Rect2, Type = Variant.Type.Rect2 }; case Variant.Type.Rect2i: - return new godot_variant() { Rect2i = src.Rect2i }; + return new godot_variant() { Rect2i = src.Rect2i, Type = Variant.Type.Rect2i }; case Variant.Type.Vector3: - return new godot_variant() { Vector3 = src.Vector3 }; + return new godot_variant() { Vector3 = src.Vector3, Type = Variant.Type.Vector3 }; case Variant.Type.Vector3i: - return new godot_variant() { Vector3i = src.Vector3i }; + return new godot_variant() { Vector3i = src.Vector3i, Type = Variant.Type.Vector3i }; case Variant.Type.Plane: - return new godot_variant() { Plane = src.Plane }; + return new godot_variant() { Plane = src.Plane, Type = Variant.Type.Plane }; case Variant.Type.Quaternion: - return new godot_variant() { Quaternion = src.Quaternion }; + return new godot_variant() { Quaternion = src.Quaternion, Type = Variant.Type.Quaternion }; case Variant.Type.Color: - return new godot_variant() { Color = src.Color }; + return new godot_variant() { Color = src.Color, Type = Variant.Type.Color }; case Variant.Type.Rid: - return new godot_variant() { RID = src.RID }; + return new godot_variant() { RID = src.RID, Type = Variant.Type.Rid }; } godotsharp_variant_new_copy(out godot_variant ret, src); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index f0bc5949df..44f951e314 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -287,6 +287,45 @@ namespace Godot return cap; } + /// <summary> + /// Returns the string converted to <c>camelCase</c>. + /// </summary> + /// <param name="instance">The string to convert.</param> + /// <returns>The converted string.</returns> + public static string ToCamelCase(this string instance) + { + using godot_string instanceStr = Marshaling.ConvertStringToNative(instance); + NativeFuncs.godotsharp_string_to_camel_case(instanceStr, out godot_string camelCase); + using (camelCase) + return Marshaling.ConvertStringToManaged(camelCase); + } + + /// <summary> + /// Returns the string converted to <c>PascalCase</c>. + /// </summary> + /// <param name="instance">The string to convert.</param> + /// <returns>The converted string.</returns> + public static string ToPascalCase(this string instance) + { + using godot_string instanceStr = Marshaling.ConvertStringToNative(instance); + NativeFuncs.godotsharp_string_to_pascal_case(instanceStr, out godot_string pascalCase); + using (pascalCase) + return Marshaling.ConvertStringToManaged(pascalCase); + } + + /// <summary> + /// Returns the string converted to <c>snake_case</c>. + /// </summary> + /// <param name="instance">The string to convert.</param> + /// <returns>The converted string.</returns> + public static string ToSnakeCase(this string instance) + { + using godot_string instanceStr = Marshaling.ConvertStringToNative(instance); + NativeFuncs.godotsharp_string_to_snake_case(instanceStr, out godot_string snakeCase); + using (snakeCase) + return Marshaling.ConvertStringToManaged(snakeCase); + } + private static string CamelcaseToUnderscore(this string instance, bool lowerCase) { string newString = string.Empty; diff --git a/modules/mono/glue/runtime_interop.cpp b/modules/mono/glue/runtime_interop.cpp index 0d68cb54b9..529bda4c38 100644 --- a/modules/mono/glue/runtime_interop.cpp +++ b/modules/mono/glue/runtime_interop.cpp @@ -1096,6 +1096,18 @@ void godotsharp_string_simplify_path(const String *p_self, String *r_simplified_ memnew_placement(r_simplified_path, String(p_self->simplify_path())); } +void godotsharp_string_to_camel_case(const String *p_self, String *r_camel_case) { + memnew_placement(r_camel_case, String(p_self->to_camel_case())); +} + +void godotsharp_string_to_pascal_case(const String *p_self, String *r_pascal_case) { + memnew_placement(r_pascal_case, String(p_self->to_pascal_case())); +} + +void godotsharp_string_to_snake_case(const String *p_self, String *r_snake_case) { + memnew_placement(r_snake_case, String(p_self->to_snake_case())); +} + void godotsharp_node_path_get_as_property_path(const NodePath *p_ptr, NodePath *r_dest) { memnew_placement(r_dest, NodePath(p_ptr->get_as_property_path())); } @@ -1471,6 +1483,9 @@ static const void *unmanaged_callbacks[]{ (void *)godotsharp_string_sha256_buffer, (void *)godotsharp_string_sha256_text, (void *)godotsharp_string_simplify_path, + (void *)godotsharp_string_to_camel_case, + (void *)godotsharp_string_to_pascal_case, + (void *)godotsharp_string_to_snake_case, (void *)godotsharp_node_path_get_as_property_path, (void *)godotsharp_node_path_get_concatenated_names, (void *)godotsharp_node_path_get_concatenated_subnames, diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index 12960fb938..c7e47d2718 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -64,7 +64,7 @@ String _get_expected_build_config() { String _get_mono_user_dir() { #ifdef TOOLS_ENABLED if (EditorPaths::get_singleton()) { - return EditorPaths::get_singleton()->get_data_dir().plus_file("mono"); + return EditorPaths::get_singleton()->get_data_dir().path_join("mono"); } else { String settings_path; @@ -72,23 +72,23 @@ String _get_mono_user_dir() { String exe_dir = OS::get_singleton()->get_executable_path().get_base_dir(); // On macOS, look outside .app bundle, since .app bundle is read-only. - if (OS::get_singleton()->has_feature("macos") && exe_dir.ends_with("MacOS") && exe_dir.plus_file("..").simplify_path().ends_with("Contents")) { - exe_dir = exe_dir.plus_file("../../..").simplify_path(); + if (OS::get_singleton()->has_feature("macos") && exe_dir.ends_with("MacOS") && exe_dir.path_join("..").simplify_path().ends_with("Contents")) { + exe_dir = exe_dir.path_join("../../..").simplify_path(); } Ref<DirAccess> d = DirAccess::create_for_path(exe_dir); if (d->file_exists("._sc_") || d->file_exists("_sc_")) { // contain yourself - settings_path = exe_dir.plus_file("editor_data"); + settings_path = exe_dir.path_join("editor_data"); } else { - settings_path = OS::get_singleton()->get_data_path().plus_file(OS::get_singleton()->get_godot_dir_name()); + settings_path = OS::get_singleton()->get_data_path().path_join(OS::get_singleton()->get_godot_dir_name()); } - return settings_path.plus_file("mono"); + return settings_path.path_join("mono"); } #else - return OS::get_singleton()->get_user_data_dir().plus_file("mono"); + return OS::get_singleton()->get_user_data_dir().path_join("mono"); #endif } @@ -126,27 +126,27 @@ public: private: _GodotSharpDirs() { - res_data_dir = ProjectSettings::get_singleton()->get_project_data_path().plus_file("mono"); - res_metadata_dir = res_data_dir.plus_file("metadata"); - res_config_dir = res_data_dir.plus_file("etc").plus_file("mono"); + res_data_dir = ProjectSettings::get_singleton()->get_project_data_path().path_join("mono"); + res_metadata_dir = res_data_dir.path_join("metadata"); + res_config_dir = res_data_dir.path_join("etc").path_join("mono"); // TODO use paths from csproj - res_temp_dir = res_data_dir.plus_file("temp"); - res_temp_assemblies_base_dir = res_temp_dir.plus_file("bin"); - res_temp_assemblies_dir = res_temp_assemblies_base_dir.plus_file(_get_expected_build_config()); + res_temp_dir = res_data_dir.path_join("temp"); + res_temp_assemblies_base_dir = res_temp_dir.path_join("bin"); + res_temp_assemblies_dir = res_temp_assemblies_base_dir.path_join(_get_expected_build_config()); - api_assemblies_base_dir = res_data_dir.plus_file("assemblies"); + api_assemblies_base_dir = res_data_dir.path_join("assemblies"); #ifdef WEB_ENABLED mono_user_dir = "user://"; #else mono_user_dir = _get_mono_user_dir(); #endif - mono_logs_dir = mono_user_dir.plus_file("mono_logs"); + mono_logs_dir = mono_user_dir.path_join("mono_logs"); #ifdef TOOLS_ENABLED - mono_solutions_dir = mono_user_dir.plus_file("solutions"); - build_logs_dir = mono_user_dir.plus_file("build_logs"); + mono_solutions_dir = mono_user_dir.path_join("solutions"); + build_logs_dir = mono_user_dir.path_join("build_logs"); String base_path = ProjectSettings::get_singleton()->globalize_path("res://"); #endif @@ -155,35 +155,35 @@ private: #ifdef TOOLS_ENABLED - String data_dir_root = exe_dir.plus_file("GodotSharp"); - data_editor_tools_dir = data_dir_root.plus_file("Tools"); - api_assemblies_base_dir = data_dir_root.plus_file("Api"); + String data_dir_root = exe_dir.path_join("GodotSharp"); + data_editor_tools_dir = data_dir_root.path_join("Tools"); + api_assemblies_base_dir = data_dir_root.path_join("Api"); - String data_mono_root_dir = data_dir_root.plus_file("Mono"); - data_mono_etc_dir = data_mono_root_dir.plus_file("etc"); + String data_mono_root_dir = data_dir_root.path_join("Mono"); + data_mono_etc_dir = data_mono_root_dir.path_join("etc"); #ifdef ANDROID_ENABLED data_mono_lib_dir = gdmono::android::support::get_app_native_lib_dir(); #else - data_mono_lib_dir = data_mono_root_dir.plus_file("lib"); + data_mono_lib_dir = data_mono_root_dir.path_join("lib"); #endif #ifdef WINDOWS_ENABLED - data_mono_bin_dir = data_mono_root_dir.plus_file("bin"); + data_mono_bin_dir = data_mono_root_dir.path_join("bin"); #endif #ifdef MACOS_ENABLED if (!DirAccess::exists(data_editor_tools_dir)) { - data_editor_tools_dir = exe_dir.plus_file("../Resources/GodotSharp/Tools"); + data_editor_tools_dir = exe_dir.path_join("../Resources/GodotSharp/Tools"); } if (!DirAccess::exists(api_assemblies_base_dir)) { - api_assemblies_base_dir = exe_dir.plus_file("../Resources/GodotSharp/Api"); + api_assemblies_base_dir = exe_dir.path_join("../Resources/GodotSharp/Api"); } if (!DirAccess::exists(data_mono_root_dir)) { - data_mono_etc_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/etc"); - data_mono_lib_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/lib"); + data_mono_etc_dir = exe_dir.path_join("../Resources/GodotSharp/Mono/etc"); + data_mono_lib_dir = exe_dir.path_join("../Resources/GodotSharp/Mono/lib"); } #endif @@ -191,40 +191,40 @@ private: String appname = ProjectSettings::get_singleton()->get("application/config/name"); String appname_safe = OS::get_singleton()->get_safe_dir_name(appname); - String data_dir_root = exe_dir.plus_file("data_" + appname_safe); + String data_dir_root = exe_dir.path_join("data_" + appname_safe); if (!DirAccess::exists(data_dir_root)) { - data_dir_root = exe_dir.plus_file("data_Godot"); + data_dir_root = exe_dir.path_join("data_Godot"); } - String data_mono_root_dir = data_dir_root.plus_file("Mono"); - data_mono_etc_dir = data_mono_root_dir.plus_file("etc"); + String data_mono_root_dir = data_dir_root.path_join("Mono"); + data_mono_etc_dir = data_mono_root_dir.path_join("etc"); #ifdef ANDROID_ENABLED data_mono_lib_dir = gdmono::android::support::get_app_native_lib_dir(); #else - data_mono_lib_dir = data_mono_root_dir.plus_file("lib"); - data_game_assemblies_dir = data_dir_root.plus_file("Assemblies"); + data_mono_lib_dir = data_mono_root_dir.path_join("lib"); + data_game_assemblies_dir = data_dir_root.path_join("Assemblies"); #endif #ifdef WINDOWS_ENABLED - data_mono_bin_dir = data_mono_root_dir.plus_file("bin"); + data_mono_bin_dir = data_mono_root_dir.path_join("bin"); #endif #ifdef MACOS_ENABLED if (!DirAccess::exists(data_mono_root_dir)) { - data_mono_etc_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/etc"); - data_mono_lib_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/lib"); + data_mono_etc_dir = exe_dir.path_join("../Resources/GodotSharp/Mono/etc"); + data_mono_lib_dir = exe_dir.path_join("../Resources/GodotSharp/Mono/lib"); } if (!DirAccess::exists(data_game_assemblies_dir)) { - data_game_assemblies_dir = exe_dir.plus_file("../Resources/GodotSharp/Assemblies"); + data_game_assemblies_dir = exe_dir.path_join("../Resources/GodotSharp/Assemblies"); } #endif #endif #ifdef TOOLS_ENABLED - api_assemblies_dir = api_assemblies_base_dir.plus_file(GDMono::get_expected_api_build_config()); + api_assemblies_dir = api_assemblies_base_dir.path_join(GDMono::get_expected_api_build_config()); #else api_assemblies_dir = data_dir_root; #endif diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index eda4924f15..e698e92d7a 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -173,13 +173,13 @@ String find_hostfxr() { #if defined(WINDOWS_ENABLED) String probe_path = GodotSharpDirs::get_api_assemblies_dir() - .plus_file("hostfxr.dll"); + .path_join("hostfxr.dll"); #elif defined(MACOS_ENABLED) String probe_path = GodotSharpDirs::get_api_assemblies_dir() - .plus_file("libhostfxr.dylib"); + .path_join("libhostfxr.dylib"); #elif defined(UNIX_ENABLED) String probe_path = GodotSharpDirs::get_api_assemblies_dir() - .plus_file("libhostfxr.so"); + .path_join("libhostfxr.so"); #else #error "Platform not supported (yet?)" #endif @@ -305,10 +305,10 @@ godot_plugins_initialize_fn initialize_hostfxr_and_godot_plugins(bool &r_runtime godot_plugins_initialize_fn godot_plugins_initialize = nullptr; HostFxrCharString godot_plugins_path = str_to_hostfxr( - GodotSharpDirs::get_api_assemblies_dir().plus_file("GodotPlugins.dll")); + GodotSharpDirs::get_api_assemblies_dir().path_join("GodotPlugins.dll")); HostFxrCharString config_path = str_to_hostfxr( - GodotSharpDirs::get_api_assemblies_dir().plus_file("GodotPlugins.runtimeconfig.json")); + GodotSharpDirs::get_api_assemblies_dir().path_join("GodotPlugins.runtimeconfig.json")); load_assembly_and_get_function_pointer_fn load_assembly_and_get_function_pointer = initialize_hostfxr_for_config(get_data(config_path)); @@ -345,7 +345,7 @@ godot_plugins_initialize_fn initialize_hostfxr_and_godot_plugins(bool &r_runtime String assembly_name = get_assembly_name(); HostFxrCharString assembly_path = str_to_hostfxr(GodotSharpDirs::get_api_assemblies_dir() - .plus_file(assembly_name + ".dll")); + .path_join(assembly_name + ".dll")); load_assembly_and_get_function_pointer_fn load_assembly_and_get_function_pointer = initialize_hostfxr_self_contained(get_data(assembly_path)); @@ -370,11 +370,11 @@ godot_plugins_initialize_fn try_load_native_aot_library(void *&r_aot_dll_handle) String assembly_name = get_assembly_name(); #if defined(WINDOWS_ENABLED) - String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().plus_file(assembly_name + ".dll"); + String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().path_join(assembly_name + ".dll"); #elif defined(MACOS_ENABLED) - String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().plus_file(assembly_name + ".dylib"); + String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().path_join(assembly_name + ".dylib"); #elif defined(UNIX_ENABLED) - String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().plus_file(assembly_name + ".so"); + String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().path_join(assembly_name + ".so"); #else #error "Platform not supported (yet?)" #endif @@ -514,7 +514,7 @@ bool GDMono::_load_project_assembly() { } String assembly_path = GodotSharpDirs::get_res_temp_assemblies_dir() - .plus_file(assembly_name + ".dll"); + .path_join(assembly_name + ".dll"); assembly_path = ProjectSettings::get_singleton()->globalize_path(assembly_path); if (!FileAccess::exists(assembly_path)) { diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index 19ad59a1bc..269e41e2f4 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -205,7 +205,7 @@ String relative_to_impl(const String &p_path, const String &p_relative_to) { return p_path; } - return String("..").plus_file(relative_to_impl(p_path, base_dir)); + return String("..").path_join(relative_to_impl(p_path, base_dir)); } } diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 428135de56..373c6e37f1 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -169,7 +169,7 @@ String DirAccessJAndroid::get_absolute_path(String p_path) { } if (p_path.is_relative_path()) { - p_path = get_current_dir().plus_file(p_path); + p_path = get_current_dir().path_join(p_path); } p_path = fix_path(p_path); diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 685b1f01af..0f8ef3f7d6 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -624,7 +624,7 @@ Vector<String> EditorExportPlatformAndroid::list_gdap_files(const String &p_path Vector<PluginConfigAndroid> EditorExportPlatformAndroid::get_plugins() { Vector<PluginConfigAndroid> loaded_plugins; - String plugins_dir = ProjectSettings::get_singleton()->get_resource_path().plus_file("android/plugins"); + String plugins_dir = ProjectSettings::get_singleton()->get_resource_path().path_join("android/plugins"); // Add the prebuilt plugins loaded_plugins.append_array(PluginConfigAndroid::get_prebuilt_plugins(plugins_dir)); @@ -635,7 +635,7 @@ Vector<PluginConfigAndroid> EditorExportPlatformAndroid::get_plugins() { if (!plugins_filenames.is_empty()) { Ref<ConfigFile> config_file = memnew(ConfigFile); for (int i = 0; i < plugins_filenames.size(); i++) { - PluginConfigAndroid config = PluginConfigAndroid::load_plugin_config(config_file, plugins_dir.plus_file(plugins_filenames[i])); + PluginConfigAndroid config = PluginConfigAndroid::load_plugin_config(config_file, plugins_dir.path_join(plugins_filenames[i])); if (config.valid_config) { loaded_plugins.push_back(config); } else { @@ -696,7 +696,7 @@ Error EditorExportPlatformAndroid::save_apk_so(void *p_userdata, const SharedObj if (abi_index != -1) { exported = true; String abi = abis[abi_index]; - String dst_path = String("lib").plus_file(abi).plus_file(p_so.path.get_file()); + String dst_path = String("lib").path_join(abi).path_join(p_so.path.get_file()); Vector<uint8_t> array = FileAccess::get_file_as_array(p_so.path); Error store_err = store_in_apk(ed, dst_path, array); ERR_FAIL_COND_V_MSG(store_err, store_err, "Cannot store in apk file '" + dst_path + "'."); @@ -737,7 +737,7 @@ Error EditorExportPlatformAndroid::copy_gradle_so(void *p_userdata, const Shared String type = export_data->debug ? "debug" : "release"; String abi = abis[abi_index]; String filename = p_so.path.get_file(); - String dst_path = base.plus_file(type).plus_file(abi).plus_file(filename); + String dst_path = base.path_join(type).path_join(abi).path_join(filename); Vector<uint8_t> data = FileAccess::get_file_as_array(p_so.path); print_verbose("Copying .so file from " + p_so.path + " to " + dst_path); Error err = store_file_at_path(dst_path, data); @@ -1851,7 +1851,7 @@ Error EditorExportPlatformAndroid::run(const Ref<EditorExportPreset> &p_preset, p_debug_flags |= DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST; } - String tmp_export_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmpexport." + uitos(OS::get_singleton()->get_unix_time()) + ".apk"); + String tmp_export_path = EditorPaths::get_singleton()->get_cache_dir().path_join("tmpexport." + uitos(OS::get_singleton()->get_unix_time()) + ".apk"); #define CLEANUP_AND_RETURN(m_err) \ { \ @@ -2004,7 +2004,7 @@ String EditorExportPlatformAndroid::get_adb_path() { exe_ext = ".exe"; } String sdk_path = EditorSettings::get_singleton()->get("export/android/android_sdk_path"); - return sdk_path.plus_file("platform-tools/adb" + exe_ext); + return sdk_path.path_join("platform-tools/adb" + exe_ext); } String EditorExportPlatformAndroid::get_apksigner_path() { @@ -2017,7 +2017,7 @@ String EditorExportPlatformAndroid::get_apksigner_path() { String apksigner_path = ""; Error errn; - String build_tools_dir = sdk_path.plus_file("build-tools"); + String build_tools_dir = sdk_path.path_join("build-tools"); Ref<DirAccess> da = DirAccess::open(build_tools_dir, &errn); if (errn != OK) { print_error("Unable to open Android 'build-tools' directory."); @@ -2030,7 +2030,7 @@ String EditorExportPlatformAndroid::get_apksigner_path() { while (!sub_dir.is_empty()) { if (!sub_dir.begins_with(".") && da->current_is_dir()) { // Check if the tool is here. - String tool_path = build_tools_dir.plus_file(sub_dir).plus_file(apksigner_command_name); + String tool_path = build_tools_dir.path_join(sub_dir).path_join(apksigner_command_name); if (FileAccess::exists(tool_path)) { apksigner_path = tool_path; break; @@ -2135,7 +2135,7 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<Edito } else { Error errn; // Check for the platform-tools directory. - Ref<DirAccess> da = DirAccess::open(sdk_path.plus_file("platform-tools"), &errn); + Ref<DirAccess> da = DirAccess::open(sdk_path.path_join("platform-tools"), &errn); if (errn != OK) { err += TTR("Invalid Android SDK path in Editor Settings."); err += TTR("Missing 'platform-tools' directory!"); @@ -2153,7 +2153,7 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<Edito } // Check for the build-tools directory. - Ref<DirAccess> build_tools_da = DirAccess::open(sdk_path.plus_file("build-tools"), &errn); + Ref<DirAccess> build_tools_da = DirAccess::open(sdk_path.path_join("build-tools"), &errn); if (errn != OK) { err += TTR("Invalid Android SDK path in Editor Settings."); err += TTR("Missing 'build-tools' directory!"); @@ -2310,7 +2310,7 @@ String EditorExportPlatformAndroid::get_apk_expansion_fullpath(const Ref<EditorE int version_code = p_preset->get("version/code"); String package_name = p_preset->get("package/unique_name"); String apk_file_name = "main." + itos(version_code) + "." + get_package_name(package_name) + ".obb"; - String fullpath = p_path.get_base_dir().plus_file(apk_file_name); + String fullpath = p_path.get_base_dir().path_join(apk_file_name); return fullpath; } @@ -2671,8 +2671,8 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP build_command = "gradlew"; #endif - String build_path = ProjectSettings::get_singleton()->get_resource_path().plus_file("android/build"); - build_command = build_path.plus_file(build_command); + String build_path = ProjectSettings::get_singleton()->get_resource_path().path_join("android/build"); + build_command = build_path.path_join(build_command); String package_name = get_package_name(p_preset->get("package/unique_name")); String version_code = itos(p_preset->get("version/code")); @@ -2742,7 +2742,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP debug_user = EditorSettings::get_singleton()->get("export/android/debug_keystore_user"); } if (debug_keystore.is_relative_path()) { - debug_keystore = OS::get_singleton()->get_resource_dir().plus_file(debug_keystore).simplify_path(); + debug_keystore = OS::get_singleton()->get_resource_dir().path_join(debug_keystore).simplify_path(); } if (!FileAccess::exists(debug_keystore)) { add_message(EXPORT_MESSAGE_ERROR, TTR("Code Signing"), TTR("Could not find keystore, unable to export.")); @@ -2758,7 +2758,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP String release_username = p_preset->get("keystore/release_user"); String release_password = p_preset->get("keystore/release_password"); if (release_keystore.is_relative_path()) { - release_keystore = OS::get_singleton()->get_resource_dir().plus_file(release_keystore).simplify_path(); + release_keystore = OS::get_singleton()->get_resource_dir().path_join(release_keystore).simplify_path(); } if (!FileAccess::exists(release_keystore)) { add_message(EXPORT_MESSAGE_ERROR, TTR("Code Signing"), TTR("Could not find keystore, unable to export.")); @@ -2793,7 +2793,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP String export_filename = p_path.get_file(); String export_path = p_path.get_base_dir(); if (export_path.is_relative_path()) { - export_path = OS::get_singleton()->get_resource_dir().plus_file(export_path); + export_path = OS::get_singleton()->get_resource_dir().path_join(export_path); } export_path = ProjectSettings::get_singleton()->globalize_path(export_path).simplify_path(); @@ -2852,7 +2852,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP Ref<FileAccess> io2_fa; zlib_filefunc_def io2 = zipio_create_io(&io2_fa); - String tmp_unaligned_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmpexport-unaligned." + uitos(OS::get_singleton()->get_unix_time()) + ".apk"); + String tmp_unaligned_path = EditorPaths::get_singleton()->get_cache_dir().path_join("tmpexport-unaligned." + uitos(OS::get_singleton()->get_unix_time()) + ".apk"); #define CLEANUP_AND_RETURN(m_err) \ { \ diff --git a/platform/android/export/godot_plugin_config.cpp b/platform/android/export/godot_plugin_config.cpp index 3daf6e44cd..21580ae907 100644 --- a/platform/android/export/godot_plugin_config.cpp +++ b/platform/android/export/godot_plugin_config.cpp @@ -50,7 +50,7 @@ String PluginConfigAndroid::resolve_local_dependency_path(String plugin_config_d if (dependency_path.is_absolute_path()) { absolute_path = ProjectSettings::get_singleton()->globalize_path(dependency_path); } else { - absolute_path = plugin_config_dir.plus_file(dependency_path); + absolute_path = plugin_config_dir.path_join(dependency_path); } } diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index f94614c741..142dc54c45 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -362,7 +362,7 @@ void OS_Android::vibrate_handheld(int p_duration_ms) { } String OS_Android::get_config_path() const { - return get_user_data_dir().plus_file("config"); + return get_user_data_dir().path_join("config"); } bool OS_Android::_check_internal_feature_support(const String &p_feature) { diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index f49cf7a88d..7aacb2de85 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -649,7 +649,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor if (custom_launch_image_2x.length() > 0 && custom_launch_image_3x.length() > 0) { Ref<Image> image; - String image_path = p_dest_dir.plus_file("splash@2x.png"); + String image_path = p_dest_dir.path_join("splash@2x.png"); image.instantiate(); Error err = image->load(custom_launch_image_2x); @@ -663,7 +663,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor } image.unref(); - image_path = p_dest_dir.plus_file("splash@3x.png"); + image_path = p_dest_dir.path_join("splash@3x.png"); image.instantiate(); err = image->load(custom_launch_image_3x); @@ -696,8 +696,8 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor // because Godot's own boot logo uses single image for all resolutions. // Also not using @1x image, because devices using this image variant // are not supported by iOS 9, which is minimal target. - const String splash_png_path_2x = p_dest_dir.plus_file("splash@2x.png"); - const String splash_png_path_3x = p_dest_dir.plus_file("splash@3x.png"); + const String splash_png_path_2x = p_dest_dir.path_join("splash@2x.png"); + const String splash_png_path_3x = p_dest_dir.path_join("splash@3x.png"); if (splash->save_png(splash_png_path_2x) != OK) { return ERR_FILE_CANT_WRITE; @@ -812,7 +812,7 @@ Error EditorExportPlatformIOS::_walk_dir_recursive(Ref<DirAccess> &p_da, FileHan dirs.push_back(path); } } else { - Error err = p_handler(current_dir.plus_file(path), p_userdata); + Error err = p_handler(current_dir.path_join(path), p_userdata); if (err) { p_da->list_dir_end(); return err; @@ -1028,7 +1028,7 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String if (p_is_framework && p_asset.ends_with(".dylib")) { // For iOS we need to turn .dylib into .framework // to be able to send application to AppStore - asset_path = String("dylibs").plus_file(base_dir); + asset_path = String("dylibs").path_join(base_dir); String file_name; @@ -1040,12 +1040,12 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String String framework_name = file_name + ".framework"; - asset_path = asset_path.plus_file(framework_name); - destination_dir = p_out_dir.plus_file(asset_path); - destination = destination_dir.plus_file(file_name); + asset_path = asset_path.path_join(framework_name); + destination_dir = p_out_dir.path_join(asset_path); + destination = destination_dir.path_join(file_name); create_framework = true; } else if (p_is_framework && (p_asset.ends_with(".framework") || p_asset.ends_with(".xcframework"))) { - asset_path = String("dylibs").plus_file(base_dir); + asset_path = String("dylibs").path_join(base_dir); String file_name; @@ -1055,8 +1055,8 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String file_name = *p_custom_file_name; } - asset_path = asset_path.plus_file(file_name); - destination_dir = p_out_dir.plus_file(asset_path); + asset_path = asset_path.path_join(file_name); + destination_dir = p_out_dir.path_join(asset_path); destination = destination_dir; } else { asset_path = base_dir; @@ -1069,9 +1069,9 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String file_name = *p_custom_file_name; } - destination_dir = p_out_dir.plus_file(asset_path); - asset_path = asset_path.plus_file(file_name); - destination = p_out_dir.plus_file(asset_path); + destination_dir = p_out_dir.path_join(asset_path); + asset_path = asset_path.path_join(file_name); + destination = p_out_dir.path_join(asset_path); } Ref<DirAccess> filesystem_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); @@ -1088,7 +1088,7 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String if (err) { return err; } - IOSExportAsset exported_asset = { binary_name.plus_file(asset_path), p_is_framework, p_should_embed }; + IOSExportAsset exported_asset = { binary_name.path_join(asset_path), p_is_framework, p_should_embed }; r_exported_assets.push_back(exported_asset); if (create_framework) { @@ -1106,7 +1106,7 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String { List<String> install_name_args; install_name_args.push_back("-id"); - install_name_args.push_back(String("@rpath").plus_file(framework_name).plus_file(file_name)); + install_name_args.push_back(String("@rpath").path_join(framework_name).path_join(file_name)); install_name_args.push_back(destination); OS::get_singleton()->execute("install_name_tool", install_name_args); @@ -1141,7 +1141,7 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String String info_plist = info_plist_format.replace("$name", file_name); - Ref<FileAccess> f = FileAccess::open(destination_dir.plus_file("Info.plist"), FileAccess::WRITE); + Ref<FileAccess> f = FileAccess::open(destination_dir.path_join("Info.plist"), FileAccess::WRITE); if (f.is_valid()) { f->store_string(info_plist); } diff --git a/platform/ios/export/export_plugin.h b/platform/ios/export/export_plugin.h index abda8e218a..639f2416a5 100644 --- a/platform/ios/export/export_plugin.h +++ b/platform/ios/export/export_plugin.h @@ -238,9 +238,9 @@ public: if (da->current_is_dir()) { if (p_check_directories) { - Vector<String> directory_files = list_plugin_config_files(p_path.plus_file(file), false); + Vector<String> directory_files = list_plugin_config_files(p_path.path_join(file), false); for (int i = 0; i < directory_files.size(); ++i) { - dir_files.push_back(file.plus_file(directory_files[i])); + dir_files.push_back(file.path_join(directory_files[i])); } } @@ -260,7 +260,7 @@ public: static Vector<PluginConfigIOS> get_plugins() { Vector<PluginConfigIOS> loaded_plugins; - String plugins_dir = ProjectSettings::get_singleton()->get_resource_path().plus_file("ios/plugins"); + String plugins_dir = ProjectSettings::get_singleton()->get_resource_path().path_join("ios/plugins"); if (DirAccess::exists(plugins_dir)) { Vector<String> plugins_filenames = list_plugin_config_files(plugins_dir, true); @@ -268,7 +268,7 @@ public: if (!plugins_filenames.is_empty()) { Ref<ConfigFile> config_file = memnew(ConfigFile); for (int i = 0; i < plugins_filenames.size(); i++) { - PluginConfigIOS config = PluginConfigIOS::load_plugin_config(config_file, plugins_dir.plus_file(plugins_filenames[i])); + PluginConfigIOS config = PluginConfigIOS::load_plugin_config(config_file, plugins_dir.path_join(plugins_filenames[i])); if (config.valid_config) { loaded_plugins.push_back(config); } else { diff --git a/platform/ios/export/godot_plugin_config.cpp b/platform/ios/export/godot_plugin_config.cpp index 24a95a11a4..42797d449b 100644 --- a/platform/ios/export/godot_plugin_config.cpp +++ b/platform/ios/export/godot_plugin_config.cpp @@ -46,7 +46,7 @@ String PluginConfigIOS::resolve_local_dependency_path(String plugin_config_dir, } String res_path = ProjectSettings::get_singleton()->globalize_path("res://"); - absolute_path = plugin_config_dir.plus_file(dependency_path); + absolute_path = plugin_config_dir.path_join(dependency_path); return absolute_path.replace(res_path, "res://"); } @@ -64,7 +64,7 @@ String PluginConfigIOS::resolve_system_dependency_path(String dependency_path) { String system_path = "/System/Library/Frameworks"; - return system_path.plus_file(dependency_path); + return system_path.path_join(dependency_path); } Vector<String> PluginConfigIOS::resolve_local_dependencies(String plugin_config_dir, Vector<String> p_paths) { @@ -121,8 +121,8 @@ bool PluginConfigIOS::validate_plugin(PluginConfigIOS &plugin_config) { String file_path = plugin_config.binary.get_base_dir(); String file_name = plugin_config.binary.get_basename().get_file(); String file_extension = plugin_config.binary.get_extension(); - String release_file_name = file_path.plus_file(file_name + ".release." + file_extension); - String debug_file_name = file_path.plus_file(file_name + ".debug." + file_extension); + String release_file_name = file_path.path_join(file_name + ".release." + file_extension); + String debug_file_name = file_path.path_join(file_name + ".debug." + file_extension); if ((plugin_extension == "a" && FileAccess::exists(release_file_name) && FileAccess::exists(debug_file_name)) || (plugin_extension == "xcframework" && DirAccess::exists(release_file_name) && DirAccess::exists(debug_file_name))) { @@ -144,7 +144,7 @@ String PluginConfigIOS::get_plugin_main_binary(PluginConfigIOS &plugin_config, b String plugin_extension = plugin_config.binary.get_extension(); String plugin_file = plugin_name_prefix + "." + (p_debug ? "debug" : "release") + "." + plugin_extension; - return plugin_binary_dir.plus_file(plugin_file); + return plugin_binary_dir.path_join(plugin_file); } uint64_t PluginConfigIOS::get_plugin_modification_time(const PluginConfigIOS &plugin_config, const String &config_path) { @@ -156,8 +156,8 @@ uint64_t PluginConfigIOS::get_plugin_modification_time(const PluginConfigIOS &pl String file_path = plugin_config.binary.get_base_dir(); String file_name = plugin_config.binary.get_basename().get_file(); String plugin_extension = plugin_config.binary.get_extension(); - String release_file_name = file_path.plus_file(file_name + ".release." + plugin_extension); - String debug_file_name = file_path.plus_file(file_name + ".debug." + plugin_extension); + String release_file_name = file_path.path_join(file_name + ".release." + plugin_extension); + String debug_file_name = file_path.path_join(file_name + ".debug." + plugin_extension); last_updated = MAX(last_updated, FileAccess::get_modified_time(release_file_name)); last_updated = MAX(last_updated, FileAccess::get_modified_time(debug_file_name)); diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index cacb9d2a27..017fc3e3a2 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -1869,6 +1869,14 @@ bool DisplayServerX11::_window_fullscreen_check(WindowID p_window) const { return retval; } +void DisplayServerX11::_validate_fullscreen_on_map(WindowID p_window) { + const WindowData &wd = windows[p_window]; + if (wd.fullscreen && !_window_fullscreen_check(p_window)) { + // Unmapped fullscreen attempt didn't take effect, redo... + _set_wm_fullscreen(p_window, true); + } +} + bool DisplayServerX11::window_is_maximize_allowed(WindowID p_window) const { _THREAD_SAFE_METHOD_ return _window_maximize_check(p_window, "_NET_WM_ALLOWED_ACTIONS"); @@ -3650,6 +3658,9 @@ void DisplayServerX11::process_events() { const WindowData &wd = windows[window_id]; + // Have we failed to set fullscreen while the window was unmapped? + _validate_fullscreen_on_map(window_id); + XWindowAttributes xwa; XSync(x11_display, False); XGetWindowAttributes(x11_display, wd.x11_window, &xwa); @@ -4990,6 +5001,9 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode XNextEvent(x11_display, &xevent); if (xevent.type == ConfigureNotify) { _window_changed(&xevent); + } else if (xevent.type == MapNotify) { + // Have we failed to set fullscreen while the window was unmapped? + _validate_fullscreen_on_map(main_window); } } diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index 0174cfb881..6b9f57d78f 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -268,6 +268,7 @@ class DisplayServerX11 : public DisplayServer { void _update_real_mouse_position(const WindowData &wd); bool _window_maximize_check(WindowID p_window, const char *p_atom_name) const; bool _window_fullscreen_check(WindowID p_window) const; + void _validate_fullscreen_on_map(WindowID p_window); void _update_size_hints(WindowID p_window); void _set_wm_fullscreen(WindowID p_window, bool p_enabled); void _set_wm_maximized(WindowID p_window, bool p_enabled); diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index a74ca155a4..61faf3061c 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -65,7 +65,7 @@ void OS_LinuxBSD::alert(const String &p_alert, const String &p_title) { for (int i = 0; i < path_elems.size(); i++) { for (uint64_t k = 0; k < sizeof(message_programs) / sizeof(char *); k++) { - String tested_path = path_elems[i].plus_file(message_programs[k]); + String tested_path = path_elems[i].path_join(message_programs[k]); if (FileAccess::exists(tested_path)) { program = tested_path; @@ -432,10 +432,10 @@ String OS_LinuxBSD::get_config_path() const { return get_environment("XDG_CONFIG_HOME"); } else { WARN_PRINT_ONCE("`XDG_CONFIG_HOME` is a relative path. Ignoring its value and falling back to `$HOME/.config` or `.` per the XDG Base Directory specification."); - return has_environment("HOME") ? get_environment("HOME").plus_file(".config") : "."; + return has_environment("HOME") ? get_environment("HOME").path_join(".config") : "."; } } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file(".config"); + return get_environment("HOME").path_join(".config"); } else { return "."; } @@ -447,10 +447,10 @@ String OS_LinuxBSD::get_data_path() const { return get_environment("XDG_DATA_HOME"); } else { WARN_PRINT_ONCE("`XDG_DATA_HOME` is a relative path. Ignoring its value and falling back to `$HOME/.local/share` or `get_config_path()` per the XDG Base Directory specification."); - return has_environment("HOME") ? get_environment("HOME").plus_file(".local/share") : get_config_path(); + return has_environment("HOME") ? get_environment("HOME").path_join(".local/share") : get_config_path(); } } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file(".local/share"); + return get_environment("HOME").path_join(".local/share"); } else { return get_config_path(); } @@ -462,10 +462,10 @@ String OS_LinuxBSD::get_cache_path() const { return get_environment("XDG_CACHE_HOME"); } else { WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `$HOME/.cache` or `get_config_path()` per the XDG Base Directory specification."); - return has_environment("HOME") ? get_environment("HOME").plus_file(".cache") : get_config_path(); + return has_environment("HOME") ? get_environment("HOME").path_join(".cache") : get_config_path(); } } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file(".cache"); + return get_environment("HOME").path_join(".cache"); } else { return get_config_path(); } diff --git a/platform/macos/dir_access_macos.mm b/platform/macos/dir_access_macos.mm index 94d937a7dc..3373cada1f 100644 --- a/platform/macos/dir_access_macos.mm +++ b/platform/macos/dir_access_macos.mm @@ -69,7 +69,7 @@ String DirAccessMacOS::get_drive(int p_drive) { } bool DirAccessMacOS::is_hidden(const String &p_name) { - String f = get_current_dir().plus_file(p_name); + String f = get_current_dir().path_join(p_name); NSURL *url = [NSURL fileURLWithPath:@(f.utf8().get_data())]; NSNumber *hidden = nil; if (![url getResourceValue:&hidden forKey:NSURLIsHiddenKey error:nil]) { diff --git a/platform/macos/export/codesign.cpp b/platform/macos/export/codesign.cpp index fd044c00cc..c2bdf555d0 100644 --- a/platform/macos/export/codesign.cpp +++ b/platform/macos/export/codesign.cpp @@ -172,7 +172,7 @@ bool CodeSignCodeResources::add_file1(const String &p_root, const String &p_path f.name = p_path; f.optional = (found == CRMatch::CR_MATCH_OPTIONAL); f.nested = false; - f.hash = hash_sha1_base64(p_root.plus_file(p_path)); + f.hash = hash_sha1_base64(p_root.path_join(p_path)); print_verbose(vformat("CodeSign/CodeResources: File(V1) %s hash1:%s", f.name, f.hash)); files1.push_back(f); @@ -182,7 +182,7 @@ bool CodeSignCodeResources::add_file1(const String &p_root, const String &p_path bool CodeSignCodeResources::add_file2(const String &p_root, const String &p_path) { CRMatch found = match_rules2(p_path); if (found == CRMatch::CR_MATCH_NESTED) { - return add_nested_file(p_root, p_path, p_root.plus_file(p_path)); + return add_nested_file(p_root, p_path, p_root.path_join(p_path)); } if (found != CRMatch::CR_MATCH_YES && found != CRMatch::CR_MATCH_OPTIONAL) { return true; // No match. @@ -192,8 +192,8 @@ bool CodeSignCodeResources::add_file2(const String &p_root, const String &p_path f.name = p_path; f.optional = (found == CRMatch::CR_MATCH_OPTIONAL); f.nested = false; - f.hash = hash_sha1_base64(p_root.plus_file(p_path)); - f.hash2 = hash_sha256_base64(p_root.plus_file(p_path)); + f.hash = hash_sha1_base64(p_root.path_join(p_path)); + f.hash2 = hash_sha256_base64(p_root.path_join(p_path)); print_verbose(vformat("CodeSign/CodeResources: File(V2) %s hash1:%s hash2:%s", f.name, f.hash, f.hash2)); @@ -214,17 +214,17 @@ bool CodeSignCodeResources::add_nested_file(const String &p_root, const String & Vector<String> files_to_add; if (LipO::is_lipo(p_exepath)) { - String tmp_path_name = EditorPaths::get_singleton()->get_cache_dir().plus_file("_lipo"); + String tmp_path_name = EditorPaths::get_singleton()->get_cache_dir().path_join("_lipo"); Error err = da->make_dir_recursive(tmp_path_name); ERR_FAIL_COND_V_MSG(err != OK, false, vformat("CodeSign/CodeResources: Failed to create \"%s\" subfolder.", tmp_path_name)); LipO lip; if (lip.open_file(p_exepath)) { for (int i = 0; i < lip.get_arch_count(); i++) { - if (!lip.extract_arch(i, tmp_path_name.plus_file("_rqexe_" + itos(i)))) { + if (!lip.extract_arch(i, tmp_path_name.path_join("_rqexe_" + itos(i)))) { CLEANUP(); ERR_FAIL_V_MSG(false, "CodeSign/CodeResources: Failed to extract thin binary."); } - files_to_add.push_back(tmp_path_name.plus_file("_rqexe_" + itos(i))); + files_to_add.push_back(tmp_path_name.path_join("_rqexe_" + itos(i))); } } } else if (MachO::is_macho(p_exepath)) { @@ -285,7 +285,7 @@ bool CodeSignCodeResources::add_nested_file(const String &p_root, const String & bool CodeSignCodeResources::add_folder_recursive(const String &p_root, const String &p_path, const String &p_main_exe_path) { Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); ERR_FAIL_COND_V(da.is_null(), false); - Error err = da->change_dir(p_root.plus_file(p_path)); + Error err = da->change_dir(p_root.path_join(p_path)); ERR_FAIL_COND_V(err != OK, false); bool ret = true; @@ -293,27 +293,27 @@ bool CodeSignCodeResources::add_folder_recursive(const String &p_root, const Str String n = da->get_next(); while (n != String()) { if (n != "." && n != "..") { - String path = p_root.plus_file(p_path).plus_file(n); + String path = p_root.path_join(p_path).path_join(n); if (path == p_main_exe_path) { n = da->get_next(); continue; // Skip main executable. } if (da->current_is_dir()) { - CRMatch found = match_rules2(p_path.plus_file(n)); + CRMatch found = match_rules2(p_path.path_join(n)); String fmw_ver = "Current"; // Framework version (default). String info_path; String main_exe; bool bundle = false; - if (da->file_exists(path.plus_file("Contents/Info.plist"))) { - info_path = path.plus_file("Contents/Info.plist"); - main_exe = path.plus_file("Contents/MacOS"); + if (da->file_exists(path.path_join("Contents/Info.plist"))) { + info_path = path.path_join("Contents/Info.plist"); + main_exe = path.path_join("Contents/MacOS"); bundle = true; - } else if (da->file_exists(path.plus_file(vformat("Versions/%s/Resources/Info.plist", fmw_ver)))) { - info_path = path.plus_file(vformat("Versions/%s/Resources/Info.plist", fmw_ver)); - main_exe = path.plus_file(vformat("Versions/%s", fmw_ver)); + } else if (da->file_exists(path.path_join(vformat("Versions/%s/Resources/Info.plist", fmw_ver)))) { + info_path = path.path_join(vformat("Versions/%s/Resources/Info.plist", fmw_ver)); + main_exe = path.path_join(vformat("Versions/%s", fmw_ver)); bundle = true; - } else if (da->file_exists(path.plus_file("Info.plist"))) { - info_path = path.plus_file("Info.plist"); + } else if (da->file_exists(path.path_join("Info.plist"))) { + info_path = path.path_join("Info.plist"); main_exe = path; bundle = true; } @@ -322,20 +322,20 @@ bool CodeSignCodeResources::add_folder_recursive(const String &p_root, const Str PList info_plist; if (info_plist.load_file(info_path)) { if (info_plist.get_root()->data_type == PList::PLNodeType::PL_NODE_TYPE_DICT && info_plist.get_root()->data_dict.has("CFBundleExecutable")) { - main_exe = main_exe.plus_file(String::utf8(info_plist.get_root()->data_dict["CFBundleExecutable"]->data_string.get_data())); + main_exe = main_exe.path_join(String::utf8(info_plist.get_root()->data_dict["CFBundleExecutable"]->data_string.get_data())); } else { ERR_FAIL_V_MSG(false, "CodeSign/CodeResources: Invalid Info.plist, no exe name."); } } else { ERR_FAIL_V_MSG(false, "CodeSign/CodeResources: Invalid Info.plist, can't load."); } - ret = ret && add_nested_file(p_root, p_path.plus_file(n), main_exe); + ret = ret && add_nested_file(p_root, p_path.path_join(n), main_exe); } else { - ret = ret && add_folder_recursive(p_root, p_path.plus_file(n), p_main_exe_path); + ret = ret && add_folder_recursive(p_root, p_path.path_join(n), p_main_exe_path); } } else { - ret = ret && add_file1(p_root, p_path.plus_file(n)); - ret = ret && add_file2(p_root, p_path.plus_file(n)); + ret = ret && add_file1(p_root, p_path.path_join(n)); + ret = ret && add_file2(p_root, p_path.path_join(n)); } } @@ -1222,7 +1222,7 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const } if (info_plist.get_root()->data_type == PList::PLNodeType::PL_NODE_TYPE_DICT && info_plist.get_root()->data_dict.has("CFBundleExecutable")) { - main_exe = p_exe_path.plus_file(String::utf8(info_plist.get_root()->data_dict["CFBundleExecutable"]->data_string.get_data())); + main_exe = p_exe_path.path_join(String::utf8(info_plist.get_root()->data_dict["CFBundleExecutable"]->data_string.get_data())); } else { r_error_msg = TTR("Invalid Info.plist, no exe name."); ERR_FAIL_V_MSG(FAILED, "CodeSign: Invalid Info.plist, no exe name."); @@ -1244,7 +1244,7 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const Vector<String> files_to_sign; if (LipO::is_lipo(main_exe)) { print_verbose(vformat("CodeSign: Executable is fat, extracting...")); - String tmp_path_name = EditorPaths::get_singleton()->get_cache_dir().plus_file("_lipo"); + String tmp_path_name = EditorPaths::get_singleton()->get_cache_dir().path_join("_lipo"); Error err = da->make_dir_recursive(tmp_path_name); if (err != OK) { r_error_msg = vformat(TTR("Failed to create \"%s\" subfolder."), tmp_path_name); @@ -1253,12 +1253,12 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const LipO lip; if (lip.open_file(main_exe)) { for (int i = 0; i < lip.get_arch_count(); i++) { - if (!lip.extract_arch(i, tmp_path_name.plus_file("_exe_" + itos(i)))) { + if (!lip.extract_arch(i, tmp_path_name.path_join("_exe_" + itos(i)))) { CLEANUP(); r_error_msg = TTR("Failed to extract thin binary."); ERR_FAIL_V_MSG(FAILED, "CodeSign: Failed to extract thin binary."); } - files_to_sign.push_back(tmp_path_name.plus_file("_exe_" + itos(i))); + files_to_sign.push_back(tmp_path_name.path_join("_exe_" + itos(i))); } } } else if (MachO::is_macho(main_exe)) { @@ -1338,15 +1338,15 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const r_error_msg = TTR("Failed to process nested resources."); ERR_FAIL_V_MSG(FAILED, "CodeSign: Failed to process nested resources."); } - Error err = da->make_dir_recursive(p_bundle_path.plus_file("_CodeSignature")); + Error err = da->make_dir_recursive(p_bundle_path.path_join("_CodeSignature")); if (err != OK) { CLEANUP(); r_error_msg = TTR("Failed to create _CodeSignature subfolder."); ERR_FAIL_V_MSG(FAILED, "CodeSign: Failed to create _CodeSignature subfolder."); } - cr.save_to_file(p_bundle_path.plus_file("_CodeSignature").plus_file("CodeResources")); - res_hash1 = file_hash_sha1(p_bundle_path.plus_file("_CodeSignature").plus_file("CodeResources")); - res_hash2 = file_hash_sha256(p_bundle_path.plus_file("_CodeSignature").plus_file("CodeResources")); + cr.save_to_file(p_bundle_path.path_join("_CodeSignature").path_join("CodeResources")); + res_hash1 = file_hash_sha1(p_bundle_path.path_join("_CodeSignature").path_join("CodeResources")); + res_hash2 = file_hash_sha256(p_bundle_path.path_join("_CodeSignature").path_join("CodeResources")); if (res_hash1.is_empty() || res_hash2.is_empty()) { CLEANUP(); r_error_msg = TTR("Failed to get CodeResources hash."); @@ -1530,18 +1530,18 @@ Error CodeSign::codesign(bool p_use_hardened_runtime, bool p_force, const String String bundle_path; bool bundle = false; bool ios_bundle = false; - if (da->file_exists(p_path.plus_file("Contents/Info.plist"))) { - info_path = p_path.plus_file("Contents/Info.plist"); - main_exe = p_path.plus_file("Contents/MacOS"); - bundle_path = p_path.plus_file("Contents"); + if (da->file_exists(p_path.path_join("Contents/Info.plist"))) { + info_path = p_path.path_join("Contents/Info.plist"); + main_exe = p_path.path_join("Contents/MacOS"); + bundle_path = p_path.path_join("Contents"); bundle = true; - } else if (da->file_exists(p_path.plus_file(vformat("Versions/%s/Resources/Info.plist", fmw_ver)))) { - info_path = p_path.plus_file(vformat("Versions/%s/Resources/Info.plist", fmw_ver)); - main_exe = p_path.plus_file(vformat("Versions/%s", fmw_ver)); - bundle_path = p_path.plus_file(vformat("Versions/%s", fmw_ver)); + } else if (da->file_exists(p_path.path_join(vformat("Versions/%s/Resources/Info.plist", fmw_ver)))) { + info_path = p_path.path_join(vformat("Versions/%s/Resources/Info.plist", fmw_ver)); + main_exe = p_path.path_join(vformat("Versions/%s", fmw_ver)); + bundle_path = p_path.path_join(vformat("Versions/%s", fmw_ver)); bundle = true; - } else if (da->file_exists(p_path.plus_file("Info.plist"))) { - info_path = p_path.plus_file("Info.plist"); + } else if (da->file_exists(p_path.path_join("Info.plist"))) { + info_path = p_path.path_join("Info.plist"); main_exe = p_path; bundle_path = p_path; bundle = true; diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index 4b453add5a..50104aced5 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -305,7 +305,7 @@ void EditorExportPlatformMacOS::_make_icon(const Ref<Image> &p_icon, Vector<uint if (icon_infos[i].is_png) { // Encode PNG icon. it->set_image(copy); - String path = EditorPaths::get_singleton()->get_cache_dir().plus_file("icon.png"); + String path = EditorPaths::get_singleton()->get_cache_dir().path_join("icon.png"); ResourceSaver::save(it, path); { @@ -766,7 +766,7 @@ Error EditorExportPlatformMacOS::_code_sign_directory(const Ref<EditorExportPres dir_access->list_dir_begin(); String current_file{ dir_access->get_next() }; while (!current_file.is_empty()) { - String current_file_path{ p_path.plus_file(current_file) }; + String current_file_path{ p_path.path_join(current_file) }; if (current_file == ".." || current_file == ".") { current_file = dir_access->get_next(); @@ -980,9 +980,9 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p tmp_app_path_name = p_path; scr_path = p_path.get_basename() + ".command"; } else { - tmp_base_path_name = EditorPaths::get_singleton()->get_cache_dir().plus_file(pkg_name); - tmp_app_path_name = tmp_base_path_name.plus_file(tmp_app_dir_name); - scr_path = tmp_base_path_name.plus_file(pkg_name + ".command"); + tmp_base_path_name = EditorPaths::get_singleton()->get_cache_dir().path_join(pkg_name); + tmp_app_path_name = tmp_base_path_name.path_join(tmp_app_dir_name); + scr_path = tmp_base_path_name.path_join(pkg_name + ".command"); } print_verbose("Exporting to " + tmp_app_path_name); @@ -1189,7 +1189,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p add_message(EXPORT_MESSAGE_INFO, TTR("Export"), TTR("Relative symlinks are not supported on this OS, the exported project might be broken!")); #endif // Handle symlinks in the archive. - file = tmp_app_path_name.plus_file(file); + file = tmp_app_path_name.path_join(file); if (err == OK) { err = tmp_app_dir->make_dir_recursive(file.get_base_dir()); if (err != OK) { @@ -1273,7 +1273,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p print_verbose("ADDING: " + file + " size: " + itos(data.size())); // Write it into our application bundle. - file = tmp_app_path_name.plus_file(file); + file = tmp_app_path_name.path_join(file); if (err == OK) { err = tmp_app_dir->make_dir_recursive(file.get_base_dir()); if (err != OK) { @@ -1332,9 +1332,9 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p bool sign_enabled = (p_preset->get("codesign/codesign").operator int() > 0); String ent_path = p_preset->get("codesign/entitlements/custom_file"); - String hlp_ent_path = EditorPaths::get_singleton()->get_cache_dir().plus_file(pkg_name + "_helper.entitlements"); + String hlp_ent_path = EditorPaths::get_singleton()->get_cache_dir().path_join(pkg_name + "_helper.entitlements"); if (sign_enabled && (ent_path.is_empty())) { - ent_path = EditorPaths::get_singleton()->get_cache_dir().plus_file(pkg_name + ".entitlements"); + ent_path = EditorPaths::get_singleton()->get_cache_dir().path_join(pkg_name + ".entitlements"); Ref<FileAccess> ent_f = FileAccess::open(ent_path, FileAccess::WRITE); if (ent_f.is_valid()) { @@ -1529,7 +1529,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p String path_in_app = tmp_app_path_name + "/Contents/Frameworks/" + src_path.get_file(); err = _copy_and_sign_files(da, src_path, path_in_app, sign_enabled, p_preset, ent_path, true); } else { - String path_in_app = tmp_app_path_name.plus_file(shared_objects[i].target).plus_file(src_path.get_file()); + String path_in_app = tmp_app_path_name.path_join(shared_objects[i].target).path_join(src_path.get_file()); err = _copy_and_sign_files(da, src_path, path_in_app, sign_enabled, p_preset, ent_path, false); } if (err != OK) { @@ -1630,7 +1630,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p } void EditorExportPlatformMacOS::_zip_folder_recursive(zipFile &p_zip, const String &p_root_path, const String &p_folder, const String &p_pkg_name) { - String dir = p_folder.is_empty() ? p_root_path : p_root_path.plus_file(p_folder); + String dir = p_folder.is_empty() ? p_root_path : p_root_path.path_join(p_folder); Ref<DirAccess> da = DirAccess::open(dir); da->list_dir_begin(); @@ -1660,7 +1660,7 @@ void EditorExportPlatformMacOS::_zip_folder_recursive(zipFile &p_zip, const Stri zipfi.internal_fa = 0; zipOpenNewFileInZip4(p_zip, - p_folder.plus_file(f).utf8().get_data(), + p_folder.path_join(f).utf8().get_data(), &zipfi, nullptr, 0, @@ -1682,7 +1682,7 @@ void EditorExportPlatformMacOS::_zip_folder_recursive(zipFile &p_zip, const Stri zipWriteInFileInZip(p_zip, target.utf8().get_data(), target.utf8().size()); zipCloseFileInZip(p_zip); } else if (da->current_is_dir()) { - _zip_folder_recursive(p_zip, p_root_path, p_folder.plus_file(f), p_pkg_name); + _zip_folder_recursive(p_zip, p_root_path, p_folder.path_join(f), p_pkg_name); } else { bool is_executable = (p_folder.ends_with("MacOS") && (f == p_pkg_name)) || p_folder.ends_with("Helpers") || f.ends_with(".command"); @@ -1705,7 +1705,7 @@ void EditorExportPlatformMacOS::_zip_folder_recursive(zipFile &p_zip, const Stri zipfi.internal_fa = 0; zipOpenNewFileInZip4(p_zip, - p_folder.plus_file(f).utf8().get_data(), + p_folder.path_join(f).utf8().get_data(), &zipfi, nullptr, 0, @@ -1723,9 +1723,9 @@ void EditorExportPlatformMacOS::_zip_folder_recursive(zipFile &p_zip, const Stri 0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions 0); - Ref<FileAccess> fa = FileAccess::open(dir.plus_file(f), FileAccess::READ); + Ref<FileAccess> fa = FileAccess::open(dir.path_join(f), FileAccess::READ); if (fa.is_null()) { - add_message(EXPORT_MESSAGE_ERROR, TTR("ZIP Creation"), vformat(TTR("Could not open file to read from path \"%s\"."), dir.plus_file(f))); + add_message(EXPORT_MESSAGE_ERROR, TTR("ZIP Creation"), vformat(TTR("Could not open file to read from path \"%s\"."), dir.path_join(f))); return; } const int bufsize = 16384; diff --git a/platform/macos/os_macos.mm b/platform/macos/os_macos.mm index 47b53bba69..35c4e4b03d 100644 --- a/platform/macos/os_macos.mm +++ b/platform/macos/os_macos.mm @@ -48,8 +48,8 @@ _FORCE_INLINE_ String OS_MacOS::get_framework_executable(const String &p_path) { // Append framework executable name, or return as is if p_path is not a framework. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - if (da->dir_exists(p_path) && da->file_exists(p_path.plus_file(p_path.get_file().get_basename()))) { - return p_path.plus_file(p_path.get_file().get_basename()); + if (da->dir_exists(p_path) && da->file_exists(p_path.path_join(p_path.get_file().get_basename()))) { + return p_path.path_join(p_path.get_file().get_basename()); } else { return p_path; } @@ -155,12 +155,12 @@ Error OS_MacOS::open_dynamic_library(const String p_path, void *&p_library_handl if (!FileAccess::exists(path)) { // Load .dylib or framework from within the executable path. - path = get_framework_executable(get_executable_path().get_base_dir().plus_file(p_path.get_file())); + path = get_framework_executable(get_executable_path().get_base_dir().path_join(p_path.get_file())); } if (!FileAccess::exists(path)) { // Load .dylib or framework from a standard macOS location. - path = get_framework_executable(get_executable_path().get_base_dir().plus_file("../Frameworks").plus_file(p_path.get_file())); + path = get_framework_executable(get_executable_path().get_base_dir().path_join("../Frameworks").path_join(p_path.get_file())); } p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW); @@ -187,7 +187,7 @@ String OS_MacOS::get_config_path() const { } } if (has_environment("HOME")) { - return get_environment("HOME").plus_file("Library/Application Support"); + return get_environment("HOME").path_join("Library/Application Support"); } return "."; } @@ -214,7 +214,7 @@ String OS_MacOS::get_cache_path() const { } } if (has_environment("HOME")) { - return get_environment("HOME").plus_file("Library/Caches"); + return get_environment("HOME").path_join("Library/Caches"); } return get_config_path(); } diff --git a/platform/uwp/export/app_packager.cpp b/platform/uwp/export/app_packager.cpp index 09717b9d69..87224d38b8 100644 --- a/platform/uwp/export/app_packager.cpp +++ b/platform/uwp/export/app_packager.cpp @@ -408,7 +408,7 @@ void AppxPackager::finish() { // Create and add block map file EditorNode::progress_task_step("export", "Creating block map...", 4); - const String &tmp_blockmap_file_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmpblockmap.xml"); + const String &tmp_blockmap_file_path = EditorPaths::get_singleton()->get_cache_dir().path_join("tmpblockmap.xml"); make_block_map(tmp_blockmap_file_path); { @@ -425,7 +425,7 @@ void AppxPackager::finish() { EditorNode::progress_task_step("export", "Setting content types...", 5); - const String &tmp_content_types_file_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmpcontenttypes.xml"); + const String &tmp_content_types_file_path = EditorPaths::get_singleton()->get_cache_dir().path_join("tmpcontenttypes.xml"); make_content_types(tmp_content_types_file_path); { diff --git a/platform/uwp/export/export_plugin.h b/platform/uwp/export/export_plugin.h index 71d0479543..b0427d1a65 100644 --- a/platform/uwp/export/export_plugin.h +++ b/platform/uwp/export/export_plugin.h @@ -329,7 +329,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { return data; } - String tmp_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("uwp_tmp_logo.png"); + String tmp_path = EditorPaths::get_singleton()->get_cache_dir().path_join("uwp_tmp_logo.png"); Error err = texture->get_image()->save_png(tmp_path); diff --git a/platform/web/api/web_tools_editor_plugin.cpp b/platform/web/api/web_tools_editor_plugin.cpp index 6f684a73c2..46fcb2d452 100644 --- a/platform/web/api/web_tools_editor_plugin.cpp +++ b/platform/web/api/web_tools_editor_plugin.cpp @@ -76,7 +76,7 @@ void WebToolsEditorPlugin::_download_zip(Variant p_v) { const String datetime_safe = Time::get_singleton()->get_datetime_string_from_system(false, true).replace(" ", "_"); const String output_name = OS::get_singleton()->get_safe_dir_name(vformat("%s_%s.zip")); - const String output_path = String("/tmp").plus_file(output_name); + const String output_path = String("/tmp").path_join(output_name); zipFile zip = zipOpen2(output_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io); const String base_path = resource_path.substr(0, resource_path.rfind("/")) + "/"; @@ -131,7 +131,7 @@ void WebToolsEditorPlugin::_zip_recursive(String p_path, String p_base_path, zip String cur = dir->get_next(); String project_data_dir_name = ProjectSettings::get_singleton()->get_project_data_dir_name(); while (!cur.is_empty()) { - String cs = p_path.plus_file(cur); + String cs = p_path.path_join(cur); if (cur == "." || cur == ".." || cur == project_data_dir_name) { // Skip } else if (dir->current_is_dir()) { diff --git a/platform/web/export/editor_http_server.h b/platform/web/export/editor_http_server.h index 1e50e60a28..38b9a66d7e 100644 --- a/platform/web/export/editor_http_server.h +++ b/platform/web/export/editor_http_server.h @@ -62,8 +62,8 @@ private: void _set_internal_certs(Ref<Crypto> p_crypto) { const String cache_path = EditorPaths::get_singleton()->get_cache_dir(); - const String key_path = cache_path.plus_file("html5_server.key"); - const String crt_path = cache_path.plus_file("html5_server.crt"); + const String key_path = cache_path.path_join("html5_server.key"); + const String crt_path = cache_path.path_join("html5_server.crt"); bool regen = !FileAccess::exists(key_path) || !FileAccess::exists(crt_path); if (!regen) { key = Ref<CryptoKey>(CryptoKey::create()); @@ -139,8 +139,8 @@ public: const String req_file = path.get_file(); const String req_ext = path.get_extension(); - const String cache_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("web"); - const String filepath = cache_path.plus_file(req_file); + const String cache_path = EditorPaths::get_singleton()->get_cache_dir().path_join("web"); + const String filepath = cache_path.path_join(req_file); if (!mimes.has(req_ext) || !FileAccess::exists(filepath)) { String s = "HTTP/1.1 404 Not Found\r\n"; diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index 996d1db2e7..2cd8ec88ef 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -75,7 +75,7 @@ Error EditorExportPlatformWeb::_extract_template(const String &p_template, const unzCloseCurrentFile(pkg); //write - String dst = p_dir.plus_file(file.replace("godot", p_name)); + String dst = p_dir.path_join(file.replace("godot", p_name)); Ref<FileAccess> f = FileAccess::open(dst, FileAccess::WRITE); if (f.is_null()) { add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Could not write file: \"%s\"."), dst)); @@ -162,7 +162,7 @@ void EditorExportPlatformWeb::_fix_html(Vector<uint8_t> &p_html, const Ref<Edito Error EditorExportPlatformWeb::_add_manifest_icon(const String &p_path, const String &p_icon, int p_size, Array &r_arr) { const String name = p_path.get_file().get_basename(); const String icon_name = vformat("%s.%dx%d.png", name, p_size, p_size); - const String icon_dest = p_path.get_base_dir().plus_file(icon_name); + const String icon_dest = p_path.get_base_dir().path_join(icon_name); Ref<Image> icon; if (!p_icon.is_empty()) { @@ -234,7 +234,7 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese } replaces["@GODOT_OPT_CACHE@"] = Variant(opt_cache_files).to_json_string(); - const String sw_path = dir.plus_file(name + ".service.worker.js"); + const String sw_path = dir.path_join(name + ".service.worker.js"); Vector<uint8_t> sw; { Ref<FileAccess> f = FileAccess::open(sw_path, FileAccess::READ); @@ -246,7 +246,7 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese f->get_buffer(sw.ptrw(), sw.size()); } _replace_strings(replaces, sw); - Error err = _write_or_error(sw.ptr(), sw.size(), dir.plus_file(name + ".service.worker.js")); + Error err = _write_or_error(sw.ptr(), sw.size(), dir.path_join(name + ".service.worker.js")); if (err != OK) { return err; } @@ -255,7 +255,7 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese const String offline_page = p_preset->get("progressive_web_app/offline_page"); if (!offline_page.is_empty()) { Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - const String offline_dest = dir.plus_file(name + ".offline.html"); + const String offline_dest = dir.path_join(name + ".offline.html"); err = da->copy(ProjectSettings::get_singleton()->globalize_path(offline_page), offline_dest); if (err != OK) { add_message(EXPORT_MESSAGE_ERROR, TTR("PWA"), vformat(TTR("Could not read file: \"%s\"."), offline_dest)); @@ -295,7 +295,7 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese manifest["icons"] = icons_arr; CharString cs = Variant(manifest).to_json_string().utf8(); - err = _write_or_error((const uint8_t *)cs.get_data(), cs.length(), dir.plus_file(name + ".manifest.json")); + err = _write_or_error((const uint8_t *)cs.get_data(), cs.length(), dir.path_join(name + ".manifest.json")); if (err != OK) { return err; } @@ -481,7 +481,7 @@ Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_p { Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); for (int i = 0; i < shared_objects.size(); i++) { - String dst = base_dir.plus_file(shared_objects[i].path.get_file()); + String dst = base_dir.path_join(shared_objects[i].path.get_file()); error = da->copy(shared_objects[i].path, dst); if (error != OK) { add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not write file: \"%s\"."), shared_objects[i].path.get_file())); @@ -601,7 +601,7 @@ Error EditorExportPlatformWeb::run(const Ref<EditorExportPreset> &p_preset, int return OK; } - const String dest = EditorPaths::get_singleton()->get_cache_dir().plus_file("web"); + const String dest = EditorPaths::get_singleton()->get_cache_dir().path_join("web"); Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); if (!da->dir_exists(dest)) { Error err = da->make_dir_recursive(dest); @@ -611,7 +611,7 @@ Error EditorExportPlatformWeb::run(const Ref<EditorExportPreset> &p_preset, int } } - const String basepath = dest.plus_file("tmp_js_export"); + const String basepath = dest.path_join("tmp_js_export"); Error err = export_project(p_preset, true, basepath + ".html", p_debug_flags); if (err != OK) { // Export generates several files, clean them up on failure. diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 0e4d5f79b9..403d53ae53 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -237,7 +237,7 @@ Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_han if (!FileAccess::exists(path)) { //this code exists so gdnative can load .dll files from within the executable path - path = get_executable_path().get_base_dir().plus_file(p_path.get_file()); + path = get_executable_path().get_base_dir().path_join(p_path.get_file()); } typedef DLL_DIRECTORY_COOKIE(WINAPI * PAddDllDirectory)(PCWSTR); @@ -1071,13 +1071,13 @@ String OS_Windows::get_user_data_dir() const { if (custom_dir.is_empty()) { custom_dir = appname; } - return get_data_path().plus_file(custom_dir).replace("\\", "/"); + return get_data_path().path_join(custom_dir).replace("\\", "/"); } else { - return get_data_path().plus_file(get_godot_dir_name()).plus_file("app_userdata").plus_file(appname).replace("\\", "/"); + return get_data_path().path_join(get_godot_dir_name()).path_join("app_userdata").path_join(appname).replace("\\", "/"); } } - return get_data_path().plus_file(get_godot_dir_name()).plus_file("app_userdata").plus_file("[unnamed project]"); + return get_data_path().path_join(get_godot_dir_name()).path_join("app_userdata").path_join("[unnamed project]"); } String OS_Windows::get_unique_id() const { diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index 4565462247..b1b1cb23ed 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -205,7 +205,7 @@ void AnimatedSprite2D::_notification(int p_what) { } } - update(); + queue_redraw(); emit_signal(SceneStringNames::get_singleton()->frame_changed); } @@ -274,7 +274,7 @@ void AnimatedSprite2D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) { notify_property_list_changed(); _reset_timeout(); - update(); + queue_redraw(); update_configuration_warnings(); } @@ -304,7 +304,7 @@ void AnimatedSprite2D::set_frame(int p_frame) { frame = p_frame; _reset_timeout(); - update(); + queue_redraw(); emit_signal(SceneStringNames::get_singleton()->frame_changed); } @@ -329,7 +329,7 @@ double AnimatedSprite2D::get_speed_scale() const { void AnimatedSprite2D::set_centered(bool p_center) { centered = p_center; - update(); + queue_redraw(); item_rect_changed(); } @@ -339,7 +339,7 @@ bool AnimatedSprite2D::is_centered() const { void AnimatedSprite2D::set_offset(const Point2 &p_offset) { offset = p_offset; - update(); + queue_redraw(); item_rect_changed(); } @@ -349,7 +349,7 @@ Point2 AnimatedSprite2D::get_offset() const { void AnimatedSprite2D::set_flip_h(bool p_flip) { hflip = p_flip; - update(); + queue_redraw(); } bool AnimatedSprite2D::is_flipped_h() const { @@ -358,7 +358,7 @@ bool AnimatedSprite2D::is_flipped_h() const { void AnimatedSprite2D::set_flip_v(bool p_flip) { vflip = p_flip; - update(); + queue_redraw(); } bool AnimatedSprite2D::is_flipped_v() const { @@ -368,7 +368,7 @@ bool AnimatedSprite2D::is_flipped_v() const { void AnimatedSprite2D::_res_changed() { set_frame(frame); - update(); + queue_redraw(); } void AnimatedSprite2D::set_playing(bool p_playing) { @@ -433,7 +433,7 @@ void AnimatedSprite2D::set_animation(const StringName &p_animation) { _reset_timeout(); set_frame(0); notify_property_list_changed(); - update(); + queue_redraw(); } StringName AnimatedSprite2D::get_animation() const { diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 88f9c2a4a6..ce77c6ba8d 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -39,7 +39,7 @@ void Camera2D::_update_scroll() { } if (Engine::get_singleton()->is_editor_hint()) { - update(); //will just be drawn + queue_redraw(); //will just be drawn return; } @@ -392,7 +392,7 @@ void Camera2D::_make_current(Object *p_which) { current = true; if (is_inside_tree()) { get_viewport()->_camera_2d_set(this); - update(); + queue_redraw(); } } else { current = false; @@ -400,7 +400,7 @@ void Camera2D::_make_current(Object *p_which) { if (get_viewport()->get_camera_2d() == this) { get_viewport()->_camera_2d_set(nullptr); } - update(); + queue_redraw(); } } } @@ -461,7 +461,7 @@ bool Camera2D::is_limit_smoothing_enabled() const { void Camera2D::set_drag_margin(Side p_side, real_t p_drag_margin) { ERR_FAIL_INDEX((int)p_side, 4); drag_margin[p_side] = p_drag_margin; - update(); + queue_redraw(); } real_t Camera2D::get_drag_margin(Side p_side) const { @@ -625,7 +625,7 @@ Node *Camera2D::get_custom_viewport() const { void Camera2D::set_screen_drawing_enabled(bool enable) { screen_drawing_enabled = enable; #ifdef TOOLS_ENABLED - update(); + queue_redraw(); #endif } @@ -636,7 +636,7 @@ bool Camera2D::is_screen_drawing_enabled() const { void Camera2D::set_limit_drawing_enabled(bool enable) { limit_drawing_enabled = enable; #ifdef TOOLS_ENABLED - update(); + queue_redraw(); #endif } @@ -647,7 +647,7 @@ bool Camera2D::is_limit_drawing_enabled() const { void Camera2D::set_margin_drawing_enabled(bool enable) { margin_drawing_enabled = enable; #ifdef TOOLS_ENABLED - update(); + queue_redraw(); #endif } diff --git a/scene/2d/canvas_group.cpp b/scene/2d/canvas_group.cpp index bbf3fff0ad..d4182f85a7 100644 --- a/scene/2d/canvas_group.cpp +++ b/scene/2d/canvas_group.cpp @@ -36,7 +36,7 @@ void CanvasGroup::set_fit_margin(real_t p_fit_margin) { fit_margin = p_fit_margin; RS::get_singleton()->canvas_item_set_canvas_group_mode(get_canvas_item(), RS::CANVAS_GROUP_MODE_TRANSPARENT, clear_margin, true, fit_margin, use_mipmaps); - update(); + queue_redraw(); } real_t CanvasGroup::get_fit_margin() const { @@ -49,7 +49,7 @@ void CanvasGroup::set_clear_margin(real_t p_clear_margin) { clear_margin = p_clear_margin; RS::get_singleton()->canvas_item_set_canvas_group_mode(get_canvas_item(), RS::CANVAS_GROUP_MODE_TRANSPARENT, clear_margin, true, clear_margin, use_mipmaps); - update(); + queue_redraw(); } real_t CanvasGroup::get_clear_margin() const { diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 04cd999982..b69b19d30d 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -198,7 +198,7 @@ void CollisionPolygon2D::set_polygon(const Vector<Point2> &p_polygon) { _build_polygon(); _update_in_shape_owner(); } - update(); + queue_redraw(); update_configuration_warnings(); } @@ -213,7 +213,7 @@ void CollisionPolygon2D::set_build_mode(BuildMode p_mode) { _build_polygon(); _update_in_shape_owner(); } - update(); + queue_redraw(); update_configuration_warnings(); } @@ -264,7 +264,7 @@ TypedArray<String> CollisionPolygon2D::get_configuration_warnings() const { void CollisionPolygon2D::set_disabled(bool p_disabled) { disabled = p_disabled; - update(); + queue_redraw(); if (parent) { parent->shape_owner_set_disabled(owner_id, p_disabled); } @@ -276,7 +276,7 @@ bool CollisionPolygon2D::is_disabled() const { void CollisionPolygon2D::set_one_way_collision(bool p_enable) { one_way_collision = p_enable; - update(); + queue_redraw(); if (parent) { parent->shape_owner_set_one_way_collision(owner_id, p_enable); } diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index cbecf28877..039bfee451 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -36,7 +36,7 @@ #include "scene/resources/convex_polygon_shape_2d.h" void CollisionShape2D::_shape_changed() { - update(); + queue_redraw(); } void CollisionShape2D::_update_in_shape_owner(bool p_xform_only) { @@ -140,7 +140,7 @@ void CollisionShape2D::set_shape(const Ref<Shape2D> &p_shape) { shape->disconnect("changed", callable_mp(this, &CollisionShape2D::_shape_changed)); } shape = p_shape; - update(); + queue_redraw(); if (parent) { parent->shape_owner_clear_shapes(owner_id); if (shape.is_valid()) { @@ -192,7 +192,7 @@ TypedArray<String> CollisionShape2D::get_configuration_warnings() const { void CollisionShape2D::set_disabled(bool p_disabled) { disabled = p_disabled; - update(); + queue_redraw(); if (parent) { parent->shape_owner_set_disabled(owner_id, p_disabled); } @@ -204,7 +204,7 @@ bool CollisionShape2D::is_disabled() const { void CollisionShape2D::set_one_way_collision(bool p_enable) { one_way_collision = p_enable; - update(); + queue_redraw(); if (parent) { parent->shape_owner_set_one_way_collision(owner_id, p_enable); } diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index 1929475c8f..dfe2ce0ec3 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -211,13 +211,13 @@ void CPUParticles2D::set_texture(const Ref<Texture2D> &p_texture) { texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &CPUParticles2D::_texture_changed)); } - update(); + queue_redraw(); _update_mesh_texture(); } void CPUParticles2D::_texture_changed() { if (texture.is_valid()) { - update(); + queue_redraw(); _update_mesh_texture(); } } @@ -556,7 +556,7 @@ static real_t rand_from_seed(uint32_t &seed) { void CPUParticles2D::_update_internal() { if (particles.size() == 0 || !is_visible_in_tree()) { - _set_redraw(false); + _set_do_redraw(false); return; } @@ -567,7 +567,7 @@ void CPUParticles2D::_update_internal() { inactive_time += delta; if (inactive_time > lifetime * 1.2) { set_process_internal(false); - _set_redraw(false); + _set_do_redraw(false); //reset variables time = 0; @@ -577,7 +577,7 @@ void CPUParticles2D::_update_internal() { return; } } - _set_redraw(true); + _set_do_redraw(true); if (time == 0 && pre_process_time > 0.0) { double frame_time; @@ -1062,16 +1062,16 @@ void CPUParticles2D::_update_particle_data_buffer() { } } -void CPUParticles2D::_set_redraw(bool p_redraw) { - if (redraw == p_redraw) { +void CPUParticles2D::_set_do_redraw(bool p_do_redraw) { + if (do_redraw == p_do_redraw) { return; } - redraw = p_redraw; + do_redraw = p_do_redraw; { MutexLock lock(update_mutex); - if (redraw) { + if (do_redraw) { RS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread)); RS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), true); @@ -1086,7 +1086,7 @@ void CPUParticles2D::_set_redraw(bool p_redraw) { } } - update(); // redraw to update render list + queue_redraw(); // redraw to update render list } void CPUParticles2D::_update_render_thread() { @@ -1102,7 +1102,7 @@ void CPUParticles2D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - _set_redraw(false); + _set_do_redraw(false); } break; case NOTIFICATION_DRAW: { @@ -1111,7 +1111,7 @@ void CPUParticles2D::_notification(int p_what) { _update_internal(); } - if (!redraw) { + if (!do_redraw) { return; // don't add to render list } diff --git a/scene/2d/cpu_particles_2d.h b/scene/2d/cpu_particles_2d.h index 8f1671d280..3fd1c7fd0f 100644 --- a/scene/2d/cpu_particles_2d.h +++ b/scene/2d/cpu_particles_2d.h @@ -102,7 +102,7 @@ private: double inactive_time = 0.0; double frame_remainder = 0.0; int cycle = 0; - bool redraw = false; + bool do_redraw = false; RID mesh; RID multimesh; @@ -186,7 +186,7 @@ private: void _update_mesh_texture(); - void _set_redraw(bool p_redraw); + void _set_do_redraw(bool p_do_redraw); void _texture_changed(); diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index 65ead7afbc..bed68b4ee0 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -30,6 +30,7 @@ #include "gpu_particles_2d.h" +#include "core/core_string_names.h" #include "scene/resources/particle_process_material.h" #ifdef TOOLS_ENABLED @@ -99,7 +100,7 @@ void GPUParticles2D::set_visibility_rect(const Rect2 &p_visibility_rect) { RS::get_singleton()->particles_set_custom_aabb(particles, aabb); - update(); + queue_redraw(); } void GPUParticles2D::set_use_local_coordinates(bool p_enable) { @@ -141,7 +142,7 @@ void GPUParticles2D::set_process_material(const Ref<Material> &p_material) { void GPUParticles2D::set_trail_enabled(bool p_enabled) { trail_enabled = p_enabled; RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_length); - update(); + queue_redraw(); RS::get_singleton()->particles_set_transform_align(particles, p_enabled ? RS::PARTICLES_TRANSFORM_ALIGN_Y_TO_VELOCITY : RS::PARTICLES_TRANSFORM_ALIGN_DISABLED); } @@ -150,7 +151,7 @@ void GPUParticles2D::set_trail_length(double p_seconds) { ERR_FAIL_COND(p_seconds < 0.001); trail_length = p_seconds; RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_length); - update(); + queue_redraw(); } void GPUParticles2D::set_trail_sections(int p_sections) { @@ -158,7 +159,7 @@ void GPUParticles2D::set_trail_sections(int p_sections) { ERR_FAIL_COND(p_sections > 128); trail_sections = p_sections; - update(); + queue_redraw(); } void GPUParticles2D::set_trail_section_subdivisions(int p_subdivisions) { @@ -166,13 +167,13 @@ void GPUParticles2D::set_trail_section_subdivisions(int p_subdivisions) { ERR_FAIL_COND(p_subdivisions > 1024); trail_section_subdivisions = p_subdivisions; - update(); + queue_redraw(); } #ifdef TOOLS_ENABLED void GPUParticles2D::set_show_visibility_rect(bool p_show_visibility_rect) { show_visibility_rect = p_show_visibility_rect; - update(); + queue_redraw(); } #endif @@ -331,9 +332,17 @@ Rect2 GPUParticles2D::capture_rect() const { } void GPUParticles2D::set_texture(const Ref<Texture2D> &p_texture) { + if (texture.is_valid()) { + texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &GPUParticles2D::_texture_changed)); + } + texture = p_texture; + + if (texture.is_valid()) { + texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &GPUParticles2D::_texture_changed)); + } _update_collision_size(); - update(); + queue_redraw(); } Ref<Texture2D> GPUParticles2D::get_texture() const { @@ -363,6 +372,14 @@ void GPUParticles2D::_attach_sub_emitter() { } } +void GPUParticles2D::_texture_changed() { + // Changes to the texture need to trigger an update to make + // the editor redraw the sprite with the updated texture. + if (texture.is_valid()) { + queue_redraw(); + } +} + void GPUParticles2D::set_sub_emitter(const NodePath &p_path) { if (is_inside_tree()) { RS::get_singleton()->particles_set_subemitter(particles, RID()); @@ -480,12 +497,21 @@ void GPUParticles2D::_notification(int p_what) { Vector2(-size.x / 2.0, size.y / 2.0) }; - Vector<Vector2> uvs = { - Vector2(0, 0), - Vector2(1, 0), - Vector2(1, 1), - Vector2(0, 1) - }; + Vector<Vector2> uvs; + AtlasTexture *atlas_texure = Object::cast_to<AtlasTexture>(*texture); + if (atlas_texure && atlas_texure->get_atlas().is_valid()) { + Rect2 region_rect = atlas_texure->get_region(); + Size2 atlas_size = atlas_texure->get_atlas()->get_size(); + uvs.push_back(Vector2(region_rect.position.x / atlas_size.x, region_rect.position.y / atlas_size.y)); + uvs.push_back(Vector2((region_rect.position.x + region_rect.size.x) / atlas_size.x, region_rect.position.y / atlas_size.y)); + uvs.push_back(Vector2((region_rect.position.x + region_rect.size.x) / atlas_size.x, (region_rect.position.y + region_rect.size.y) / atlas_size.y)); + uvs.push_back(Vector2(region_rect.position.x / atlas_size.x, (region_rect.position.y + region_rect.size.y) / atlas_size.y)); + } else { + uvs.push_back(Vector2(0, 0)); + uvs.push_back(Vector2(1, 0)); + uvs.push_back(Vector2(1, 1)); + uvs.push_back(Vector2(0, 1)); + } Vector<int> indices = { 0, 1, 2, 0, 2, 3 }; diff --git a/scene/2d/gpu_particles_2d.h b/scene/2d/gpu_particles_2d.h index 7eece32898..10ae91775f 100644 --- a/scene/2d/gpu_particles_2d.h +++ b/scene/2d/gpu_particles_2d.h @@ -82,6 +82,8 @@ private: void _attach_sub_emitter(); + void _texture_changed(); + protected: static void _bind_methods(); void _validate_property(PropertyInfo &p_property) const; diff --git a/scene/2d/joint_2d.cpp b/scene/2d/joint_2d.cpp index 7b9f7e14ca..89b6f3f9da 100644 --- a/scene/2d/joint_2d.cpp +++ b/scene/2d/joint_2d.cpp @@ -267,7 +267,7 @@ void PinJoint2D::_configure_joint(RID p_joint, PhysicsBody2D *body_a, PhysicsBod void PinJoint2D::set_softness(real_t p_softness) { softness = p_softness; - update(); + queue_redraw(); if (is_configured()) { PhysicsServer2D::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer2D::PIN_JOINT_SOFTNESS, p_softness); } @@ -321,7 +321,7 @@ void GrooveJoint2D::_configure_joint(RID p_joint, PhysicsBody2D *body_a, Physics void GrooveJoint2D::set_length(real_t p_length) { length = p_length; - update(); + queue_redraw(); } real_t GrooveJoint2D::get_length() const { @@ -330,7 +330,7 @@ real_t GrooveJoint2D::get_length() const { void GrooveJoint2D::set_initial_offset(real_t p_initial_offset) { initial_offset = p_initial_offset; - update(); + queue_redraw(); } real_t GrooveJoint2D::get_initial_offset() const { @@ -387,7 +387,7 @@ void DampedSpringJoint2D::_configure_joint(RID p_joint, PhysicsBody2D *body_a, P void DampedSpringJoint2D::set_length(real_t p_length) { length = p_length; - update(); + queue_redraw(); } real_t DampedSpringJoint2D::get_length() const { @@ -396,7 +396,7 @@ real_t DampedSpringJoint2D::get_length() const { void DampedSpringJoint2D::set_rest_length(real_t p_rest_length) { rest_length = p_rest_length; - update(); + queue_redraw(); if (is_configured()) { PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_SPRING_REST_LENGTH, p_rest_length ? p_rest_length : length); } @@ -408,7 +408,7 @@ real_t DampedSpringJoint2D::get_rest_length() const { void DampedSpringJoint2D::set_stiffness(real_t p_stiffness) { stiffness = p_stiffness; - update(); + queue_redraw(); if (is_configured()) { PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_SPRING_STIFFNESS, p_stiffness); } @@ -420,7 +420,7 @@ real_t DampedSpringJoint2D::get_stiffness() const { void DampedSpringJoint2D::set_damping(real_t p_damping) { damping = p_damping; - update(); + queue_redraw(); if (is_configured()) { PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_SPRING_DAMPING, p_damping); } diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp index 14188d7120..6c171383ca 100644 --- a/scene/2d/light_occluder_2d.cpp +++ b/scene/2d/light_occluder_2d.cpp @@ -153,7 +153,7 @@ OccluderPolygon2D::~OccluderPolygon2D() { void LightOccluder2D::_poly_changed() { #ifdef DEBUG_ENABLED - update(); + queue_redraw(); #endif } @@ -229,7 +229,7 @@ void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polyg if (occluder_polygon.is_valid()) { occluder_polygon->connect("changed", callable_mp(this, &LightOccluder2D::_poly_changed)); } - update(); + queue_redraw(); #endif } diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 837f3061f1..6a72280f3d 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -76,7 +76,7 @@ bool Line2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc void Line2D::set_points(const Vector<Vector2> &p_points) { _points = p_points; - update(); + queue_redraw(); } void Line2D::set_width(float p_width) { @@ -84,7 +84,7 @@ void Line2D::set_width(float p_width) { p_width = 0.0; } _width = p_width; - update(); + queue_redraw(); } float Line2D::get_width() const { @@ -104,7 +104,7 @@ void Line2D::set_curve(const Ref<Curve> &p_curve) { _curve->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Line2D::_curve_changed)); } - update(); + queue_redraw(); } Ref<Curve> Line2D::get_curve() const { @@ -118,7 +118,7 @@ Vector<Vector2> Line2D::get_points() const { void Line2D::set_point_position(int i, Vector2 p_pos) { ERR_FAIL_INDEX(i, _points.size()); _points.set(i, p_pos); - update(); + queue_redraw(); } Vector2 Line2D::get_point_position(int i) const { @@ -134,7 +134,7 @@ void Line2D::clear_points() { int count = _points.size(); if (count > 0) { _points.clear(); - update(); + queue_redraw(); } } @@ -144,17 +144,17 @@ void Line2D::add_point(Vector2 p_pos, int p_atpos) { } else { _points.insert(p_atpos, p_pos); } - update(); + queue_redraw(); } void Line2D::remove_point(int i) { _points.remove_at(i); - update(); + queue_redraw(); } void Line2D::set_default_color(Color p_color) { _default_color = p_color; - update(); + queue_redraw(); } Color Line2D::get_default_color() const { @@ -174,7 +174,7 @@ void Line2D::set_gradient(const Ref<Gradient> &p_gradient) { _gradient->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Line2D::_gradient_changed)); } - update(); + queue_redraw(); } Ref<Gradient> Line2D::get_gradient() const { @@ -183,7 +183,7 @@ Ref<Gradient> Line2D::get_gradient() const { void Line2D::set_texture(const Ref<Texture2D> &p_texture) { _texture = p_texture; - update(); + queue_redraw(); } Ref<Texture2D> Line2D::get_texture() const { @@ -192,7 +192,7 @@ Ref<Texture2D> Line2D::get_texture() const { void Line2D::set_texture_mode(const LineTextureMode p_mode) { _texture_mode = p_mode; - update(); + queue_redraw(); } Line2D::LineTextureMode Line2D::get_texture_mode() const { @@ -201,7 +201,7 @@ Line2D::LineTextureMode Line2D::get_texture_mode() const { void Line2D::set_joint_mode(LineJointMode p_mode) { _joint_mode = p_mode; - update(); + queue_redraw(); } Line2D::LineJointMode Line2D::get_joint_mode() const { @@ -210,7 +210,7 @@ Line2D::LineJointMode Line2D::get_joint_mode() const { void Line2D::set_begin_cap_mode(LineCapMode p_mode) { _begin_cap_mode = p_mode; - update(); + queue_redraw(); } Line2D::LineCapMode Line2D::get_begin_cap_mode() const { @@ -219,7 +219,7 @@ Line2D::LineCapMode Line2D::get_begin_cap_mode() const { void Line2D::set_end_cap_mode(LineCapMode p_mode) { _end_cap_mode = p_mode; - update(); + queue_redraw(); } Line2D::LineCapMode Line2D::get_end_cap_mode() const { @@ -239,7 +239,7 @@ void Line2D::set_sharp_limit(float p_limit) { p_limit = 0.f; } _sharp_limit = p_limit; - update(); + queue_redraw(); } float Line2D::get_sharp_limit() const { @@ -248,7 +248,7 @@ float Line2D::get_sharp_limit() const { void Line2D::set_round_precision(int p_precision) { _round_precision = MAX(1, p_precision); - update(); + queue_redraw(); } int Line2D::get_round_precision() const { @@ -257,7 +257,7 @@ int Line2D::get_round_precision() const { void Line2D::set_antialiased(bool p_antialiased) { _antialiased = p_antialiased; - update(); + queue_redraw(); } bool Line2D::get_antialiased() const { @@ -334,11 +334,11 @@ void Line2D::_draw() { } void Line2D::_gradient_changed() { - update(); + queue_redraw(); } void Line2D::_curve_changed() { - update(); + queue_redraw(); } // static diff --git a/scene/2d/marker_2d.cpp b/scene/2d/marker_2d.cpp index ba1d2ffbfd..d203c58ffd 100644 --- a/scene/2d/marker_2d.cpp +++ b/scene/2d/marker_2d.cpp @@ -86,7 +86,7 @@ bool Marker2D::_edit_use_rect() const { void Marker2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - update(); + queue_redraw(); } break; case NOTIFICATION_DRAW: { @@ -102,7 +102,7 @@ void Marker2D::_notification(int p_what) { void Marker2D::set_gizmo_extents(real_t p_extents) { gizmo_extents = p_extents; - update(); + queue_redraw(); } real_t Marker2D::get_gizmo_extents() const { diff --git a/scene/2d/mesh_instance_2d.cpp b/scene/2d/mesh_instance_2d.cpp index 178addd62d..56099205d4 100644 --- a/scene/2d/mesh_instance_2d.cpp +++ b/scene/2d/mesh_instance_2d.cpp @@ -61,7 +61,7 @@ void MeshInstance2D::_bind_methods() { void MeshInstance2D::set_mesh(const Ref<Mesh> &p_mesh) { mesh = p_mesh; - update(); + queue_redraw(); } Ref<Mesh> MeshInstance2D::get_mesh() const { @@ -73,13 +73,13 @@ void MeshInstance2D::set_texture(const Ref<Texture2D> &p_texture) { return; } texture = p_texture; - update(); + queue_redraw(); emit_signal(SceneStringNames::get_singleton()->texture_changed); } void MeshInstance2D::set_normal_map(const Ref<Texture2D> &p_texture) { normal_map = p_texture; - update(); + queue_redraw(); } Ref<Texture2D> MeshInstance2D::get_normal_map() const { diff --git a/scene/2d/multimesh_instance_2d.cpp b/scene/2d/multimesh_instance_2d.cpp index 8f72ff1757..68d529fd32 100644 --- a/scene/2d/multimesh_instance_2d.cpp +++ b/scene/2d/multimesh_instance_2d.cpp @@ -61,7 +61,7 @@ void MultiMeshInstance2D::_bind_methods() { void MultiMeshInstance2D::set_multimesh(const Ref<MultiMesh> &p_multimesh) { multimesh = p_multimesh; - update(); + queue_redraw(); } Ref<MultiMesh> MultiMeshInstance2D::get_multimesh() const { @@ -73,7 +73,7 @@ void MultiMeshInstance2D::set_texture(const Ref<Texture2D> &p_texture) { return; } texture = p_texture; - update(); + queue_redraw(); emit_signal(SceneStringNames::get_singleton()->texture_changed); } @@ -83,7 +83,7 @@ Ref<Texture2D> MultiMeshInstance2D::get_texture() const { void MultiMeshInstance2D::set_normal_map(const Ref<Texture2D> &p_texture) { normal_map = p_texture; - update(); + queue_redraw(); } Ref<Texture2D> MultiMeshInstance2D::get_normal_map() const { diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp index 00aa4b0b59..ffccb95a22 100644 --- a/scene/2d/navigation_region_2d.cpp +++ b/scene/2d/navigation_region_2d.cpp @@ -374,7 +374,7 @@ void NavigationRegion2D::set_enabled(bool p_enabled) { #ifdef DEBUG_ENABLED if (Engine::get_singleton()->is_editor_hint() || NavigationServer3D::get_singleton()->get_debug_enabled()) { - update(); + queue_redraw(); } #endif // DEBUG_ENABLED } @@ -551,7 +551,7 @@ Ref<NavigationPolygon> NavigationRegion2D::get_navigation_polygon() const { void NavigationRegion2D::_navpoly_changed() { if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())) { - update(); + queue_redraw(); } if (navpoly.is_valid()) { NavigationServer2D::get_singleton()->region_set_navpoly(region, navpoly); @@ -561,7 +561,7 @@ void NavigationRegion2D::_navpoly_changed() { void NavigationRegion2D::_map_changed(RID p_map) { #ifdef DEBUG_ENABLED if (is_inside_tree() && get_world_2d()->get_navigation_map() == p_map) { - update(); + queue_redraw(); } #endif // DEBUG_ENABLED } diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index bbc326a4b4..b883d14a41 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -131,7 +131,7 @@ void Path2D::_curve_changed() { return; } - update(); + queue_redraw(); } void Path2D::set_curve(const Ref<Curve2D> &p_curve) { diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 8161fb5bd9..111a0df89a 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -97,7 +97,7 @@ void Polygon2D::_validate_property(PropertyInfo &p_property) const { } void Polygon2D::_skeleton_bone_setup_changed() { - update(); + queue_redraw(); } void Polygon2D::_notification(int p_what) { @@ -375,7 +375,7 @@ void Polygon2D::_notification(int p_what) { void Polygon2D::set_polygon(const Vector<Vector2> &p_polygon) { polygon = p_polygon; rect_cache_dirty = true; - update(); + queue_redraw(); } Vector<Vector2> Polygon2D::get_polygon() const { @@ -392,7 +392,7 @@ int Polygon2D::get_internal_vertex_count() const { void Polygon2D::set_uv(const Vector<Vector2> &p_uv) { uv = p_uv; - update(); + queue_redraw(); } Vector<Vector2> Polygon2D::get_uv() const { @@ -401,7 +401,7 @@ Vector<Vector2> Polygon2D::get_uv() const { void Polygon2D::set_polygons(const Array &p_polygons) { polygons = p_polygons; - update(); + queue_redraw(); } Array Polygon2D::get_polygons() const { @@ -410,7 +410,7 @@ Array Polygon2D::get_polygons() const { void Polygon2D::set_color(const Color &p_color) { color = p_color; - update(); + queue_redraw(); } Color Polygon2D::get_color() const { @@ -419,7 +419,7 @@ Color Polygon2D::get_color() const { void Polygon2D::set_vertex_colors(const Vector<Color> &p_colors) { vertex_colors = p_colors; - update(); + queue_redraw(); } Vector<Color> Polygon2D::get_vertex_colors() const { @@ -428,7 +428,7 @@ Vector<Color> Polygon2D::get_vertex_colors() const { void Polygon2D::set_texture(const Ref<Texture2D> &p_texture) { texture = p_texture; - update(); + queue_redraw(); } Ref<Texture2D> Polygon2D::get_texture() const { @@ -437,7 +437,7 @@ Ref<Texture2D> Polygon2D::get_texture() const { void Polygon2D::set_texture_offset(const Vector2 &p_offset) { tex_ofs = p_offset; - update(); + queue_redraw(); } Vector2 Polygon2D::get_texture_offset() const { @@ -446,7 +446,7 @@ Vector2 Polygon2D::get_texture_offset() const { void Polygon2D::set_texture_rotation(real_t p_rot) { tex_rot = p_rot; - update(); + queue_redraw(); } real_t Polygon2D::get_texture_rotation() const { @@ -455,7 +455,7 @@ real_t Polygon2D::get_texture_rotation() const { void Polygon2D::set_texture_scale(const Size2 &p_scale) { tex_scale = p_scale; - update(); + queue_redraw(); } Size2 Polygon2D::get_texture_scale() const { @@ -464,7 +464,7 @@ Size2 Polygon2D::get_texture_scale() const { void Polygon2D::set_invert(bool p_invert) { invert = p_invert; - update(); + queue_redraw(); notify_property_list_changed(); } @@ -474,7 +474,7 @@ bool Polygon2D::get_invert() const { void Polygon2D::set_antialiased(bool p_antialiased) { antialiased = p_antialiased; - update(); + queue_redraw(); } bool Polygon2D::get_antialiased() const { @@ -483,7 +483,7 @@ bool Polygon2D::get_antialiased() const { void Polygon2D::set_invert_border(real_t p_invert_border) { invert_border = p_invert_border; - update(); + queue_redraw(); } real_t Polygon2D::get_invert_border() const { @@ -493,7 +493,7 @@ real_t Polygon2D::get_invert_border() const { void Polygon2D::set_offset(const Vector2 &p_offset) { offset = p_offset; rect_cache_dirty = true; - update(); + queue_redraw(); } Vector2 Polygon2D::get_offset() const { @@ -533,13 +533,13 @@ void Polygon2D::clear_bones() { void Polygon2D::set_bone_weights(int p_index, const Vector<float> &p_weights) { ERR_FAIL_INDEX(p_index, bone_weights.size()); bone_weights.write[p_index].weights = p_weights; - update(); + queue_redraw(); } void Polygon2D::set_bone_path(int p_index, const NodePath &p_path) { ERR_FAIL_INDEX(p_index, bone_weights.size()); bone_weights.write[p_index].path = p_path; - update(); + queue_redraw(); } Array Polygon2D::_get_bones() const { @@ -567,7 +567,7 @@ void Polygon2D::set_skeleton(const NodePath &p_skeleton) { return; } skeleton = p_skeleton; - update(); + queue_redraw(); } NodePath Polygon2D::get_skeleton() const { diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index c4036faa79..2c8a2e715a 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -36,7 +36,7 @@ void RayCast2D::set_target_position(const Vector2 &p_point) { target_position = p_point; if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint())) { - update(); + queue_redraw(); } } @@ -100,7 +100,7 @@ Vector2 RayCast2D::get_collision_normal() const { void RayCast2D::set_enabled(bool p_enabled) { enabled = p_enabled; - update(); + queue_redraw(); if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) { set_physics_process_internal(p_enabled); } @@ -219,7 +219,7 @@ void RayCast2D::_update_raycast_state() { } if (prev_collision_state != collided) { - update(); + queue_redraw(); } } diff --git a/scene/2d/shape_cast_2d.cpp b/scene/2d/shape_cast_2d.cpp index 316988d298..a25d5934ee 100644 --- a/scene/2d/shape_cast_2d.cpp +++ b/scene/2d/shape_cast_2d.cpp @@ -40,7 +40,7 @@ void ShapeCast2D::set_target_position(const Vector2 &p_point) { target_position = p_point; if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint())) { - update(); + queue_redraw(); } } @@ -132,7 +132,7 @@ real_t ShapeCast2D::get_closest_collision_unsafe_fraction() const { void ShapeCast2D::set_enabled(bool p_enabled) { enabled = p_enabled; - update(); + queue_redraw(); if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) { set_physics_process_internal(p_enabled); } @@ -152,7 +152,7 @@ void ShapeCast2D::set_shape(const Ref<Shape2D> &p_shape) { shape_rid = shape->get_rid(); } update_configuration_warnings(); - update(); + queue_redraw(); } Ref<Shape2D> ShapeCast2D::get_shape() const { @@ -182,7 +182,7 @@ bool ShapeCast2D::get_exclude_parent_body() const { } void ShapeCast2D::_redraw_shape() { - update(); + queue_redraw(); } void ShapeCast2D::_notification(int p_what) { @@ -325,7 +325,7 @@ void ShapeCast2D::_update_shapecast_state() { collided = !result.is_empty(); if (prev_collision_state != collided) { - update(); + queue_redraw(); } } diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp index 13a32fbfd4..8f0bf22617 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/scene/2d/skeleton_2d.cpp @@ -126,7 +126,7 @@ void Bone2D::_notification(int p_what) { return; } - update(); + queue_redraw(); #endif // TOOLS_ENABLED } break; @@ -143,12 +143,12 @@ void Bone2D::_notification(int p_what) { return; } - update(); + queue_redraw(); if (get_parent()) { Bone2D *parent_bone = Object::cast_to<Bone2D>(get_parent()); if (parent_bone) { - parent_bone->update(); + parent_bone->queue_redraw(); } } #endif // TOOLS_ENABLED @@ -365,7 +365,7 @@ bool Bone2D::_editor_get_bone_shape(Vector<Vector2> *p_shape, Vector<Vector2> *p void Bone2D::_editor_set_show_bone_gizmo(bool p_show_gizmo) { _editor_show_bone_gizmo = p_show_gizmo; - update(); + queue_redraw(); } bool Bone2D::_editor_get_show_bone_gizmo() const { @@ -493,7 +493,7 @@ void Bone2D::set_length(real_t p_length) { length = p_length; #ifdef TOOLS_ENABLED - update(); + queue_redraw(); #endif // TOOLS_ENABLED } @@ -505,7 +505,7 @@ void Bone2D::set_bone_angle(real_t p_angle) { bone_angle = p_angle; #ifdef TOOLS_ENABLED - update(); + queue_redraw(); #endif // TOOLS_ENABLED } diff --git a/scene/2d/sprite_2d.cpp b/scene/2d/sprite_2d.cpp index e1983f9cb9..0ecf8333a0 100644 --- a/scene/2d/sprite_2d.cpp +++ b/scene/2d/sprite_2d.cpp @@ -146,7 +146,7 @@ void Sprite2D::set_texture(const Ref<Texture2D> &p_texture) { texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite2D::_texture_changed)); } - update(); + queue_redraw(); emit_signal(SceneStringNames::get_singleton()->texture_changed); item_rect_changed(); } @@ -157,7 +157,7 @@ Ref<Texture2D> Sprite2D::get_texture() const { void Sprite2D::set_centered(bool p_center) { centered = p_center; - update(); + queue_redraw(); item_rect_changed(); } @@ -167,7 +167,7 @@ bool Sprite2D::is_centered() const { void Sprite2D::set_offset(const Point2 &p_offset) { offset = p_offset; - update(); + queue_redraw(); item_rect_changed(); } @@ -177,7 +177,7 @@ Point2 Sprite2D::get_offset() const { void Sprite2D::set_flip_h(bool p_flip) { hflip = p_flip; - update(); + queue_redraw(); } bool Sprite2D::is_flipped_h() const { @@ -186,7 +186,7 @@ bool Sprite2D::is_flipped_h() const { void Sprite2D::set_flip_v(bool p_flip) { vflip = p_flip; - update(); + queue_redraw(); } bool Sprite2D::is_flipped_v() const { @@ -199,7 +199,7 @@ void Sprite2D::set_region_enabled(bool p_region_enabled) { } region_enabled = p_region_enabled; - update(); + queue_redraw(); notify_property_list_changed(); } @@ -225,7 +225,7 @@ Rect2 Sprite2D::get_region_rect() const { void Sprite2D::set_region_filter_clip_enabled(bool p_region_filter_clip_enabled) { region_filter_clip_enabled = p_region_filter_clip_enabled; - update(); + queue_redraw(); } bool Sprite2D::is_region_filter_clip_enabled() const { @@ -262,7 +262,7 @@ Vector2i Sprite2D::get_frame_coords() const { void Sprite2D::set_vframes(int p_amount) { ERR_FAIL_COND_MSG(p_amount < 1, "Amount of vframes cannot be smaller than 1."); vframes = p_amount; - update(); + queue_redraw(); item_rect_changed(); notify_property_list_changed(); } @@ -274,7 +274,7 @@ int Sprite2D::get_vframes() const { void Sprite2D::set_hframes(int p_amount) { ERR_FAIL_COND_MSG(p_amount < 1, "Amount of hframes cannot be smaller than 1."); hframes = p_amount; - update(); + queue_redraw(); item_rect_changed(); notify_property_list_changed(); } @@ -388,7 +388,7 @@ void Sprite2D::_texture_changed() { // Changes to the texture need to trigger an update to make // the editor redraw the sprite with the updated texture. if (texture.is_valid()) { - update(); + queue_redraw(); } } diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp index 9dea69cd64..b620f58ed7 100644 --- a/scene/2d/touch_screen_button.cpp +++ b/scene/2d/touch_screen_button.cpp @@ -34,7 +34,7 @@ void TouchScreenButton::set_texture_normal(const Ref<Texture2D> &p_texture) { texture_normal = p_texture; - update(); + queue_redraw(); } Ref<Texture2D> TouchScreenButton::get_texture_normal() const { @@ -43,7 +43,7 @@ Ref<Texture2D> TouchScreenButton::get_texture_normal() const { void TouchScreenButton::set_texture_pressed(const Ref<Texture2D> &p_texture_pressed) { texture_pressed = p_texture_pressed; - update(); + queue_redraw(); } Ref<Texture2D> TouchScreenButton::get_texture_pressed() const { @@ -60,16 +60,16 @@ Ref<BitMap> TouchScreenButton::get_bitmask() const { void TouchScreenButton::set_shape(const Ref<Shape2D> &p_shape) { if (shape.is_valid()) { - shape->disconnect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); + shape->disconnect("changed", callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); } shape = p_shape; if (shape.is_valid()) { - shape->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); + shape->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); } - update(); + queue_redraw(); } Ref<Shape2D> TouchScreenButton::get_shape() const { @@ -78,7 +78,7 @@ Ref<Shape2D> TouchScreenButton::get_shape() const { void TouchScreenButton::set_shape_centered(bool p_shape_centered) { shape_centered = p_shape_centered; - update(); + queue_redraw(); } bool TouchScreenButton::is_shape_visible() const { @@ -87,7 +87,7 @@ bool TouchScreenButton::is_shape_visible() const { void TouchScreenButton::set_shape_visible(bool p_shape_visible) { shape_visible = p_shape_visible; - update(); + queue_redraw(); } bool TouchScreenButton::is_shape_centered() const { @@ -140,7 +140,7 @@ void TouchScreenButton::_notification(int p_what) { if (!Engine::get_singleton()->is_editor_hint() && !!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id())) && visibility == VISIBILITY_TOUCHSCREEN_ONLY) { return; } - update(); + queue_redraw(); if (!Engine::get_singleton()->is_editor_hint()) { set_process_input(is_visible_in_tree()); @@ -292,7 +292,7 @@ void TouchScreenButton::_press(int p_finger_pressed) { } emit_signal(SNAME("pressed")); - update(); + queue_redraw(); } void TouchScreenButton::_release(bool p_exiting_tree) { @@ -311,7 +311,7 @@ void TouchScreenButton::_release(bool p_exiting_tree) { if (!p_exiting_tree) { emit_signal(SNAME("released")); - update(); + queue_redraw(); } } @@ -339,7 +339,7 @@ Rect2 TouchScreenButton::get_anchorable_rect() const { void TouchScreenButton::set_visibility_mode(VisibilityMode p_mode) { visibility = p_mode; - update(); + queue_redraw(); } TouchScreenButton::VisibilityMode TouchScreenButton::get_visibility_mode() const { diff --git a/scene/2d/visible_on_screen_notifier_2d.cpp b/scene/2d/visible_on_screen_notifier_2d.cpp index 1971dc1240..263c3a12a2 100644 --- a/scene/2d/visible_on_screen_notifier_2d.cpp +++ b/scene/2d/visible_on_screen_notifier_2d.cpp @@ -66,7 +66,7 @@ void VisibleOnScreenNotifier2D::set_rect(const Rect2 &p_rect) { if (is_inside_tree()) { RS::get_singleton()->canvas_item_set_visibility_notifier(get_canvas_item(), true, rect, callable_mp(this, &VisibleOnScreenNotifier2D::_visibility_enter), callable_mp(this, &VisibleOnScreenNotifier2D::_visibility_exit)); } - update(); + queue_redraw(); } Rect2 VisibleOnScreenNotifier2D::get_rect() const { diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index 31993f898d..a76f4dd0d5 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -115,8 +115,8 @@ void MeshInstance3D::set_mesh(const Ref<Mesh> &p_mesh) { if (mesh.is_valid()) { mesh->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance3D::_mesh_changed)); - _mesh_changed(); set_base(mesh->get_rid()); + _mesh_changed(); } else { blend_shape_tracks.clear(); blend_shape_properties.clear(); @@ -380,6 +380,13 @@ void MeshInstance3D::_mesh_changed() { } } + int surface_count = mesh->get_surface_count(); + for (int surface_index = 0; surface_index < surface_count; ++surface_index) { + if (surface_override_materials[surface_index].is_valid()) { + RS::get_singleton()->instance_set_surface_override_material(get_instance(), surface_index, surface_override_materials[surface_index]->get_rid()); + } + } + update_gizmos(); } diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 7d9f83b7a2..5b18d4e457 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -75,10 +75,17 @@ Ref<PropertyTweener> Tween::tween_property(Object *p_target, NodePath p_property ERR_FAIL_COND_V_MSG(!valid, nullptr, "Tween invalid. Either finished or created outside scene tree."); ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first."); -#ifdef DEBUG_ENABLED Variant::Type property_type = p_target->get_indexed(p_property.get_as_property_path().get_subnames()).get_type(); - ERR_FAIL_COND_V_MSG(property_type != p_to.get_type(), Ref<PropertyTweener>(), "Type mismatch between property and final value: " + Variant::get_type_name(property_type) + " and " + Variant::get_type_name(p_to.get_type())); -#endif + if (property_type != p_to.get_type()) { + // Cast p_to between floats and ints to avoid minor annoyances. + if (property_type == Variant::FLOAT && p_to.get_type() == Variant::INT) { + p_to = float(p_to); + } else if (property_type == Variant::INT && p_to.get_type() == Variant::FLOAT) { + p_to = int(p_to); + } else { + ERR_FAIL_V_MSG(Ref<PropertyTweener>(), "Type mismatch between property and final value: " + Variant::get_type_name(property_type) + " and " + Variant::get_type_name(p_to.get_type())); + } + } Ref<PropertyTweener> tweener = memnew(PropertyTweener(p_target, p_property, p_to, p_duration)); append(tweener); diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index cee7c049a9..cf467ceafb 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -77,7 +77,7 @@ void BaseButton::gui_input(const Ref<InputEvent> &p_event) { bool last_press_inside = status.pressing_inside; status.pressing_inside = has_point(mouse_motion->get_position()); if (last_press_inside != status.pressing_inside) { - update(); + queue_redraw(); } } } @@ -87,32 +87,32 @@ void BaseButton::_notification(int p_what) { switch (p_what) { case NOTIFICATION_MOUSE_ENTER: { status.hovering = true; - update(); + queue_redraw(); } break; case NOTIFICATION_MOUSE_EXIT: { status.hovering = false; - update(); + queue_redraw(); } break; case NOTIFICATION_DRAG_BEGIN: case NOTIFICATION_SCROLL_BEGIN: { if (status.press_attempt) { status.press_attempt = false; - update(); + queue_redraw(); } } break; case NOTIFICATION_FOCUS_ENTER: { - update(); + queue_redraw(); } break; case NOTIFICATION_FOCUS_EXIT: { if (status.press_attempt) { status.press_attempt = false; - update(); + queue_redraw(); } else if (status.hovering) { - update(); + queue_redraw(); } } break; @@ -188,7 +188,7 @@ void BaseButton::on_action_event(Ref<InputEvent> p_event) { emit_signal(SNAME("button_up")); } - update(); + queue_redraw(); } void BaseButton::pressed() { @@ -210,7 +210,7 @@ void BaseButton::set_disabled(bool p_disabled) { status.press_attempt = false; status.pressing_inside = false; } - update(); + queue_redraw(); } bool BaseButton::is_disabled() const { @@ -234,7 +234,7 @@ void BaseButton::set_pressed(bool p_pressed) { } _toggled(status.pressed); - update(); + queue_redraw(); } void BaseButton::set_pressed_no_signal(bool p_pressed) { @@ -246,7 +246,7 @@ void BaseButton::set_pressed_no_signal(bool p_pressed) { } status.pressed = p_pressed; - update(); + queue_redraw(); } bool BaseButton::is_pressing() const { @@ -385,7 +385,7 @@ void BaseButton::set_button_group(const Ref<ButtonGroup> &p_group) { button_group->buttons.insert(this); } - update(); //checkbox changes to radio if set a buttongroup + queue_redraw(); //checkbox changes to radio if set a buttongroup } Ref<ButtonGroup> BaseButton::get_button_group() const { diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index e163f4355c..0b7280619e 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -49,7 +49,7 @@ void Button::_set_internal_margin(Side p_side, float p_value) { void Button::_notification(int p_what) { switch (p_what) { case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { - update(); + queue_redraw(); } break; case NOTIFICATION_TRANSLATION_CHANGED: { @@ -57,14 +57,14 @@ void Button::_notification(int p_what) { _shape(); update_minimum_size(); - update(); + queue_redraw(); } break; case NOTIFICATION_THEME_CHANGED: { _shape(); update_minimum_size(); - update(); + queue_redraw(); } break; case NOTIFICATION_DRAW: { @@ -389,7 +389,7 @@ void Button::set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior) { overrun_behavior = p_behavior; _shape(); - update(); + queue_redraw(); update_minimum_size(); } } @@ -404,7 +404,7 @@ void Button::set_text(const String &p_text) { xl_text = atr(text); _shape(); - update(); + queue_redraw(); update_minimum_size(); } } @@ -418,7 +418,7 @@ void Button::set_text_direction(Control::TextDirection p_text_direction) { if (text_direction != p_text_direction) { text_direction = p_text_direction; _shape(); - update(); + queue_redraw(); } } @@ -430,7 +430,7 @@ void Button::set_language(const String &p_language) { if (language != p_language) { language = p_language; _shape(); - update(); + queue_redraw(); } } @@ -441,7 +441,7 @@ String Button::get_language() const { void Button::set_icon(const Ref<Texture2D> &p_icon) { if (icon != p_icon) { icon = p_icon; - update(); + queue_redraw(); update_minimum_size(); } } @@ -453,7 +453,7 @@ Ref<Texture2D> Button::get_icon() const { void Button::set_expand_icon(bool p_enabled) { if (expand_icon != p_enabled) { expand_icon = p_enabled; - update(); + queue_redraw(); update_minimum_size(); } } @@ -465,7 +465,7 @@ bool Button::is_expand_icon() const { void Button::set_flat(bool p_enabled) { if (flat != p_enabled) { flat = p_enabled; - update(); + queue_redraw(); } } @@ -476,7 +476,7 @@ bool Button::is_flat() const { void Button::set_clip_text(bool p_enabled) { if (clip_text != p_enabled) { clip_text = p_enabled; - update(); + queue_redraw(); update_minimum_size(); } } @@ -488,7 +488,7 @@ bool Button::get_clip_text() const { void Button::set_text_alignment(HorizontalAlignment p_alignment) { if (alignment != p_alignment) { alignment = p_alignment; - update(); + queue_redraw(); } } @@ -499,7 +499,7 @@ HorizontalAlignment Button::get_text_alignment() const { void Button::set_icon_alignment(HorizontalAlignment p_alignment) { icon_alignment = p_alignment; update_minimum_size(); - update(); + queue_redraw(); } HorizontalAlignment Button::get_icon_alignment() const { diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index e54ba7ce13..1ef1801457 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -268,7 +268,7 @@ void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) { if (is_code_completion_scroll_pressed && mb->get_button_index() == MouseButton::LEFT) { is_code_completion_scroll_pressed = false; - update(); + queue_redraw(); return; } @@ -281,13 +281,13 @@ void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) { case MouseButton::WHEEL_UP: { if (code_completion_current_selected > 0) { code_completion_current_selected--; - update(); + queue_redraw(); } } break; case MouseButton::WHEEL_DOWN: { if (code_completion_current_selected < code_completion_options.size() - 1) { code_completion_current_selected++; - update(); + queue_redraw(); } } break; case MouseButton::LEFT: { @@ -295,7 +295,7 @@ void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) { if (mb->is_double_click()) { confirm_code_completion(); } - update(); + queue_redraw(); } break; default: break; @@ -310,7 +310,7 @@ void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) { is_code_completion_scroll_pressed = true; _update_scroll_selected_line(mb->get_position().y); - update(); + queue_redraw(); } return; @@ -384,12 +384,12 @@ void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) { bool scroll_hovered = code_completion_scroll_rect.has_point(mpos); if (is_code_completion_scroll_hovered != scroll_hovered) { is_code_completion_scroll_hovered = scroll_hovered; - update(); + queue_redraw(); } if (is_code_completion_scroll_pressed) { _update_scroll_selected_line(mpos.y); - update(); + queue_redraw(); return; } } @@ -448,7 +448,7 @@ void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) { } else { code_completion_current_selected = code_completion_options.size() - 1; } - update(); + queue_redraw(); accept_event(); return; } @@ -458,31 +458,31 @@ void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) { } else { code_completion_current_selected = 0; } - update(); + queue_redraw(); accept_event(); return; } if (k->is_action("ui_page_up", true)) { code_completion_current_selected = MAX(0, code_completion_current_selected - code_completion_max_lines); - update(); + queue_redraw(); accept_event(); return; } if (k->is_action("ui_page_down", true)) { code_completion_current_selected = MIN(code_completion_options.size() - 1, code_completion_current_selected + code_completion_max_lines); - update(); + queue_redraw(); accept_event(); return; } if (k->is_action("ui_home", true)) { code_completion_current_selected = 0; - update(); + queue_redraw(); accept_event(); return; } if (k->is_action("ui_end", true)) { code_completion_current_selected = code_completion_options.size() - 1; - update(); + queue_redraw(); accept_event(); return; } @@ -1106,7 +1106,7 @@ bool CodeEdit::is_auto_brace_completion_enabled() const { void CodeEdit::set_highlight_matching_braces_enabled(bool p_enabled) { highlight_matching_braces_enabled = p_enabled; - update(); + queue_redraw(); } bool CodeEdit::is_highlight_matching_braces_enabled() const { @@ -1265,7 +1265,7 @@ void CodeEdit::set_line_as_breakpoint(int p_line, bool p_breakpointed) { breakpointed_lines.erase(p_line); } emit_signal(SNAME("breakpoint_toggled"), p_line); - update(); + queue_redraw(); } bool CodeEdit::is_line_breakpointed(int p_line) const { @@ -1294,7 +1294,7 @@ PackedInt32Array CodeEdit::get_breakpointed_lines() const { void CodeEdit::set_line_as_bookmarked(int p_line, bool p_bookmarked) { int mask = get_line_gutter_metadata(p_line, main_gutter); set_line_gutter_metadata(p_line, main_gutter, p_bookmarked ? mask | MAIN_GUTTER_BOOKMARK : mask & ~MAIN_GUTTER_BOOKMARK); - update(); + queue_redraw(); } bool CodeEdit::is_line_bookmarked(int p_line) const { @@ -1323,7 +1323,7 @@ PackedInt32Array CodeEdit::get_bookmarked_lines() const { void CodeEdit::set_line_as_executing(int p_line, bool p_executing) { int mask = get_line_gutter_metadata(p_line, main_gutter); set_line_gutter_metadata(p_line, main_gutter, p_executing ? mask | MAIN_GUTTER_EXECUTING : mask & ~MAIN_GUTTER_EXECUTING); - update(); + queue_redraw(); } bool CodeEdit::is_line_executing(int p_line) const { @@ -1359,7 +1359,7 @@ bool CodeEdit::is_draw_line_numbers_enabled() const { void CodeEdit::set_line_numbers_zero_padded(bool p_zero_padded) { p_zero_padded ? line_number_padding = "0" : line_number_padding = " "; - update(); + queue_redraw(); } bool CodeEdit::is_line_numbers_zero_padded() const { @@ -1529,7 +1529,7 @@ void CodeEdit::fold_line(int p_line) { set_caret_line(p_line, false, false); set_caret_column(get_line(p_line).length(), false); } - update(); + queue_redraw(); } void CodeEdit::unfold_line(int p_line) { @@ -1552,14 +1552,14 @@ void CodeEdit::unfold_line(int p_line) { } _set_line_as_hidden(i, false); } - update(); + queue_redraw(); } void CodeEdit::fold_all_lines() { for (int i = 0; i < get_line_count(); i++) { fold_line(i); } - update(); + queue_redraw(); } void CodeEdit::unfold_all_lines() { @@ -1765,12 +1765,12 @@ Point2 CodeEdit::get_delimiter_end_position(int p_line, int p_column) const { void CodeEdit::set_code_hint(const String &p_hint) { code_hint = p_hint; code_hint_xpos = -0xFFFF; - update(); + queue_redraw(); } void CodeEdit::set_code_hint_draw_below(bool p_below) { code_hint_draw_below = p_below; - update(); + queue_redraw(); } /* Code Completion */ @@ -1929,7 +1929,7 @@ void CodeEdit::set_code_completion_selected_index(int p_index) { } ERR_FAIL_INDEX(p_index, code_completion_options.size()); code_completion_current_selected = p_index; - update(); + queue_redraw(); } void CodeEdit::confirm_code_completion(bool p_replace) { @@ -2043,13 +2043,13 @@ void CodeEdit::cancel_code_completion() { } code_completion_forced = false; code_completion_active = false; - update(); + queue_redraw(); } /* Line length guidelines */ void CodeEdit::set_line_length_guidelines(TypedArray<int> p_guideline_columns) { line_length_guideline_columns = p_guideline_columns; - update(); + queue_redraw(); } TypedArray<int> CodeEdit::get_line_length_guidelines() const { @@ -2802,7 +2802,7 @@ void CodeEdit::_filter_code_completion_candidates_impl() { code_completion_longest_line = MIN(max_width, code_completion_max_width * font_size); code_completion_current_selected = 0; code_completion_active = true; - update(); + queue_redraw(); return; } @@ -3052,7 +3052,7 @@ void CodeEdit::_filter_code_completion_candidates_impl() { code_completion_longest_line = MIN(max_width, code_completion_max_width * font_size); code_completion_current_selected = 0; code_completion_active = true; - update(); + queue_redraw(); } void CodeEdit::_lines_edited_from(int p_from_line, int p_to_line) { diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index a417e7b9e2..3030fdff8d 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -303,7 +303,7 @@ void ColorPicker::set_edit_alpha(bool p_show) { } _update_color(); - sample->update(); + sample->queue_redraw(); } bool ColorPicker::is_editing_alpha() const { @@ -458,15 +458,15 @@ void ColorPicker::_update_color(bool p_update_sliders) { _update_text_value(); - sample->update(); - uv_edit->update(); - w_edit->update(); + sample->queue_redraw(); + uv_edit->queue_redraw(); + w_edit->queue_redraw(); for (int i = 0; i < current_slider_count; i++) { - sliders[i]->update(); + sliders[i]->queue_redraw(); } - alpha_slider->update(); - wheel->update(); - wheel_uv->update(); + alpha_slider->queue_redraw(); + wheel->queue_redraw(); + wheel_uv->queue_redraw(); updating = false; } @@ -1359,7 +1359,7 @@ void ColorPickerButton::_about_to_popup() { void ColorPickerButton::_color_changed(const Color &p_color) { color = p_color; - update(); + queue_redraw(); emit_signal(SNAME("color_changed"), color); } @@ -1439,7 +1439,7 @@ void ColorPickerButton::set_pick_color(const Color &p_color) { picker->set_pick_color(p_color); } - update(); + queue_redraw(); } Color ColorPickerButton::get_pick_color() const { diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp index c30fa8461a..143662efc6 100644 --- a/scene/gui/color_rect.cpp +++ b/scene/gui/color_rect.cpp @@ -35,7 +35,7 @@ void ColorRect::set_color(const Color &p_color) { return; } color = p_color; - update(); + queue_redraw(); } Color ColorRect::get_color() const { diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 4de16a0a29..5e8d5a567f 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -713,7 +713,7 @@ void Control::set_anchor(Side p_side, real_t p_anchor, bool p_keep_offset, bool _size_changed(); } - update(); + queue_redraw(); } real_t Control::get_anchor(Side p_side) const { @@ -1459,7 +1459,7 @@ void Control::set_scale(const Vector2 &p_scale) { if (data.scale.y == 0) { data.scale.y = CMP_EPSILON; } - update(); + queue_redraw(); _notify_transform(); } @@ -1473,7 +1473,7 @@ void Control::set_rotation(real_t p_radians) { } data.rotation = p_radians; - update(); + queue_redraw(); _notify_transform(); } @@ -1487,7 +1487,7 @@ void Control::set_pivot_offset(const Vector2 &p_pivot) { } data.pivot_offset = p_pivot; - update(); + queue_redraw(); _notify_transform(); } @@ -2240,7 +2240,7 @@ void Control::set_disable_visibility_clip(bool p_ignore) { return; } data.disable_visibility_clip = p_ignore; - update(); + queue_redraw(); } bool Control::is_visibility_clip_disabled() const { @@ -2252,7 +2252,7 @@ void Control::set_clip_contents(bool p_clip) { return; } data.clip_contents = p_clip; - update(); + queue_redraw(); } bool Control::is_clipping_contents() { @@ -3196,9 +3196,9 @@ void Control::_notification(int p_notification) { // some parents need to know the order of the children to draw (like TabContainer) // update if necessary if (data.parent) { - data.parent->update(); + data.parent->queue_redraw(); } - update(); + queue_redraw(); if (data.RI) { get_viewport()->_gui_set_root_order_dirty(); @@ -3225,19 +3225,19 @@ void Control::_notification(int p_notification) { case NOTIFICATION_FOCUS_ENTER: { emit_signal(SceneStringNames::get_singleton()->focus_entered); - update(); + queue_redraw(); } break; case NOTIFICATION_FOCUS_EXIT: { emit_signal(SceneStringNames::get_singleton()->focus_exited); - update(); + queue_redraw(); } break; case NOTIFICATION_THEME_CHANGED: { emit_signal(SceneStringNames::get_singleton()->theme_changed); _invalidate_theme_cache(); update_minimum_size(); - update(); + queue_redraw(); } break; case NOTIFICATION_VISIBILITY_CHANGED: { diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 57655afb4c..2a56d6d222 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -163,7 +163,7 @@ Vector<String> FileDialog::get_selected_files() const { TreeItem *item = tree->get_root(); while ((item = tree->get_next_selected(item))) { - list.push_back(dir_access->get_current_dir().plus_file(item->get_text(0))); + list.push_back(dir_access->get_current_dir().path_join(item->get_text(0))); }; return list; @@ -192,7 +192,7 @@ void FileDialog::update_dir() { } void FileDialog::_dir_submitted(String p_dir) { - _change_dir(root_prefix.plus_file(p_dir)); + _change_dir(root_prefix.path_join(p_dir)); file->set_text(""); _push_history(); } @@ -202,7 +202,7 @@ void FileDialog::_file_submitted(const String &p_file) { } void FileDialog::_save_confirm_pressed() { - String f = dir_access->get_current_dir().plus_file(file->get_text()); + String f = dir_access->get_current_dir().path_join(file->get_text()); emit_signal(SNAME("file_selected"), f); hide(); } @@ -252,7 +252,7 @@ void FileDialog::_action_pressed() { Vector<String> files; while (ti) { - files.push_back(fbase.plus_file(ti->get_text(0))); + files.push_back(fbase.path_join(ti->get_text(0))); ti = tree->get_next_selected(ti); } @@ -265,7 +265,7 @@ void FileDialog::_action_pressed() { } String file_text = file->get_text(); - String f = file_text.is_absolute_path() ? file_text : dir_access->get_current_dir().plus_file(file_text); + String f = file_text.is_absolute_path() ? file_text : dir_access->get_current_dir().path_join(file_text); if ((mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_FILE) && dir_access->file_exists(f)) { emit_signal(SNAME("file_selected"), f); @@ -278,7 +278,7 @@ void FileDialog::_action_pressed() { if (item) { Dictionary d = item->get_metadata(0); if (d["dir"] && d["name"] != "..") { - path = path.plus_file(d["name"]); + path = path.path_join(d["name"]); } } @@ -598,7 +598,7 @@ void FileDialog::update_file_list() { ti->set_text(0, files.front()->get()); if (get_icon_func) { - Ref<Texture2D> icon = get_icon_func(base_dir.plus_file(files.front()->get())); + Ref<Texture2D> icon = get_icon_func(base_dir.path_join(files.front()->get())); ti->set_icon(0, icon); } else { ti->set_icon(0, file_icon); @@ -706,7 +706,7 @@ String FileDialog::get_current_file() const { } String FileDialog::get_current_path() const { - return dir->get_text().plus_file(file->get_text()); + return dir->get_text().path_join(file->get_text()); } void FileDialog::set_current_dir(const String &p_dir) { diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index cc27a6b7c2..5e56be7c29 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -92,7 +92,7 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { points.remove_at(grabbed); grabbed = -1; grabbing = false; - update(); + queue_redraw(); emit_signal(SNAME("ramp_changed")); accept_event(); } @@ -112,7 +112,7 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { points.remove_at(grabbed); grabbed = -1; grabbing = false; - update(); + queue_redraw(); emit_signal(SNAME("ramp_changed")); accept_event(); } @@ -138,13 +138,13 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { } emit_signal(SNAME("ramp_changed")); - update(); + queue_redraw(); } } // Select. if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT && mb->is_pressed()) { - update(); + queue_redraw(); int x = mb->get_position().x; int total_w = get_size().width - get_size().height - draw_spacing; @@ -214,7 +214,7 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { grabbing = false; emit_signal(SNAME("ramp_changed")); } - update(); + queue_redraw(); } Ref<InputEventMouseMotion> mm = p_event; @@ -282,7 +282,7 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { emit_signal(SNAME("ramp_changed")); - update(); + queue_redraw(); } } @@ -378,7 +378,7 @@ void GradientEdit::_color_changed(const Color &p_color) { return; } points.write[grabbed].color = p_color; - update(); + queue_redraw(); emit_signal(SNAME("ramp_changed")); } @@ -393,7 +393,7 @@ void GradientEdit::set_ramp(const Vector<float> &p_offsets, const Vector<Color> } points.sort(); - update(); + queue_redraw(); } Vector<float> GradientEdit::get_offsets() const { diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 00f2e48601..8c16f8ca26 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -176,7 +176,7 @@ void GraphEditMinimap::gui_input(const Ref<InputEvent> &p_ev) { new_minimap_size.y = MIN(get_size().y - mm->get_relative().y, ge->get_size().y - 2.0 * minimap_padding.y); ge->set_minimap_size(new_minimap_size); - update(); + queue_redraw(); } else { Vector2 click_position = _convert_to_graph_position(mm->get_position() - minimap_padding) - graph_padding; _adjust_graph_scroll(click_position); @@ -201,10 +201,10 @@ Error GraphEdit::connect_node(const StringName &p_from, int p_from_port, const S c.to_port = p_to_port; c.activity = 0; connections.push_back(c); - top_layer->update(); - minimap->update(); - update(); - connections_layer->update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); + queue_redraw(); + connections_layer->queue_redraw(); return OK; } @@ -223,10 +223,10 @@ void GraphEdit::disconnect_node(const StringName &p_from, int p_from_port, const for (const List<Connection>::Element *E = connections.front(); E; E = E->next()) { if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) { connections.erase(E); - top_layer->update(); - minimap->update(); - update(); - connections_layer->update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); + queue_redraw(); + connections_layer->queue_redraw(); return; } } @@ -253,9 +253,9 @@ void GraphEdit::_scroll_moved(double) { call_deferred(SNAME("_update_scroll_offset")); awaiting_scroll_offset_update = true; } - top_layer->update(); - minimap->update(); - update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); + queue_redraw(); if (!setting_scroll_ofs) { //in godot, signals on change value are avoided as a convention emit_signal(SNAME("scroll_offset_changed"), get_scroll_ofs()); @@ -359,19 +359,19 @@ void GraphEdit::_graph_node_raised(Node *p_gn) { void GraphEdit::_graph_node_moved(Node *p_gn) { GraphNode *gn = Object::cast_to<GraphNode>(p_gn); ERR_FAIL_COND(!gn); - top_layer->update(); - minimap->update(); - update(); - connections_layer->update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); + queue_redraw(); + connections_layer->queue_redraw(); } void GraphEdit::_graph_node_slot_updated(int p_index, Node *p_gn) { GraphNode *gn = Object::cast_to<GraphNode>(p_gn); ERR_FAIL_COND(!gn); - top_layer->update(); - minimap->update(); - update(); - connections_layer->update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); + queue_redraw(); + connections_layer->queue_redraw(); } void GraphEdit::add_child_notify(Node *p_child) { @@ -385,8 +385,8 @@ void GraphEdit::add_child_notify(Node *p_child) { gn->connect("position_offset_changed", callable_mp(this, &GraphEdit::_graph_node_moved).bind(gn)); gn->connect("slot_updated", callable_mp(this, &GraphEdit::_graph_node_slot_updated).bind(gn)); gn->connect("raise_request", callable_mp(this, &GraphEdit::_graph_node_raised).bind(gn)); - gn->connect("item_rect_changed", callable_mp((CanvasItem *)connections_layer, &CanvasItem::update)); - gn->connect("item_rect_changed", callable_mp((CanvasItem *)minimap, &GraphEditMinimap::update)); + gn->connect("item_rect_changed", callable_mp((CanvasItem *)connections_layer, &CanvasItem::queue_redraw)); + gn->connect("item_rect_changed", callable_mp((CanvasItem *)minimap, &GraphEditMinimap::queue_redraw)); _graph_node_moved(gn); gn->set_mouse_filter(MOUSE_FILTER_PASS); } @@ -414,10 +414,10 @@ void GraphEdit::remove_child_notify(Node *p_child) { // In case of the whole GraphEdit being destroyed these references can already be freed. if (connections_layer != nullptr && connections_layer->is_inside_tree()) { - gn->disconnect("item_rect_changed", callable_mp((CanvasItem *)connections_layer, &CanvasItem::update)); + gn->disconnect("item_rect_changed", callable_mp((CanvasItem *)connections_layer, &CanvasItem::queue_redraw)); } if (minimap != nullptr && minimap->is_inside_tree()) { - gn->disconnect("item_rect_changed", callable_mp((CanvasItem *)minimap, &GraphEditMinimap::update)); + gn->disconnect("item_rect_changed", callable_mp((CanvasItem *)minimap, &GraphEditMinimap::queue_redraw)); } } } @@ -500,8 +500,8 @@ void GraphEdit::_notification(int p_what) { case NOTIFICATION_RESIZED: { _update_scroll(); - top_layer->update(); - minimap->update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); } break; } } @@ -698,8 +698,8 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { if (mm.is_valid() && connecting) { connecting_to = mm->get_position(); connecting_target = false; - top_layer->update(); - minimap->update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); connecting_valid = just_disconnected || click_pos.distance_to(connecting_to / zoom) > 20.0; if (connecting_valid) { @@ -1191,8 +1191,8 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) { } } - top_layer->update(); - minimap->update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); } Ref<InputEventMouseButton> b = p_ev; @@ -1214,8 +1214,8 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) { } gn->set_selected(select); } - top_layer->update(); - minimap->update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); } else { if (connecting) { force_connection_drag_end(); @@ -1261,10 +1261,10 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) { dragging = false; - top_layer->update(); - minimap->update(); - update(); - connections_layer->update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); + queue_redraw(); + connections_layer->queue_redraw(); } if (b->get_button_index() == MouseButton::LEFT && b->is_pressed()) { @@ -1377,8 +1377,8 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) { box_selecting = false; box_selecting_rect = Rect2(); previous_selected.clear(); - top_layer->update(); - minimap->update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); } } @@ -1444,9 +1444,9 @@ void GraphEdit::set_connection_activity(const StringName &p_from, int p_from_por if (E.from == p_from && E.from_port == p_from_port && E.to == p_to && E.to_port == p_to_port) { if (Math::is_equal_approx(E.activity, p_activity)) { //update only if changed - top_layer->update(); - minimap->update(); - connections_layer->update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); + connections_layer->queue_redraw(); } E.activity = p_activity; return; @@ -1456,19 +1456,19 @@ void GraphEdit::set_connection_activity(const StringName &p_from, int p_from_por void GraphEdit::clear_connections() { connections.clear(); - minimap->update(); - update(); - connections_layer->update(); + minimap->queue_redraw(); + queue_redraw(); + connections_layer->queue_redraw(); } void GraphEdit::force_connection_drag_end() { ERR_FAIL_COND_MSG(!connecting, "Drag end requested without active drag!"); connecting = false; connecting_valid = false; - top_layer->update(); - minimap->update(); - update(); - connections_layer->update(); + top_layer->queue_redraw(); + minimap->queue_redraw(); + queue_redraw(); + connections_layer->queue_redraw(); emit_signal(SNAME("connection_drag_ended")); } @@ -1502,14 +1502,14 @@ void GraphEdit::set_zoom_custom(float p_zoom, const Vector2 &p_center) { Vector2 sbofs = (Vector2(h_scroll->get_value(), v_scroll->get_value()) + p_center) / zoom; zoom = p_zoom; - top_layer->update(); + top_layer->queue_redraw(); zoom_minus->set_disabled(zoom == zoom_min); zoom_plus->set_disabled(zoom == zoom_max); _update_scroll(); - minimap->update(); - connections_layer->update(); + minimap->queue_redraw(); + connections_layer->queue_redraw(); if (is_visible_in_tree()) { Vector2 ofs = sbofs * zoom - p_center; @@ -1518,7 +1518,7 @@ void GraphEdit::set_zoom_custom(float p_zoom, const Vector2 &p_center) { } _update_zoom_label(); - update(); + queue_redraw(); } float GraphEdit::get_zoom() const { @@ -1657,7 +1657,7 @@ void GraphEdit::set_use_snap(bool p_enable) { return; } snap_button->set_pressed(p_enable); - update(); + queue_redraw(); } bool GraphEdit::is_using_snap() const { @@ -1671,15 +1671,15 @@ int GraphEdit::get_snap() const { void GraphEdit::set_snap(int p_snap) { ERR_FAIL_COND(p_snap < 5); snap_amount->set_value(p_snap); - update(); + queue_redraw(); } void GraphEdit::_snap_toggled() { - update(); + queue_redraw(); } void GraphEdit::_snap_value_changed(double) { - update(); + queue_redraw(); } void GraphEdit::set_minimap_size(Vector2 p_size) { @@ -1691,7 +1691,7 @@ void GraphEdit::set_minimap_size(Vector2 p_size) { minimap->set_offset(Side::SIDE_TOP, -minimap_size.y - MINIMAP_OFFSET); minimap->set_offset(Side::SIDE_RIGHT, -MINIMAP_OFFSET); minimap->set_offset(Side::SIDE_BOTTOM, -MINIMAP_OFFSET); - minimap->update(); + minimap->queue_redraw(); } Vector2 GraphEdit::get_minimap_size() const { @@ -1703,7 +1703,7 @@ void GraphEdit::set_minimap_opacity(float p_opacity) { return; } minimap->set_modulate(Color(1, 1, 1, p_opacity)); - minimap->update(); + minimap->queue_redraw(); } float GraphEdit::get_minimap_opacity() const { @@ -1717,7 +1717,7 @@ void GraphEdit::set_minimap_enabled(bool p_enable) { } minimap_button->set_pressed(p_enable); _minimap_toggled(); - minimap->update(); + minimap->queue_redraw(); } bool GraphEdit::is_minimap_enabled() const { @@ -1740,7 +1740,7 @@ bool GraphEdit::is_arrange_nodes_button_hidden() const { void GraphEdit::_minimap_toggled() { if (is_minimap_enabled()) { minimap->set_visible(true); - minimap->update(); + minimap->queue_redraw(); } else { minimap->set_visible(false); } @@ -1748,7 +1748,7 @@ void GraphEdit::_minimap_toggled() { void GraphEdit::set_connection_lines_curvature(float p_curvature) { lines_curvature = p_curvature; - update(); + queue_redraw(); } float GraphEdit::get_connection_lines_curvature() const { @@ -1760,7 +1760,7 @@ void GraphEdit::set_connection_lines_thickness(float p_thickness) { return; } lines_thickness = p_thickness; - update(); + queue_redraw(); } float GraphEdit::get_connection_lines_thickness() const { @@ -1772,7 +1772,7 @@ void GraphEdit::set_connection_lines_antialiased(bool p_antialiased) { return; } lines_antialiased = p_antialiased; - update(); + queue_redraw(); } bool GraphEdit::is_connection_lines_antialiased() const { diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index b07d401e6b..5976d9fc37 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -78,7 +78,7 @@ bool GraphNode::_set(const StringName &p_name, const Variant &p_value) { } set_slot(idx, si.enable_left, si.type_left, si.color_left, si.enable_right, si.type_right, si.color_right, si.custom_slot_left, si.custom_slot_right, si.draw_stylebox); - update(); + queue_redraw(); return true; } @@ -288,7 +288,7 @@ void GraphNode::_resort() { idx++; } - update(); + queue_redraw(); connpos_dirty = true; } @@ -416,7 +416,7 @@ void GraphNode::_notification(int p_what) { _shape(); update_minimum_size(); - update(); + queue_redraw(); } break; } } @@ -475,7 +475,7 @@ void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const C s.custom_slot_right = p_custom_right; s.draw_stylebox = p_draw_stylebox; slot_info[p_idx] = s; - update(); + queue_redraw(); connpos_dirty = true; emit_signal(SNAME("slot_updated"), p_idx); @@ -483,13 +483,13 @@ void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const C void GraphNode::clear_slot(int p_idx) { slot_info.erase(p_idx); - update(); + queue_redraw(); connpos_dirty = true; } void GraphNode::clear_all_slots() { slot_info.clear(); - update(); + queue_redraw(); connpos_dirty = true; } @@ -508,7 +508,7 @@ void GraphNode::set_slot_enabled_left(int p_idx, bool p_enable_left) { } slot_info[p_idx].enable_left = p_enable_left; - update(); + queue_redraw(); connpos_dirty = true; emit_signal(SNAME("slot_updated"), p_idx); @@ -522,7 +522,7 @@ void GraphNode::set_slot_type_left(int p_idx, int p_type_left) { } slot_info[p_idx].type_left = p_type_left; - update(); + queue_redraw(); connpos_dirty = true; emit_signal(SNAME("slot_updated"), p_idx); @@ -543,7 +543,7 @@ void GraphNode::set_slot_color_left(int p_idx, const Color &p_color_left) { } slot_info[p_idx].color_left = p_color_left; - update(); + queue_redraw(); connpos_dirty = true; emit_signal(SNAME("slot_updated"), p_idx); @@ -571,7 +571,7 @@ void GraphNode::set_slot_enabled_right(int p_idx, bool p_enable_right) { } slot_info[p_idx].enable_right = p_enable_right; - update(); + queue_redraw(); connpos_dirty = true; emit_signal(SNAME("slot_updated"), p_idx); @@ -585,7 +585,7 @@ void GraphNode::set_slot_type_right(int p_idx, int p_type_right) { } slot_info[p_idx].type_right = p_type_right; - update(); + queue_redraw(); connpos_dirty = true; emit_signal(SNAME("slot_updated"), p_idx); @@ -606,7 +606,7 @@ void GraphNode::set_slot_color_right(int p_idx, const Color &p_color_right) { } slot_info[p_idx].color_right = p_color_right; - update(); + queue_redraw(); connpos_dirty = true; emit_signal(SNAME("slot_updated"), p_idx); @@ -630,7 +630,7 @@ void GraphNode::set_slot_draw_stylebox(int p_idx, bool p_enable) { ERR_FAIL_COND_MSG(p_idx < 0, vformat("Cannot set draw_stylebox for the slot with p_idx (%d) lesser than zero.", p_idx)); slot_info[p_idx].draw_stylebox = p_enable; - update(); + queue_redraw(); connpos_dirty = true; emit_signal(SNAME("slot_updated"), p_idx); @@ -688,7 +688,7 @@ void GraphNode::set_title(const String &p_title) { title = p_title; _shape(); - update(); + queue_redraw(); update_minimum_size(); } @@ -701,7 +701,7 @@ void GraphNode::set_text_direction(Control::TextDirection p_text_direction) { if (text_direction != p_text_direction) { text_direction = p_text_direction; _shape(); - update(); + queue_redraw(); } } @@ -713,7 +713,7 @@ void GraphNode::set_language(const String &p_language) { if (language != p_language) { language = p_language; _shape(); - update(); + queue_redraw(); } } @@ -728,7 +728,7 @@ void GraphNode::set_position_offset(const Vector2 &p_offset) { position_offset = p_offset; emit_signal(SNAME("position_offset_changed")); - update(); + queue_redraw(); } Vector2 GraphNode::get_position_offset() const { @@ -741,7 +741,7 @@ void GraphNode::set_selected(bool p_selected) { } selected = p_selected; - update(); + queue_redraw(); } bool GraphNode::is_selected() { @@ -766,7 +766,7 @@ void GraphNode::set_show_close_button(bool p_enable) { } show_close = p_enable; - update(); + queue_redraw(); } bool GraphNode::is_close_button_visible() const { @@ -970,7 +970,7 @@ void GraphNode::set_overlay(Overlay p_overlay) { } overlay = p_overlay; - update(); + queue_redraw(); } GraphNode::Overlay GraphNode::get_overlay() const { @@ -983,7 +983,7 @@ void GraphNode::set_comment(bool p_enable) { } comment = p_enable; - update(); + queue_redraw(); } bool GraphNode::is_comment() const { @@ -996,7 +996,7 @@ void GraphNode::set_resizable(bool p_enable) { } resizable = p_enable; - update(); + queue_redraw(); } bool GraphNode::is_resizable() const { diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 086f729603..e3a27ba7d5 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -63,7 +63,7 @@ int ItemList::add_item(const String &p_item, const Ref<Texture2D> &p_texture, bo _shape(items.size() - 1); - update(); + queue_redraw(); shape_changed = true; notify_property_list_changed(); return item_id; @@ -76,7 +76,7 @@ int ItemList::add_icon_item(const Ref<Texture2D> &p_item, bool p_selectable) { items.push_back(item); int item_id = items.size() - 1; - update(); + queue_redraw(); shape_changed = true; notify_property_list_changed(); return item_id; @@ -94,7 +94,7 @@ void ItemList::set_item_text(int p_idx, const String &p_text) { items.write[p_idx].text = p_text; _shape(p_idx); - update(); + queue_redraw(); shape_changed = true; } @@ -112,7 +112,7 @@ void ItemList::set_item_text_direction(int p_idx, Control::TextDirection p_text_ if (items[p_idx].text_direction != p_text_direction) { items.write[p_idx].text_direction = p_text_direction; _shape(p_idx); - update(); + queue_redraw(); } } @@ -129,7 +129,7 @@ void ItemList::set_item_language(int p_idx, const String &p_language) { if (items[p_idx].language != p_language) { items.write[p_idx].language = p_language; _shape(p_idx); - update(); + queue_redraw(); } } @@ -162,7 +162,7 @@ void ItemList::set_item_tooltip(int p_idx, const String &p_tooltip) { } items.write[p_idx].tooltip = p_tooltip; - update(); + queue_redraw(); shape_changed = true; } @@ -182,7 +182,7 @@ void ItemList::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) { } items.write[p_idx].icon = p_icon; - update(); + queue_redraw(); shape_changed = true; } @@ -203,7 +203,7 @@ void ItemList::set_item_icon_transposed(int p_idx, const bool p_transposed) { } items.write[p_idx].icon_transposed = p_transposed; - update(); + queue_redraw(); shape_changed = true; } @@ -224,7 +224,7 @@ void ItemList::set_item_icon_region(int p_idx, const Rect2 &p_region) { } items.write[p_idx].icon_region = p_region; - update(); + queue_redraw(); shape_changed = true; } @@ -245,7 +245,7 @@ void ItemList::set_item_icon_modulate(int p_idx, const Color &p_modulate) { } items.write[p_idx].icon_modulate = p_modulate; - update(); + queue_redraw(); } Color ItemList::get_item_icon_modulate(int p_idx) const { @@ -265,7 +265,7 @@ void ItemList::set_item_custom_bg_color(int p_idx, const Color &p_custom_bg_colo } items.write[p_idx].custom_bg = p_custom_bg_color; - update(); + queue_redraw(); } Color ItemList::get_item_custom_bg_color(int p_idx) const { @@ -285,7 +285,7 @@ void ItemList::set_item_custom_fg_color(int p_idx, const Color &p_custom_fg_colo } items.write[p_idx].custom_fg = p_custom_fg_color; - update(); + queue_redraw(); } Color ItemList::get_item_custom_fg_color(int p_idx) const { @@ -305,7 +305,7 @@ void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture2D> &p_tag_icon) { } items.write[p_idx].tag_icon = p_tag_icon; - update(); + queue_redraw(); shape_changed = true; } @@ -340,7 +340,7 @@ void ItemList::set_item_disabled(int p_idx, bool p_disabled) { } items.write[p_idx].disabled = p_disabled; - update(); + queue_redraw(); } bool ItemList::is_item_disabled(int p_idx) const { @@ -359,7 +359,7 @@ void ItemList::set_item_metadata(int p_idx, const Variant &p_metadata) { } items.write[p_idx].metadata = p_metadata; - update(); + queue_redraw(); shape_changed = true; } @@ -387,7 +387,7 @@ void ItemList::select(int p_idx, bool p_single) { items.write[p_idx].selected = true; } } - update(); + queue_redraw(); } void ItemList::deselect(int p_idx) { @@ -399,7 +399,7 @@ void ItemList::deselect(int p_idx) { } else { items.write[p_idx].selected = false; } - update(); + queue_redraw(); } void ItemList::deselect_all() { @@ -411,7 +411,7 @@ void ItemList::deselect_all() { items.write[i].selected = false; } current = -1; - update(); + queue_redraw(); } bool ItemList::is_selected(int p_idx) const { @@ -431,7 +431,7 @@ void ItemList::set_current(int p_current) { select(p_current, true); } else { current = p_current; - update(); + queue_redraw(); } } @@ -451,7 +451,7 @@ void ItemList::move_item(int p_from_idx, int p_to_idx) { items.remove_at(p_from_idx); items.insert(p_to_idx, item); - update(); + queue_redraw(); shape_changed = true; notify_property_list_changed(); } @@ -464,7 +464,7 @@ void ItemList::set_item_count(int p_count) { } items.resize(p_count); - update(); + queue_redraw(); shape_changed = true; notify_property_list_changed(); } @@ -480,7 +480,7 @@ void ItemList::remove_item(int p_idx) { if (current == p_idx) { current = -1; } - update(); + queue_redraw(); shape_changed = true; defer_select_single = -1; notify_property_list_changed(); @@ -490,7 +490,7 @@ void ItemList::clear() { items.clear(); current = -1; ensure_selected_visible = false; - update(); + queue_redraw(); shape_changed = true; defer_select_single = -1; notify_property_list_changed(); @@ -504,7 +504,7 @@ void ItemList::set_fixed_column_width(int p_size) { } fixed_column_width = p_size; - update(); + queue_redraw(); shape_changed = true; } @@ -518,7 +518,7 @@ void ItemList::set_same_column_width(bool p_enable) { } same_column_width = p_enable; - update(); + queue_redraw(); shape_changed = true; } @@ -539,7 +539,7 @@ void ItemList::set_max_text_lines(int p_lines) { } } shape_changed = true; - update(); + queue_redraw(); } } @@ -555,7 +555,7 @@ void ItemList::set_max_columns(int p_amount) { } max_columns = p_amount; - update(); + queue_redraw(); shape_changed = true; } @@ -569,7 +569,7 @@ void ItemList::set_select_mode(SelectMode p_mode) { } select_mode = p_mode; - update(); + queue_redraw(); } ItemList::SelectMode ItemList::get_select_mode() const { @@ -588,7 +588,7 @@ void ItemList::set_icon_mode(IconMode p_mode) { } } shape_changed = true; - update(); + queue_redraw(); } } @@ -602,7 +602,7 @@ void ItemList::set_fixed_icon_size(const Size2 &p_size) { } fixed_icon_size = p_size; - update(); + queue_redraw(); } Size2 ItemList::get_fixed_icon_size() const { @@ -961,7 +961,7 @@ void ItemList::gui_input(const Ref<InputEvent> &p_event) { void ItemList::ensure_current_is_visible() { ensure_selected_visible = true; - update(); + queue_redraw(); } static Rect2 _adjust_to_max_size(Size2 p_size, Size2 p_max_size) { @@ -984,7 +984,7 @@ void ItemList::_notification(int p_what) { switch (p_what) { case NOTIFICATION_RESIZED: { shape_changed = true; - update(); + queue_redraw(); } break; case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: @@ -994,7 +994,7 @@ void ItemList::_notification(int p_what) { _shape(i); } shape_changed = true; - update(); + queue_redraw(); } break; case NOTIFICATION_DRAW: { @@ -1430,7 +1430,7 @@ void ItemList::_notification(int p_what) { } void ItemList::_scroll_changed(double) { - update(); + queue_redraw(); } int ItemList::get_item_at_position(const Point2 &p_pos, bool p_exact) const { @@ -1505,7 +1505,7 @@ String ItemList::get_tooltip(const Point2 &p_pos) const { void ItemList::sort_items_by_text() { items.sort(); - update(); + queue_redraw(); shape_changed = true; if (select_mode == SELECT_SINGLE) { @@ -1593,7 +1593,7 @@ void ItemList::set_auto_height(bool p_enable) { auto_height = p_enable; shape_changed = true; - update(); + queue_redraw(); } bool ItemList::has_auto_height() const { @@ -1607,7 +1607,7 @@ void ItemList::set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior) items.write[i].text_buf->set_text_overrun_behavior(p_behavior); } shape_changed = true; - update(); + queue_redraw(); } } diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index fa7d4195cb..cd68d1f001 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -44,7 +44,7 @@ void Label::set_autowrap_mode(TextServer::AutowrapMode p_mode) { autowrap_mode = p_mode; lines_dirty = true; - update(); + queue_redraw(); if (clip || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { update_minimum_size(); @@ -63,7 +63,7 @@ void Label::set_uppercase(bool p_uppercase) { uppercase = p_uppercase; dirty = true; - update(); + queue_redraw(); } bool Label::is_uppercase() const { @@ -284,11 +284,11 @@ void Label::_notification(int p_what) { } dirty = true; - update(); + queue_redraw(); } break; case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { - update(); + queue_redraw(); } break; case NOTIFICATION_DRAW: { @@ -544,7 +544,7 @@ void Label::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { font_dirty = true; - update(); + queue_redraw(); } break; case NOTIFICATION_RESIZED: { @@ -623,7 +623,7 @@ void Label::set_horizontal_alignment(HorizontalAlignment p_alignment) { } horizontal_alignment = p_alignment; - update(); + queue_redraw(); } HorizontalAlignment Label::get_horizontal_alignment() const { @@ -638,7 +638,7 @@ void Label::set_vertical_alignment(VerticalAlignment p_alignment) { } vertical_alignment = p_alignment; - update(); + queue_redraw(); } VerticalAlignment Label::get_vertical_alignment() const { @@ -655,13 +655,13 @@ void Label::set_text(const String &p_string) { if (visible_ratio < 1) { visible_chars = get_total_character_count() * visible_ratio; } - update(); + queue_redraw(); update_minimum_size(); } void Label::_invalidate() { font_dirty = true; - update(); + queue_redraw(); } void Label::set_label_settings(const Ref<LabelSettings> &p_settings) { @@ -686,7 +686,7 @@ void Label::set_text_direction(Control::TextDirection p_text_direction) { if (text_direction != p_text_direction) { text_direction = p_text_direction; font_dirty = true; - update(); + queue_redraw(); } } @@ -694,7 +694,7 @@ void Label::set_structured_text_bidi_override(TextServer::StructuredTextParser p if (st_parser != p_parser) { st_parser = p_parser; dirty = true; - update(); + queue_redraw(); } } @@ -709,7 +709,7 @@ void Label::set_structured_text_bidi_override_options(Array p_args) { st_args = p_args; dirty = true; - update(); + queue_redraw(); } Array Label::get_structured_text_bidi_override_options() const { @@ -724,7 +724,7 @@ void Label::set_language(const String &p_language) { if (language != p_language) { language = p_language; dirty = true; - update(); + queue_redraw(); } } @@ -738,7 +738,7 @@ void Label::set_clip_text(bool p_clip) { } clip = p_clip; - update(); + queue_redraw(); update_minimum_size(); } @@ -753,7 +753,7 @@ void Label::set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior) { overrun_behavior = p_behavior; lines_dirty = true; - update(); + queue_redraw(); if (clip || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { update_minimum_size(); } @@ -778,7 +778,7 @@ void Label::set_visible_characters(int p_amount) { if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) { dirty = true; } - update(); + queue_redraw(); } } @@ -802,7 +802,7 @@ void Label::set_visible_ratio(float p_ratio) { if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) { dirty = true; } - update(); + queue_redraw(); } } @@ -818,7 +818,7 @@ void Label::set_visible_characters_behavior(TextServer::VisibleCharactersBehavio if (visible_chars_behavior != p_behavior) { visible_chars_behavior = p_behavior; dirty = true; - update(); + queue_redraw(); } } @@ -831,7 +831,7 @@ void Label::set_lines_skipped(int p_lines) { lines_skipped = p_lines; _update_visible(); - update(); + queue_redraw(); } int Label::get_lines_skipped() const { @@ -845,7 +845,7 @@ void Label::set_max_lines_visible(int p_lines) { max_lines_visible = p_lines; _update_visible(); - update(); + queue_redraw(); } int Label::get_max_lines_visible() const { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 34a60b907c..aa8a825014 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -51,7 +51,7 @@ void LineEdit::_swap_current_input_direction() { input_direction = TEXT_DIRECTION_LTR; } set_caret_column(get_caret_column()); - update(); + queue_redraw(); } void LineEdit::_move_caret_left(bool p_select, bool p_move_by_word) { @@ -285,7 +285,7 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) { if (!text.is_empty() && is_editable() && _is_over_clear_button(b->get_position())) { clear_button_status.press_attempt = true; clear_button_status.pressing_inside = true; - update(); + queue_redraw(); return; } @@ -348,7 +348,7 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) { } } - update(); + queue_redraw(); } else { if (selection.enabled && !pass && b->get_button_index() == MouseButton::LEFT && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_CLIPBOARD_PRIMARY)) { @@ -375,7 +375,7 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) { show_virtual_keyboard(); } - update(); + queue_redraw(); } Ref<InputEventMouseMotion> m = p_event; @@ -385,7 +385,7 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) { bool last_press_inside = clear_button_status.pressing_inside; clear_button_status.pressing_inside = clear_button_status.press_attempt && _is_over_clear_button(m->get_position()); if (last_press_inside != clear_button_status.pressing_inside) { - update(); + queue_redraw(); } } @@ -613,7 +613,7 @@ void LineEdit::set_horizontal_alignment(HorizontalAlignment p_alignment) { alignment = p_alignment; _shape(); - update(); + queue_redraw(); } HorizontalAlignment LineEdit::get_horizontal_alignment() const { @@ -681,7 +681,7 @@ void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) { } text_changed_dirty = true; } - update(); + queue_redraw(); } } @@ -725,25 +725,25 @@ void LineEdit::_notification(int p_what) { case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_THEME_CHANGED: { _shape(); - update(); + queue_redraw(); } break; case NOTIFICATION_TRANSLATION_CHANGED: { placeholder_translated = atr(placeholder); _shape(); - update(); + queue_redraw(); } break; case NOTIFICATION_WM_WINDOW_FOCUS_IN: { window_has_focus = true; draw_caret = true; - update(); + queue_redraw(); } break; case NOTIFICATION_WM_WINDOW_FOCUS_OUT: { window_has_focus = false; draw_caret = false; - update(); + queue_redraw(); } break; case NOTIFICATION_INTERNAL_PROCESS: { @@ -1052,7 +1052,7 @@ void LineEdit::_notification(int p_what) { _shape(); set_caret_column(caret_column); // Update scroll_offset - update(); + queue_redraw(); } } break; @@ -1357,7 +1357,7 @@ bool LineEdit::is_caret_force_displayed() const { void LineEdit::set_caret_force_displayed(const bool p_enabled) { caret_force_displayed = p_enabled; set_caret_blink_enabled(caret_blink_enabled); - update(); + queue_redraw(); } float LineEdit::get_caret_blink_speed() const { @@ -1374,7 +1374,7 @@ void LineEdit::_reset_caret_blink_timer() { draw_caret = true; if (has_focus()) { caret_blink_timer = 0.0; - update(); + queue_redraw(); } } } @@ -1382,7 +1382,7 @@ void LineEdit::_reset_caret_blink_timer() { void LineEdit::_toggle_draw_caret() { draw_caret = !draw_caret; if (is_visible_in_tree() && ((has_focus() && window_has_focus) || caret_force_displayed)) { - update(); + queue_redraw(); } } @@ -1425,7 +1425,7 @@ void LineEdit::set_text(String p_text) { insert_text_at_caret(p_text); _create_undo_state(); - update(); + queue_redraw(); caret_column = 0; scroll_offset = 0.0; } @@ -1445,7 +1445,7 @@ void LineEdit::set_text_direction(Control::TextDirection p_text_direction) { menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_LTR), text_direction == TEXT_DIRECTION_LTR); menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_RTL), text_direction == TEXT_DIRECTION_RTL); } - update(); + queue_redraw(); } } @@ -1457,7 +1457,7 @@ void LineEdit::set_language(const String &p_language) { if (language != p_language) { language = p_language; _shape(); - update(); + queue_redraw(); } } @@ -1472,7 +1472,7 @@ void LineEdit::set_draw_control_chars(bool p_draw_control_chars) { menu->set_item_checked(menu->get_item_index(MENU_DISPLAY_UCC), draw_control_chars); } _shape(); - update(); + queue_redraw(); } } @@ -1484,7 +1484,7 @@ void LineEdit::set_structured_text_bidi_override(TextServer::StructuredTextParse if (st_parser != p_parser) { st_parser = p_parser; _shape(); - update(); + queue_redraw(); } } @@ -1495,7 +1495,7 @@ TextServer::StructuredTextParser LineEdit::get_structured_text_bidi_override() c void LineEdit::set_structured_text_bidi_override_options(Array p_args) { st_args = p_args; _shape(); - update(); + queue_redraw(); } Array LineEdit::get_structured_text_bidi_override_options() const { @@ -1534,7 +1534,7 @@ void LineEdit::set_placeholder(String p_text) { placeholder = p_text; placeholder_translated = atr(placeholder); _shape(); - update(); + queue_redraw(); } String LineEdit::get_placeholder() const { @@ -1614,7 +1614,7 @@ void LineEdit::set_caret_column(int p_column) { } scroll_offset = MIN(0, scroll_offset); - update(); + queue_redraw(); } int LineEdit::get_caret_column() const { @@ -1660,7 +1660,7 @@ void LineEdit::clear_internal() { undo_text = ""; text = ""; _shape(); - update(); + queue_redraw(); } Size2 LineEdit::get_minimum_size() const { @@ -1704,7 +1704,7 @@ void LineEdit::deselect() { selection.enabled = false; selection.creating = false; selection.double_click = false; - update(); + queue_redraw(); } bool LineEdit::has_selection() const { @@ -1768,7 +1768,7 @@ void LineEdit::select_all() { selection.begin = 0; selection.end = text.length(); selection.enabled = true; - update(); + queue_redraw(); } void LineEdit::set_editable(bool p_editable) { @@ -1779,7 +1779,7 @@ void LineEdit::set_editable(bool p_editable) { editable = p_editable; update_minimum_size(); - update(); + queue_redraw(); } bool LineEdit::is_editable() const { @@ -1793,7 +1793,7 @@ void LineEdit::set_secret(bool p_secret) { pass = p_secret; _shape(); - update(); + queue_redraw(); } bool LineEdit::is_secret() const { @@ -1811,7 +1811,7 @@ void LineEdit::set_secret_character(const String &p_string) { secret_character = p_string; _shape(); - update(); + queue_redraw(); } String LineEdit::get_secret_character() const { @@ -1848,7 +1848,7 @@ void LineEdit::select(int p_from, int p_to) { selection.end = p_to; selection.creating = false; selection.double_click = false; - update(); + queue_redraw(); } bool LineEdit::is_text_field() const { @@ -2027,7 +2027,7 @@ void LineEdit::set_clear_button_enabled(bool p_enabled) { clear_button_enabled = p_enabled; _fit_to_width(); update_minimum_size(); - update(); + queue_redraw(); } bool LineEdit::is_clear_button_enabled() const { @@ -2104,7 +2104,7 @@ void LineEdit::set_right_icon(const Ref<Texture2D> &p_icon) { right_icon = p_icon; _fit_to_width(); update_minimum_size(); - update(); + queue_redraw(); } Ref<Texture2D> LineEdit::get_right_icon() { @@ -2114,7 +2114,7 @@ Ref<Texture2D> LineEdit::get_right_icon() { void LineEdit::set_flat(bool p_enabled) { if (flat != p_enabled) { flat = p_enabled; - update(); + queue_redraw(); } } diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp index ee3f64e0e5..b0252ac685 100644 --- a/scene/gui/link_button.cpp +++ b/scene/gui/link_button.cpp @@ -54,7 +54,7 @@ void LinkButton::set_text(const String &p_text) { xl_text = atr(text); _shape(); update_minimum_size(); - update(); + queue_redraw(); } String LinkButton::get_text() const { @@ -65,7 +65,7 @@ void LinkButton::set_structured_text_bidi_override(TextServer::StructuredTextPar if (st_parser != p_parser) { st_parser = p_parser; _shape(); - update(); + queue_redraw(); } } @@ -76,7 +76,7 @@ TextServer::StructuredTextParser LinkButton::get_structured_text_bidi_override() void LinkButton::set_structured_text_bidi_override_options(Array p_args) { st_args = p_args; _shape(); - update(); + queue_redraw(); } Array LinkButton::get_structured_text_bidi_override_options() const { @@ -88,7 +88,7 @@ void LinkButton::set_text_direction(Control::TextDirection p_text_direction) { if (text_direction != p_text_direction) { text_direction = p_text_direction; _shape(); - update(); + queue_redraw(); } } @@ -100,7 +100,7 @@ void LinkButton::set_language(const String &p_language) { if (language != p_language) { language = p_language; _shape(); - update(); + queue_redraw(); } } @@ -114,7 +114,7 @@ void LinkButton::set_underline_mode(UnderlineMode p_underline_mode) { } underline_mode = p_underline_mode; - update(); + queue_redraw(); } LinkButton::UnderlineMode LinkButton::get_underline_mode() const { @@ -131,17 +131,17 @@ void LinkButton::_notification(int p_what) { xl_text = atr(text); _shape(); update_minimum_size(); - update(); + queue_redraw(); } break; case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { - update(); + queue_redraw(); } break; case NOTIFICATION_THEME_CHANGED: { _shape(); update_minimum_size(); - update(); + queue_redraw(); } break; case NOTIFICATION_DRAW: { diff --git a/scene/gui/menu_bar.cpp b/scene/gui/menu_bar.cpp index 9b7b67d83e..8aad14e1ec 100644 --- a/scene/gui/menu_bar.cpp +++ b/scene/gui/menu_bar.cpp @@ -95,7 +95,7 @@ void MenuBar::gui_input(const Ref<InputEvent> &p_event) { selected_menu = focused_menu; } if (selected_menu != old_sel) { - update(); + queue_redraw(); } } @@ -143,7 +143,7 @@ void MenuBar::_open_popup(int p_index, bool p_focus_item) { } } - update(); + queue_redraw(); } void MenuBar::shortcut_input(const Ref<InputEvent> &p_event) { @@ -212,7 +212,7 @@ void MenuBar::_popup_visibility_changed(bool p_visible) { active_menu = -1; focused_menu = -1; set_process_internal(false); - update(); + queue_redraw(); return; } @@ -337,7 +337,7 @@ void MenuBar::_update_menu() { } } update_minimum_size(); - update(); + queue_redraw(); } void MenuBar::_notification(int p_what) { @@ -352,7 +352,7 @@ void MenuBar::_notification(int p_what) { } break; case NOTIFICATION_MOUSE_EXIT: { focused_menu = -1; - update(); + queue_redraw(); } break; case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: @@ -716,7 +716,7 @@ String MenuBar::get_language() const { void MenuBar::set_flat(bool p_enabled) { if (flat != p_enabled) { flat = p_enabled; - update(); + queue_redraw(); } } diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp index a7e86dd5de..6048916d7d 100644 --- a/scene/gui/nine_patch_rect.cpp +++ b/scene/gui/nine_patch_rect.cpp @@ -94,7 +94,7 @@ void NinePatchRect::set_texture(const Ref<Texture2D> &p_tex) { return; } texture = p_tex; - update(); + queue_redraw(); update_minimum_size(); emit_signal(SceneStringNames::get_singleton()->texture_changed); } @@ -111,7 +111,7 @@ void NinePatchRect::set_patch_margin(Side p_side, int p_size) { } margin[p_side] = p_size; - update(); + queue_redraw(); update_minimum_size(); } @@ -140,7 +140,7 @@ void NinePatchRect::set_draw_center(bool p_enabled) { } draw_center = p_enabled; - update(); + queue_redraw(); } bool NinePatchRect::is_draw_center_enabled() const { @@ -153,7 +153,7 @@ void NinePatchRect::set_h_axis_stretch_mode(AxisStretchMode p_mode) { } axis_h = p_mode; - update(); + queue_redraw(); } NinePatchRect::AxisStretchMode NinePatchRect::get_h_axis_stretch_mode() const { @@ -166,7 +166,7 @@ void NinePatchRect::set_v_axis_stretch_mode(AxisStretchMode p_mode) { } axis_v = p_mode; - update(); + queue_redraw(); } NinePatchRect::AxisStretchMode NinePatchRect::get_v_axis_stretch_mode() const { diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index c8bb9fd530..c3060bf242 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -296,7 +296,7 @@ void PopupMenu::gui_input(const Ref<InputEvent> &p_event) { mouse_over = i; emit_signal(SNAME("id_focused"), i); scroll_to_item(i); - control->update(); + control->queue_redraw(); set_input_as_handled(); match_found = true; break; @@ -310,7 +310,7 @@ void PopupMenu::gui_input(const Ref<InputEvent> &p_event) { mouse_over = i; emit_signal(SNAME("id_focused"), i); scroll_to_item(i); - control->update(); + control->queue_redraw(); set_input_as_handled(); break; } @@ -328,7 +328,7 @@ void PopupMenu::gui_input(const Ref<InputEvent> &p_event) { mouse_over = i; emit_signal(SNAME("id_focused"), i); scroll_to_item(i); - control->update(); + control->queue_redraw(); set_input_as_handled(); match_found = true; break; @@ -342,7 +342,7 @@ void PopupMenu::gui_input(const Ref<InputEvent> &p_event) { mouse_over = i; emit_signal(SNAME("id_focused"), i); scroll_to_item(i); - control->update(); + control->queue_redraw(); set_input_as_handled(); break; } @@ -463,7 +463,7 @@ void PopupMenu::gui_input(const Ref<InputEvent> &p_event) { if (id < 0) { mouse_over = -1; - control->update(); + control->queue_redraw(); return; } @@ -474,7 +474,7 @@ void PopupMenu::gui_input(const Ref<InputEvent> &p_event) { if (over != mouse_over) { mouse_over = over; - control->update(); + control->queue_redraw(); } } @@ -511,7 +511,7 @@ void PopupMenu::gui_input(const Ref<InputEvent> &p_event) { mouse_over = i; emit_signal(SNAME("id_focused"), i); scroll_to_item(i); - control->update(); + control->queue_redraw(); set_input_as_handled(); break; } @@ -843,7 +843,7 @@ void PopupMenu::_notification(int p_what) { child_controls_changed(); _menu_changed(); - control->update(); + control->queue_redraw(); } break; case NOTIFICATION_WM_MOUSE_ENTER: { @@ -853,7 +853,7 @@ void PopupMenu::_notification(int p_what) { case NOTIFICATION_WM_MOUSE_EXIT: { if (mouse_over >= 0 && (items[mouse_over].submenu.is_empty() || submenu_over != -1)) { mouse_over = -1; - control->update(); + control->queue_redraw(); } } break; @@ -881,7 +881,7 @@ void PopupMenu::_notification(int p_what) { if (!is_visible()) { if (mouse_over >= 0) { mouse_over = -1; - control->update(); + control->queue_redraw(); } for (int i = 0; i < items.size(); i++) { @@ -934,7 +934,7 @@ void PopupMenu::add_item(const String &p_label, int p_id, Key p_accel) { ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel); items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); notify_property_list_changed(); _menu_changed(); @@ -946,7 +946,7 @@ void PopupMenu::add_icon_item(const Ref<Texture2D> &p_icon, const String &p_labe item.icon = p_icon; items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); notify_property_list_changed(); _menu_changed(); @@ -958,7 +958,7 @@ void PopupMenu::add_check_item(const String &p_label, int p_id, Key p_accel) { item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX; items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -970,7 +970,7 @@ void PopupMenu::add_icon_check_item(const Ref<Texture2D> &p_icon, const String & item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX; items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); } @@ -980,7 +980,7 @@ void PopupMenu::add_radio_check_item(const String &p_label, int p_id, Key p_acce item.checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON; items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -992,7 +992,7 @@ void PopupMenu::add_icon_radio_check_item(const Ref<Texture2D> &p_icon, const St item.checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON; items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1004,7 +1004,7 @@ void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int item.state = p_default_state; items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1023,7 +1023,7 @@ void PopupMenu::add_shortcut(const Ref<Shortcut> &p_shortcut, int p_id, bool p_g ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global); items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1034,7 +1034,7 @@ void PopupMenu::add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<Shortc item.icon = p_icon; items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1045,7 +1045,7 @@ void PopupMenu::add_check_shortcut(const Ref<Shortcut> &p_shortcut, int p_id, bo item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX; items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1057,7 +1057,7 @@ void PopupMenu::add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref< item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX; items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1068,7 +1068,7 @@ void PopupMenu::add_radio_check_shortcut(const Ref<Shortcut> &p_shortcut, int p_ item.checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON; items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1080,7 +1080,7 @@ void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, cons item.checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON; items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1093,7 +1093,7 @@ void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu, item.submenu = p_submenu; items.push_back(item); _shape_item(items.size() - 1); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1116,7 +1116,7 @@ void PopupMenu::set_item_text(int p_idx, const String &p_text) { items.write[p_idx].dirty = true; _shape_item(p_idx); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1130,7 +1130,7 @@ void PopupMenu::set_item_text_direction(int p_item, Control::TextDirection p_tex if (items[p_item].text_direction != p_text_direction) { items.write[p_item].text_direction = p_text_direction; items.write[p_item].dirty = true; - control->update(); + control->queue_redraw(); } } @@ -1142,7 +1142,7 @@ void PopupMenu::set_item_language(int p_item, const String &p_language) { if (items[p_item].language != p_language) { items.write[p_item].language = p_language; items.write[p_item].dirty = true; - control->update(); + control->queue_redraw(); } } @@ -1158,7 +1158,7 @@ void PopupMenu::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) { items.write[p_idx].icon = p_icon; - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1175,7 +1175,7 @@ void PopupMenu::set_item_checked(int p_idx, bool p_checked) { items.write[p_idx].checked = p_checked; - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1192,7 +1192,7 @@ void PopupMenu::set_item_id(int p_idx, int p_id) { items.write[p_idx].id = p_id; - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1210,7 +1210,7 @@ void PopupMenu::set_item_accelerator(int p_idx, Key p_accel) { items.write[p_idx].accel = p_accel; items.write[p_idx].dirty = true; - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1226,7 +1226,7 @@ void PopupMenu::set_item_metadata(int p_idx, const Variant &p_meta) { } items.write[p_idx].metadata = p_meta; - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1242,7 +1242,7 @@ void PopupMenu::set_item_disabled(int p_idx, bool p_disabled) { } items.write[p_idx].disabled = p_disabled; - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1258,7 +1258,7 @@ void PopupMenu::set_item_submenu(int p_idx, const String &p_submenu) { } items.write[p_idx].submenu = p_submenu; - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1266,7 +1266,7 @@ void PopupMenu::set_item_submenu(int p_idx, const String &p_submenu) { void PopupMenu::toggle_item_checked(int p_idx) { ERR_FAIL_INDEX(p_idx, items.size()); items.write[p_idx].checked = !items[p_idx].checked; - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1377,7 +1377,7 @@ void PopupMenu::set_item_as_separator(int p_idx, bool p_separator) { } items.write[p_idx].separator = p_separator; - control->update(); + control->queue_redraw(); } bool PopupMenu::is_item_separator(int p_idx) const { @@ -1397,7 +1397,7 @@ void PopupMenu::set_item_as_checkable(int p_idx, bool p_checkable) { } items.write[p_idx].checkable_type = p_checkable ? Item::CHECKABLE_TYPE_CHECK_BOX : Item::CHECKABLE_TYPE_NONE; - control->update(); + control->queue_redraw(); _menu_changed(); } @@ -1413,7 +1413,7 @@ void PopupMenu::set_item_as_radio_checkable(int p_idx, bool p_radio_checkable) { } items.write[p_idx].checkable_type = p_radio_checkable ? Item::CHECKABLE_TYPE_RADIO_BUTTON : Item::CHECKABLE_TYPE_NONE; - control->update(); + control->queue_redraw(); _menu_changed(); } @@ -1428,7 +1428,7 @@ void PopupMenu::set_item_tooltip(int p_idx, const String &p_tooltip) { } items.write[p_idx].tooltip = p_tooltip; - control->update(); + control->queue_redraw(); _menu_changed(); } @@ -1453,7 +1453,7 @@ void PopupMenu::set_item_shortcut(int p_idx, const Ref<Shortcut> &p_shortcut, bo _ref_shortcut(items[p_idx].shortcut); } - control->update(); + control->queue_redraw(); _menu_changed(); } @@ -1468,7 +1468,7 @@ void PopupMenu::set_item_indent(int p_idx, int p_indent) { } items.write[p_idx].indent = p_indent; - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1484,7 +1484,7 @@ void PopupMenu::set_item_multistate(int p_idx, int p_state) { } items.write[p_idx].state = p_state; - control->update(); + control->queue_redraw(); _menu_changed(); } @@ -1499,7 +1499,7 @@ void PopupMenu::set_item_shortcut_disabled(int p_idx, bool p_disabled) { } items.write[p_idx].shortcut_is_disabled = p_disabled; - control->update(); + control->queue_redraw(); _menu_changed(); } @@ -1514,7 +1514,7 @@ void PopupMenu::toggle_item_multistate(int p_idx) { items.write[p_idx].state = 0; } - control->update(); + control->queue_redraw(); _menu_changed(); } @@ -1552,7 +1552,7 @@ void PopupMenu::set_current_index(int p_idx) { scroll_to_item(mouse_over); } - control->update(); + control->queue_redraw(); } int PopupMenu::get_current_index() const { @@ -1575,7 +1575,7 @@ void PopupMenu::set_item_count(int p_count) { } } - control->update(); + control->queue_redraw(); child_controls_changed(); notify_property_list_changed(); _menu_changed(); @@ -1718,7 +1718,7 @@ void PopupMenu::remove_item(int p_idx) { } items.remove_at(p_idx); - control->update(); + control->queue_redraw(); child_controls_changed(); _menu_changed(); } @@ -1732,7 +1732,7 @@ void PopupMenu::add_separator(const String &p_text, int p_id) { sep.xl_text = atr(p_text); } items.push_back(sep); - control->update(); + control->queue_redraw(); _menu_changed(); } @@ -1744,7 +1744,7 @@ void PopupMenu::clear() { } items.clear(); mouse_over = -1; - control->update(); + control->queue_redraw(); child_controls_changed(); notify_property_list_changed(); _menu_changed(); @@ -1753,7 +1753,7 @@ void PopupMenu::clear() { void PopupMenu::_ref_shortcut(Ref<Shortcut> p_sc) { if (!shortcut_refcount.has(p_sc)) { shortcut_refcount[p_sc] = 1; - p_sc->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); + p_sc->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); } else { shortcut_refcount[p_sc] += 1; } @@ -1763,7 +1763,7 @@ void PopupMenu::_unref_shortcut(Ref<Shortcut> p_sc) { ERR_FAIL_COND(!shortcut_refcount.has(p_sc)); shortcut_refcount[p_sc]--; if (shortcut_refcount[p_sc] == 0) { - p_sc->disconnect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); + p_sc->disconnect("changed", callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); shortcut_refcount.erase(p_sc); } } diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp index 80859e8eb9..63a2db4569 100644 --- a/scene/gui/progress_bar.cpp +++ b/scene/gui/progress_bar.cpp @@ -118,7 +118,7 @@ void ProgressBar::_notification(int p_what) { void ProgressBar::set_fill_mode(int p_fill) { ERR_FAIL_INDEX(p_fill, FILL_MODE_MAX); mode = (FillMode)p_fill; - update(); + queue_redraw(); } int ProgressBar::get_fill_mode() { @@ -131,7 +131,7 @@ void ProgressBar::set_percent_visible(bool p_visible) { } percent_visible = p_visible; update_minimum_size(); - update(); + queue_redraw(); } bool ProgressBar::is_percent_visible() const { diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index 0fb1f27802..1eb412abaf 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -46,7 +46,7 @@ void Range::_value_changed(double p_value) { void Range::_value_changed_notify() { _value_changed(shared->val); emit_signal(SNAME("value_changed"), shared->val); - update(); + queue_redraw(); } void Range::Shared::emit_value_changed() { @@ -61,7 +61,7 @@ void Range::Shared::emit_value_changed() { void Range::_changed_notify(const char *p_what) { emit_signal(SNAME("changed")); - update(); + queue_redraw(); } void Range::_validate_values() { diff --git a/scene/gui/reference_rect.cpp b/scene/gui/reference_rect.cpp index 05dfe4b118..fa5ac5b864 100644 --- a/scene/gui/reference_rect.cpp +++ b/scene/gui/reference_rect.cpp @@ -51,7 +51,7 @@ void ReferenceRect::set_border_color(const Color &p_color) { } border_color = p_color; - update(); + queue_redraw(); } Color ReferenceRect::get_border_color() const { @@ -65,7 +65,7 @@ void ReferenceRect::set_border_width(float p_width) { } border_width = width_max; - update(); + queue_redraw(); } float ReferenceRect::get_border_width() const { @@ -78,7 +78,7 @@ void ReferenceRect::set_editor_only(const bool &p_enabled) { } editor_only = p_enabled; - update(); + queue_redraw(); } bool ReferenceRect::get_editor_only() const { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 8ce8663091..c9a903153d 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1621,7 +1621,7 @@ void RichTextLabel::_scroll_changed(double) { scroll_updated = true; - update(); + queue_redraw(); } void RichTextLabel::_update_fx(RichTextLabel::ItemFrame *p_frame, double p_delta_time) { @@ -1685,20 +1685,20 @@ void RichTextLabel::_notification(int p_what) { meta_hovering = nullptr; emit_signal(SNAME("meta_hover_ended"), current_meta); current_meta = false; - update(); + queue_redraw(); } } break; case NOTIFICATION_RESIZED: { _stop_thread(); main->first_resized_line.store(0); //invalidate ALL - update(); + queue_redraw(); } break; case NOTIFICATION_THEME_CHANGED: { _stop_thread(); main->first_invalid_font_line.store(0); //invalidate ALL - update(); + queue_redraw(); } break; case NOTIFICATION_ENTER_TREE: { @@ -1708,7 +1708,7 @@ void RichTextLabel::_notification(int p_what) { } main->first_invalid_line.store(0); //invalidate ALL - update(); + queue_redraw(); } break; case NOTIFICATION_PREDELETE: @@ -1720,11 +1720,11 @@ void RichTextLabel::_notification(int p_what) { case NOTIFICATION_TRANSLATION_CHANGED: { _stop_thread(); main->first_invalid_line.store(0); //invalidate ALL - update(); + queue_redraw(); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { - update(); + queue_redraw(); } break; case NOTIFICATION_DRAW: { @@ -1806,7 +1806,7 @@ void RichTextLabel::_notification(int p_what) { } double dt = get_process_delta_time(); _update_fx(main, dt); - update(); + queue_redraw(); } } break; @@ -1918,7 +1918,7 @@ void RichTextLabel::gui_input(const Ref<InputEvent> &p_event) { if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_CLIPBOARD_PRIMARY)) { DisplayServer::get_singleton()->clipboard_set_primary(get_selected_text()); } - update(); + queue_redraw(); break; } } @@ -2084,7 +2084,7 @@ void RichTextLabel::gui_input(const Ref<InputEvent> &p_event) { } selection.active = true; - update(); + queue_redraw(); } Variant meta; @@ -2541,7 +2541,7 @@ void RichTextLabel::_thread_function(void *self) { RichTextLabel *rtl = reinterpret_cast<RichTextLabel *>(self); rtl->_process_line_caches(); rtl->updating.store(false); - rtl->call_deferred(SNAME("update")); + rtl->call_deferred(SNAME("queue_redraw")); } void RichTextLabel::_stop_thread() { @@ -2562,7 +2562,7 @@ void RichTextLabel::set_threaded(bool p_threaded) { if (threaded != p_threaded) { _stop_thread(); threaded = p_threaded; - update(); + queue_redraw(); } } @@ -2661,7 +2661,7 @@ bool RichTextLabel::_validate_line_caches() { return false; } else { _process_line_caches(); - update(); + queue_redraw(); return true; } } @@ -2799,7 +2799,7 @@ void RichTextLabel::add_text(const String &p_text) { pos = end + 1; } - update(); + queue_redraw(); } void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline) { @@ -2837,7 +2837,7 @@ void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline) if (fixed_width != -1) { update_minimum_size(); } - update(); + queue_redraw(); } void RichTextLabel::_remove_item(Item *p_item, const int p_line, const int p_subitem_line) { @@ -2918,7 +2918,7 @@ void RichTextLabel::add_newline() { _add_item(item, false); current_frame->lines.resize(current_frame->lines.size() + 1); _invalidate_current_line(current_frame); - update(); + queue_redraw(); } bool RichTextLabel::remove_line(const int p_line) { @@ -2957,7 +2957,7 @@ bool RichTextLabel::remove_line(const int p_line) { } main->first_invalid_line.store(0); - update(); + queue_redraw(); return true; } @@ -3386,7 +3386,7 @@ void RichTextLabel::set_tab_size(int p_spaces) { tab_size = p_spaces; main->first_resized_line.store(0); - update(); + queue_redraw(); } int RichTextLabel::get_tab_size() const { @@ -3410,7 +3410,7 @@ void RichTextLabel::set_meta_underline(bool p_underline) { } underline_meta = p_underline; - update(); + queue_redraw(); } bool RichTextLabel::is_meta_underlined() const { @@ -3419,7 +3419,7 @@ bool RichTextLabel::is_meta_underlined() const { void RichTextLabel::set_hint_underline(bool p_underline) { underline_hint = p_underline; - update(); + queue_redraw(); } bool RichTextLabel::is_hint_underlined() const { @@ -3445,7 +3445,7 @@ void RichTextLabel::set_scroll_active(bool p_active) { scroll_active = p_active; vscroll->set_drag_node_enabled(p_active); - update(); + queue_redraw(); } bool RichTextLabel::is_scroll_active() const { @@ -4570,7 +4570,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p if (!(p_search_previous && char_idx < 0) && _search_line(selection.from_frame, selection.from_line, p_string, char_idx, p_search_previous)) { scroll_to_line(selection.from_frame->line + selection.from_line); - update(); + queue_redraw(); return true; } char_idx = p_search_previous ? -1 : 0; @@ -4595,7 +4595,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p // Search for next element if (_search_table(parent_table, parent_element, p_string, p_search_previous)) { scroll_to_line(selection.from_frame->line + selection.from_line); - update(); + queue_redraw(); return true; } } @@ -4619,7 +4619,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p if (_search_line(main, current_line, p_string, char_idx, p_search_previous)) { scroll_to_line(current_line); - update(); + queue_redraw(); return true; } p_search_previous ? current_line-- : current_line++; @@ -4729,7 +4729,7 @@ String RichTextLabel::get_selected_text() const { void RichTextLabel::deselect() { selection.active = false; - update(); + queue_redraw(); } void RichTextLabel::selection_copy() { @@ -4784,7 +4784,7 @@ void RichTextLabel::select_all() { selection.to_char = to_frame->lines[to_line].char_count; selection.to_item = to_item; selection.active = true; - update(); + queue_redraw(); } bool RichTextLabel::is_selection_enabled() const { @@ -4872,7 +4872,7 @@ void RichTextLabel::set_text_direction(Control::TextDirection p_text_direction) text_direction = p_text_direction; main->first_invalid_line.store(0); //invalidate ALL _validate_line_caches(); - update(); + queue_redraw(); } } @@ -4883,7 +4883,7 @@ void RichTextLabel::set_structured_text_bidi_override(TextServer::StructuredText st_parser = p_parser; main->first_invalid_line.store(0); //invalidate ALL _validate_line_caches(); - update(); + queue_redraw(); } } @@ -4898,7 +4898,7 @@ void RichTextLabel::set_structured_text_bidi_override_options(Array p_args) { st_args = p_args; main->first_invalid_line.store(0); //invalidate ALL _validate_line_caches(); - update(); + queue_redraw(); } } @@ -4917,7 +4917,7 @@ void RichTextLabel::set_language(const String &p_language) { language = p_language; main->first_invalid_line.store(0); //invalidate ALL _validate_line_caches(); - update(); + queue_redraw(); } } @@ -4932,7 +4932,7 @@ void RichTextLabel::set_autowrap_mode(TextServer::AutowrapMode p_mode) { autowrap_mode = p_mode; main->first_invalid_line = 0; //invalidate ALL _validate_line_caches(); - update(); + queue_redraw(); } } @@ -4959,7 +4959,7 @@ void RichTextLabel::set_visible_ratio(float p_ratio) { main->first_invalid_line.store(0); // Invalidate ALL. _validate_line_caches(); } - update(); + queue_redraw(); } } @@ -5259,7 +5259,7 @@ void RichTextLabel::set_visible_characters_behavior(TextServer::VisibleCharacter visible_chars_behavior = p_behavior; main->first_invalid_line.store(0); //invalidate ALL _validate_line_caches(); - update(); + queue_redraw(); } } @@ -5280,7 +5280,7 @@ void RichTextLabel::set_visible_characters(int p_visible) { main->first_invalid_line.store(0); //invalidate ALL _validate_line_caches(); } - update(); + queue_redraw(); } } diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 48c57d9b1b..2555318f39 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -82,14 +82,14 @@ void ScrollBar::gui_input(const Ref<InputEvent> &p_event) { if (ofs < decr_size) { decr_active = true; set_value(get_value() - (custom_step >= 0 ? custom_step : get_step())); - update(); + queue_redraw(); return; } if (ofs > total - incr_size) { incr_active = true; set_value(get_value() + (custom_step >= 0 ? custom_step : get_step())); - update(); + queue_redraw(); return; } @@ -117,7 +117,7 @@ void ScrollBar::gui_input(const Ref<InputEvent> &p_event) { drag.active = true; drag.pos_at_click = grabber_ofs + ofs; drag.value_at_click = get_as_ratio(); - update(); + queue_redraw(); } else { if (scrolling) { target_scroll = CLAMP(target_scroll + get_page(), get_min(), get_max() - get_page()); @@ -137,7 +137,7 @@ void ScrollBar::gui_input(const Ref<InputEvent> &p_event) { incr_active = false; decr_active = false; drag.active = false; - update(); + queue_redraw(); } } @@ -177,7 +177,7 @@ void ScrollBar::gui_input(const Ref<InputEvent> &p_event) { if (new_hilite != highlight) { highlight = new_hilite; - update(); + queue_redraw(); } } } @@ -408,7 +408,7 @@ void ScrollBar::_notification(int p_what) { case NOTIFICATION_MOUSE_EXIT: { highlight = HIGHLIGHT_NONE; - update(); + queue_redraw(); } break; } } diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 8fd547813d..cd595446bb 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -312,7 +312,7 @@ void ScrollContainer::_reposition_children() { fit_child_in_rect(c, r); } - update(); + queue_redraw(); } void ScrollContainer::_notification(int p_what) { diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index 2695ad1f14..7bf61e3541 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -149,17 +149,17 @@ void Slider::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { update_minimum_size(); - update(); + queue_redraw(); } break; case NOTIFICATION_MOUSE_ENTER: { mouse_inside = true; - update(); + queue_redraw(); } break; case NOTIFICATION_MOUSE_EXIT: { mouse_inside = false; - update(); + queue_redraw(); } break; case NOTIFICATION_VISIBILITY_CHANGED: @@ -232,7 +232,7 @@ void Slider::set_ticks(int p_count) { } ticks = p_count; - update(); + queue_redraw(); } int Slider::get_ticks() const { @@ -249,7 +249,7 @@ void Slider::set_ticks_on_borders(bool _tob) { } ticks_on_borders = _tob; - update(); + queue_redraw(); } void Slider::set_editable(bool p_editable) { @@ -258,7 +258,7 @@ void Slider::set_editable(bool p_editable) { } editable = p_editable; - update(); + queue_redraw(); } bool Slider::is_editable() const { diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 65c4a09c84..900249ddd9 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -238,7 +238,7 @@ void SpinBox::_notification(int p_what) { case NOTIFICATION_TRANSLATION_CHANGED: { _value_changed(0); - update(); + queue_redraw(); } break; case NOTIFICATION_THEME_CHANGED: { @@ -247,7 +247,7 @@ void SpinBox::_notification(int p_what) { } break; case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { - update(); + queue_redraw(); } break; } } diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 3e60db0846..b7e1f2a914 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -124,7 +124,7 @@ void SplitContainer::_resort() { } } - update(); + queue_redraw(); } Size2 SplitContainer::get_minimum_size() const { @@ -176,7 +176,7 @@ void SplitContainer::_notification(int p_what) { case NOTIFICATION_MOUSE_EXIT: { mouse_inside = false; if (get_theme_constant(SNAME("autohide"))) { - update(); + queue_redraw(); } } break; @@ -256,7 +256,7 @@ void SplitContainer::gui_input(const Ref<InputEvent> &p_event) { if (mouse_inside != mouse_inside_state) { mouse_inside = mouse_inside_state; if (get_theme_constant(SNAME("autohide"))) { - update(); + queue_redraw(); } } @@ -333,7 +333,7 @@ void SplitContainer::set_dragger_visibility(DraggerVisibility p_visibility) { dragger_visibility = p_visibility; queue_sort(); - update(); + queue_redraw(); } SplitContainer::DraggerVisibility SplitContainer::get_dragger_visibility() const { diff --git a/scene/gui/subviewport_container.cpp b/scene/gui/subviewport_container.cpp index 869683e427..88e68ec763 100644 --- a/scene/gui/subviewport_container.cpp +++ b/scene/gui/subviewport_container.cpp @@ -60,7 +60,7 @@ void SubViewportContainer::set_stretch(bool p_enable) { stretch = p_enable; update_minimum_size(); queue_sort(); - update(); + queue_redraw(); } bool SubViewportContainer::is_stretch_enabled() const { @@ -88,7 +88,7 @@ void SubViewportContainer::set_stretch_shrink(int p_shrink) { c->set_size(get_size() / shrink); } - update(); + queue_redraw(); } int SubViewportContainer::get_stretch_shrink() const { diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp index e0739f909f..61cf8e8a86 100644 --- a/scene/gui/tab_bar.cpp +++ b/scene/gui/tab_bar.cpp @@ -129,39 +129,39 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { if (pos.x < decr->get_width()) { if (highlight_arrow != 1) { highlight_arrow = 1; - update(); + queue_redraw(); } } else if (pos.x < incr->get_width() + decr->get_width()) { if (highlight_arrow != 0) { highlight_arrow = 0; - update(); + queue_redraw(); } } else if (highlight_arrow != -1) { highlight_arrow = -1; - update(); + queue_redraw(); } } else { int limit_minus_buttons = get_size().width - incr->get_width() - decr->get_width(); if (pos.x > limit_minus_buttons + decr->get_width()) { if (highlight_arrow != 1) { highlight_arrow = 1; - update(); + queue_redraw(); } } else if (pos.x > limit_minus_buttons) { if (highlight_arrow != 0) { highlight_arrow = 0; - update(); + queue_redraw(); } } else if (highlight_arrow != -1) { highlight_arrow = -1; - update(); + queue_redraw(); } } } if (get_viewport()->gui_is_dragging() && can_drop_data(pos, get_viewport()->gui_get_drag_data())) { dragging_valid_tab = true; - update(); + queue_redraw(); } _update_hover(); @@ -177,7 +177,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { if (offset > 0) { offset--; _update_cache(); - update(); + queue_redraw(); } } } @@ -187,7 +187,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { if (missing_right && offset < tabs.size()) { offset++; _update_cache(); - update(); + queue_redraw(); } } } @@ -198,7 +198,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { } rb_pressing = false; - update(); + queue_redraw(); } if (cb_pressing && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { @@ -207,7 +207,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { } cb_pressing = false; - update(); + queue_redraw(); } if (mb->is_pressed() && (mb->get_button_index() == MouseButton::LEFT || (select_with_rmb && mb->get_button_index() == MouseButton::RIGHT))) { @@ -222,14 +222,14 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { if (missing_right) { offset++; _update_cache(); - update(); + queue_redraw(); } return; } else if (pos.x < incr->get_width() + decr->get_width()) { if (offset > 0) { offset--; _update_cache(); - update(); + queue_redraw(); } return; } @@ -239,14 +239,14 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { if (missing_right) { offset++; _update_cache(); - update(); + queue_redraw(); } return; } else if (pos.x > limit) { if (offset > 0) { offset--; _update_cache(); - update(); + queue_redraw(); } return; } @@ -266,13 +266,13 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { if (tabs[i].rb_rect.has_point(pos)) { rb_pressing = true; - update(); + queue_redraw(); return; } if (tabs[i].cb_rect.has_point(pos) && (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current))) { cb_pressing = true; - update(); + queue_redraw(); return; } @@ -317,7 +317,7 @@ void TabBar::_shape(int p_tab) { void TabBar::_notification(int p_what) { switch (p_what) { case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { - update(); + queue_redraw(); } break; case NOTIFICATION_THEME_CHANGED: @@ -343,7 +343,7 @@ void TabBar::_notification(int p_what) { case NOTIFICATION_DRAG_END: { if (dragging_valid_tab) { dragging_valid_tab = false; - update(); + queue_redraw(); } } break; @@ -581,7 +581,7 @@ void TabBar::set_tab_count(int p_count) { } } - update(); + queue_redraw(); update_minimum_size(); notify_property_list_changed(); } @@ -607,7 +607,7 @@ void TabBar::set_current_tab(int p_current) { if (scroll_to_selected) { ensure_tab_visible(current); } - update(); + queue_redraw(); emit_signal(SNAME("tab_changed"), p_current); } @@ -647,7 +647,7 @@ void TabBar::set_tab_title(int p_tab, const String &p_title) { if (scroll_to_selected) { ensure_tab_visible(current); } - update(); + queue_redraw(); update_minimum_size(); } @@ -663,7 +663,7 @@ void TabBar::set_tab_text_direction(int p_tab, Control::TextDirection p_text_dir if (tabs[p_tab].text_direction != p_text_direction) { tabs.write[p_tab].text_direction = p_text_direction; _shape(p_tab); - update(); + queue_redraw(); } } @@ -683,7 +683,7 @@ void TabBar::set_tab_language(int p_tab, const String &p_language) { if (scroll_to_selected) { ensure_tab_visible(current); } - update(); + queue_redraw(); update_minimum_size(); } } @@ -707,7 +707,7 @@ void TabBar::set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon) { if (scroll_to_selected) { ensure_tab_visible(current); } - update(); + queue_redraw(); update_minimum_size(); } @@ -730,7 +730,7 @@ void TabBar::set_tab_disabled(int p_tab, bool p_disabled) { if (scroll_to_selected) { ensure_tab_visible(current); } - update(); + queue_redraw(); update_minimum_size(); } @@ -753,7 +753,7 @@ void TabBar::set_tab_hidden(int p_tab, bool p_hidden) { if (scroll_to_selected) { ensure_tab_visible(current); } - update(); + queue_redraw(); update_minimum_size(); } @@ -776,7 +776,7 @@ void TabBar::set_tab_button_icon(int p_tab, const Ref<Texture2D> &p_icon) { if (scroll_to_selected) { ensure_tab_visible(current); } - update(); + queue_redraw(); update_minimum_size(); } @@ -817,7 +817,7 @@ void TabBar::_update_hover() { } if (hover_buttons != -1) { - update(); + queue_redraw(); break; } } @@ -838,7 +838,7 @@ void TabBar::_update_hover() { cb_hover = hover_buttons; if (rb_hover != rb_hover_old || cb_hover != cb_hover_old) { - update(); + queue_redraw(); } } } @@ -940,7 +940,7 @@ void TabBar::_on_mouse_exited() { highlight_arrow = -1; dragging_valid_tab = false; - update(); + queue_redraw(); } void TabBar::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) { @@ -955,7 +955,7 @@ void TabBar::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) { if (scroll_to_selected) { ensure_tab_visible(current); } - update(); + queue_redraw(); update_minimum_size(); if (tabs.size() == 1 && is_inside_tree()) { @@ -974,7 +974,7 @@ void TabBar::clear_tabs() { current = 0; previous = 0; - update(); + queue_redraw(); update_minimum_size(); notify_property_list_changed(); } @@ -1004,7 +1004,7 @@ void TabBar::remove_tab(int p_idx) { } } - update(); + queue_redraw(); update_minimum_size(); notify_property_list_changed(); @@ -1152,7 +1152,7 @@ void TabBar::drop_data(const Point2 &p_point, const Variant &p_data) { set_current_tab(hover_now); } else { _update_cache(); - update(); + queue_redraw(); } update_minimum_size(); @@ -1188,7 +1188,7 @@ void TabBar::set_tab_alignment(AlignmentMode p_alignment) { tab_alignment = p_alignment; _update_cache(); - update(); + queue_redraw(); } TabBar::AlignmentMode TabBar::get_tab_alignment() const { @@ -1210,7 +1210,7 @@ void TabBar::set_clip_tabs(bool p_clip_tabs) { if (scroll_to_selected) { ensure_tab_visible(current); } - update(); + queue_redraw(); update_minimum_size(); } @@ -1251,7 +1251,7 @@ void TabBar::move_tab(int p_from, int p_to) { if (scroll_to_selected) { ensure_tab_visible(current); } - update(); + queue_redraw(); notify_property_list_changed(); } @@ -1337,7 +1337,7 @@ void TabBar::_ensure_no_over_offset() { if (prev_offset != offset) { _update_cache(); - update(); + queue_redraw(); } } @@ -1354,7 +1354,7 @@ void TabBar::ensure_tab_visible(int p_idx) { if (p_idx < offset) { offset = p_idx; _update_cache(); - update(); + queue_redraw(); return; } @@ -1389,7 +1389,7 @@ void TabBar::ensure_tab_visible(int p_idx) { if (prev_offset != offset) { _update_cache(); - update(); + queue_redraw(); } } @@ -1416,7 +1416,7 @@ void TabBar::set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy) { if (scroll_to_selected) { ensure_tab_visible(current); } - update(); + queue_redraw(); update_minimum_size(); } @@ -1438,7 +1438,7 @@ void TabBar::set_max_tab_width(int p_width) { if (scroll_to_selected) { ensure_tab_visible(current); } - update(); + queue_redraw(); update_minimum_size(); } diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 10a6d18330..3e04ebee6a 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -98,7 +98,7 @@ void TabContainer::gui_input(const Ref<InputEvent> &p_event) { if (pos.y > _get_top_margin()) { if (menu_hovered) { menu_hovered = false; - update(); + queue_redraw(); } return; } @@ -109,23 +109,23 @@ void TabContainer::gui_input(const Ref<InputEvent> &p_event) { if (pos.x <= menu->get_width()) { if (!menu_hovered) { menu_hovered = true; - update(); + queue_redraw(); return; } } else if (menu_hovered) { menu_hovered = false; - update(); + queue_redraw(); } } else { if (pos.x >= size.width - menu->get_width()) { if (!menu_hovered) { menu_hovered = true; - update(); + queue_redraw(); return; } } else if (menu_hovered) { menu_hovered = false; - update(); + queue_redraw(); } } @@ -163,6 +163,10 @@ void TabContainer::_notification(int p_what) { int header_height = _get_top_margin(); + // Draw background for the tabbar. + Ref<StyleBox> tabbar_background = get_theme_stylebox(SNAME("tabbar_background")); + tabbar_background->draw(canvas, Rect2(0, 0, size.width, header_height)); + // Draw the background for the tab's content. panel->draw(canvas, Rect2(0, header_height, size.width, size.height - header_height)); // Draw the popup menu. @@ -218,7 +222,7 @@ void TabContainer::_on_theme_changed() { } else { update_minimum_size(); } - update(); + queue_redraw(); theme_changing = false; } @@ -304,7 +308,7 @@ void TabContainer::_update_margins() { void TabContainer::_on_mouse_exited() { if (menu_hovered) { menu_hovered = false; - update(); + queue_redraw(); } } @@ -502,7 +506,7 @@ void TabContainer::add_child_notify(Node *p_child) { _update_margins(); if (get_tab_count() == 1) { - update(); + queue_redraw(); } p_child->connect("renamed", callable_mp(this, &TabContainer::_refresh_tab_names)); @@ -558,7 +562,7 @@ void TabContainer::remove_child_notify(Node *p_child) { _update_margins(); if (get_tab_count() == 0) { - update(); + queue_redraw(); } p_child->remove_meta("_tab_name"); @@ -656,7 +660,7 @@ void TabContainer::set_tabs_visible(bool p_visible) { } } - update(); + queue_redraw(); update_minimum_size(); } @@ -838,7 +842,7 @@ void TabContainer::set_popup(Node *p_popup) { popup_obj_id = popup_id; if (had_popup != bool(popup)) { - update(); + queue_redraw(); _update_margins(); if (!get_clip_tabs()) { update_minimum_size(); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 097eb1fd95..95338c7b8c 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -452,13 +452,13 @@ void TextEdit::_notification(int p_what) { case NOTIFICATION_WM_WINDOW_FOCUS_IN: { window_has_focus = true; draw_caret = true; - update(); + queue_redraw(); } break; case NOTIFICATION_WM_WINDOW_FOCUS_OUT: { window_has_focus = false; draw_caret = false; - update(); + queue_redraw(); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { @@ -1507,7 +1507,7 @@ void TextEdit::_notification(int p_what) { } text.invalidate_cache(caret.line, caret.column, true, t, structured_text_parser(st_parser, st_args, t)); - update(); + queue_redraw(); } } break; @@ -1696,7 +1696,7 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) { } selection.selecting_line = prev_line; selection.selecting_column = prev_col; - update(); + queue_redraw(); } else { if (caret.line < selection.selecting_line || (caret.line == selection.selecting_line && caret.column < selection.selecting_column)) { if (selection.shiftclick_left) { @@ -1718,7 +1718,7 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) { selection.active = false; } - update(); + queue_redraw(); } } else if (drag_and_drop_selection_enabled && is_mouse_over_selection()) { selection.selecting_mode = SelectionMode::SELECTION_MODE_NONE; @@ -1746,7 +1746,7 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) { last_dblclk = OS::get_singleton()->get_ticks_msec(); last_dblclk_pos = mb->get_position(); } - update(); + queue_redraw(); } if (is_middle_mouse_paste_enabled() && mb->get_button_index() == MouseButton::MIDDLE && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_CLIPBOARD_PRIMARY)) { @@ -1880,7 +1880,7 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) { if (current_hovered_gutter != hovered_gutter) { hovered_gutter = current_hovered_gutter; - update(); + queue_redraw(); } if (drag_action && can_drop_data(mpos, get_viewport()->gui_get_drag_data())) { @@ -2146,7 +2146,7 @@ void TextEdit::_swap_current_input_direction() { input_direction = TEXT_DIRECTION_LTR; } set_caret_column(caret.column); - update(); + queue_redraw(); } void TextEdit::_new_line(bool p_split_current_line, bool p_above) { @@ -2527,7 +2527,7 @@ void TextEdit::_delete(bool p_word, bool p_all_to_right) { } _remove_text(caret.line, caret.column, next_line, next_column); - update(); + queue_redraw(); } void TextEdit::_move_caret_document_start(bool p_select) { @@ -2816,7 +2816,7 @@ void TextEdit::set_editable(const bool p_editable) { editable = p_editable; - update(); + queue_redraw(); } bool TextEdit::is_editable() const { @@ -2846,7 +2846,7 @@ void TextEdit::set_text_direction(Control::TextDirection p_text_direction) { menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_LTR), text_direction == TEXT_DIRECTION_LTR); menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_RTL), text_direction == TEXT_DIRECTION_RTL); } - update(); + queue_redraw(); } } @@ -2866,7 +2866,7 @@ void TextEdit::set_language(const String &p_language) { text.set_direction_and_language(dir, (!language.is_empty()) ? language : TranslationServer::get_singleton()->get_tool_locale()); text.invalidate_all(); _update_placeholder(); - update(); + queue_redraw(); } } @@ -2880,7 +2880,7 @@ void TextEdit::set_structured_text_bidi_override(TextServer::StructuredTextParse for (int i = 0; i < text.size(); i++) { text.set(i, text[i], structured_text_parser(st_parser, st_args, text[i])); } - update(); + queue_redraw(); } } @@ -2897,7 +2897,7 @@ void TextEdit::set_structured_text_bidi_override_options(Array p_args) { for (int i = 0; i < text.size(); i++) { text.set(i, text[i], structured_text_parser(st_parser, st_args, text[i])); } - update(); + queue_redraw(); } Array TextEdit::get_structured_text_bidi_override_options() const { @@ -2912,7 +2912,7 @@ void TextEdit::set_tab_size(const int p_size) { text.set_tab_size(p_size); text.invalidate_all_lines(); _update_placeholder(); - update(); + queue_redraw(); } int TextEdit::get_tab_size() const { @@ -2926,7 +2926,7 @@ void TextEdit::set_overtype_mode_enabled(const bool p_enabled) { } overtype_mode = p_enabled; - update(); + queue_redraw(); } bool TextEdit::is_overtype_mode_enabled() const { @@ -3022,7 +3022,7 @@ void TextEdit::set_text(const String &p_text) { set_caret_line(0); set_caret_column(0); - update(); + queue_redraw(); setting_text = false; emit_signal(SNAME("text_set")); } @@ -3050,7 +3050,7 @@ void TextEdit::set_placeholder(const String &p_text) { placeholder_text = p_text; _update_placeholder(); - update(); + queue_redraw(); } String TextEdit::get_placeholder() const { @@ -3149,7 +3149,7 @@ void TextEdit::insert_line_at(int p_at, const String &p_text) { ++selection.to_line; } } - update(); + queue_redraw(); } void TextEdit::insert_text_at_caret(const String &p_text) { @@ -3166,7 +3166,7 @@ void TextEdit::insert_text_at_caret(const String &p_text) { set_caret_line(new_line, false); set_caret_column(new_column); - update(); + queue_redraw(); if (had_selection) { end_complex_operation(); @@ -3557,7 +3557,7 @@ void TextEdit::undo() { set_caret_line(undo_stack_pos->get().from_line, false); set_caret_column(undo_stack_pos->get().from_column); } - update(); + queue_redraw(); } void TextEdit::redo() { @@ -3592,7 +3592,7 @@ void TextEdit::redo() { set_caret_line(undo_stack_pos->get().to_line, false); set_caret_column(undo_stack_pos->get().to_column); undo_stack_pos = undo_stack_pos->next(); - update(); + queue_redraw(); } void TextEdit::clear_undo_history() { @@ -3962,7 +3962,7 @@ void TextEdit::set_caret_type(CaretType p_type) { } caret_type = p_type; - update(); + queue_redraw(); } TextEdit::CaretType TextEdit::get_caret_type() const { @@ -4217,7 +4217,7 @@ void TextEdit::select_all() { selection.shiftclick_left = true; set_caret_line(selection.to_line, false); set_caret_column(selection.to_column, false); - update(); + queue_redraw(); } void TextEdit::select_word_under_caret() { @@ -4312,7 +4312,7 @@ void TextEdit::select(int p_from_line, int p_from_column, int p_to_line, int p_t selection.shiftclick_left = true; } - update(); + queue_redraw(); } bool TextEdit::has_selection() const { @@ -4359,7 +4359,7 @@ int TextEdit::get_selection_to_column() const { void TextEdit::deselect() { selection.active = false; - update(); + queue_redraw(); } void TextEdit::delete_selection() { @@ -4372,7 +4372,7 @@ void TextEdit::delete_selection() { _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column); set_caret_line(selection.from_line, false, false); set_caret_column(selection.from_column); - update(); + queue_redraw(); } /* Line wrapping. */ @@ -4464,7 +4464,7 @@ void TextEdit::set_scroll_past_end_of_file_enabled(const bool p_enabled) { } scroll_past_end_of_file_enabled = p_enabled; - update(); + queue_redraw(); } bool TextEdit::is_scroll_past_end_of_file_enabled() const { @@ -4688,7 +4688,7 @@ void TextEdit::adjust_viewport_to_caret() { } h_scroll->set_value(caret.x_ofs); - update(); + queue_redraw(); } void TextEdit::center_viewport_to_caret() { @@ -4741,7 +4741,7 @@ void TextEdit::center_viewport_to_caret() { } h_scroll->set_value(caret.x_ofs); - update(); + queue_redraw(); } /* Minimap */ @@ -4752,7 +4752,7 @@ void TextEdit::set_draw_minimap(bool p_enabled) { draw_minimap = p_enabled; _update_wrap_at_column(); - update(); + queue_redraw(); } bool TextEdit::is_drawing_minimap() const { @@ -4766,7 +4766,7 @@ void TextEdit::set_minimap_width(int p_minimap_width) { minimap_width = p_minimap_width; _update_wrap_at_column(); - update(); + queue_redraw(); } int TextEdit::get_minimap_width() const { @@ -4787,7 +4787,7 @@ void TextEdit::add_gutter(int p_at) { text.add_gutter(p_at); emit_signal(SNAME("gutter_added")); - update(); + queue_redraw(); } void TextEdit::remove_gutter(int p_gutter) { @@ -4797,7 +4797,7 @@ void TextEdit::remove_gutter(int p_gutter) { text.remove_gutter(p_gutter); emit_signal(SNAME("gutter_removed")); - update(); + queue_redraw(); } int TextEdit::get_gutter_count() const { @@ -4822,7 +4822,7 @@ void TextEdit::set_gutter_type(int p_gutter, GutterType p_type) { } gutters.write[p_gutter].type = p_type; - update(); + queue_redraw(); } TextEdit::GutterType TextEdit::get_gutter_type(int p_gutter) const { @@ -4870,7 +4870,7 @@ void TextEdit::set_gutter_clickable(int p_gutter, bool p_clickable) { } gutters.write[p_gutter].clickable = p_clickable; - update(); + queue_redraw(); } bool TextEdit::is_gutter_clickable(int p_gutter) const { @@ -4918,7 +4918,7 @@ void TextEdit::merge_gutters(int p_from_line, int p_to_line) { text.set_line_gutter_clickable(p_to_line, i, true); } } - update(); + queue_redraw(); } void TextEdit::set_gutter_custom_draw(int p_gutter, const Callable &p_draw_callback) { @@ -4929,7 +4929,7 @@ void TextEdit::set_gutter_custom_draw(int p_gutter, const Callable &p_draw_callb } gutters.write[p_gutter].custom_draw_callback = p_draw_callback; - update(); + queue_redraw(); } // Line gutters. @@ -4954,7 +4954,7 @@ void TextEdit::set_line_gutter_text(int p_line, int p_gutter, const String &p_te } text.set_line_gutter_text(p_line, p_gutter, p_text); - update(); + queue_redraw(); } String TextEdit::get_line_gutter_text(int p_line, int p_gutter) const { @@ -4972,7 +4972,7 @@ void TextEdit::set_line_gutter_icon(int p_line, int p_gutter, const Ref<Texture2 } text.set_line_gutter_icon(p_line, p_gutter, p_icon); - update(); + queue_redraw(); } Ref<Texture2D> TextEdit::get_line_gutter_icon(int p_line, int p_gutter) const { @@ -4990,7 +4990,7 @@ void TextEdit::set_line_gutter_item_color(int p_line, int p_gutter, const Color } text.set_line_gutter_item_color(p_line, p_gutter, p_color); - update(); + queue_redraw(); } Color TextEdit::get_line_gutter_item_color(int p_line, int p_gutter) const { @@ -5020,7 +5020,7 @@ void TextEdit::set_line_background_color(int p_line, const Color &p_color) { } text.set_line_background_color(p_line, p_color); - update(); + queue_redraw(); } Color TextEdit::get_line_background_color(int p_line) const { @@ -5038,7 +5038,7 @@ void TextEdit::set_syntax_highlighter(Ref<SyntaxHighlighter> p_syntax_highlighte if (syntax_highlighter.is_valid()) { syntax_highlighter->set_text_edit(this); } - update(); + queue_redraw(); } Ref<SyntaxHighlighter> TextEdit::get_syntax_highlighter() const { @@ -5052,7 +5052,7 @@ void TextEdit::set_highlight_current_line(bool p_enabled) { } highlight_current_line = p_enabled; - update(); + queue_redraw(); } bool TextEdit::is_highlight_current_line_enabled() const { @@ -5065,7 +5065,7 @@ void TextEdit::set_highlight_all_occurrences(const bool p_enabled) { } highlight_all_occurrences = p_enabled; - update(); + queue_redraw(); } bool TextEdit::is_highlight_all_occurrences_enabled() const { @@ -5081,7 +5081,7 @@ void TextEdit::set_draw_control_chars(bool p_enabled) { text.set_draw_control_chars(draw_control_chars); text.invalidate_font(); _update_placeholder(); - update(); + queue_redraw(); } } @@ -5095,7 +5095,7 @@ void TextEdit::set_draw_tabs(bool p_enabled) { } draw_tabs = p_enabled; - update(); + queue_redraw(); } bool TextEdit::is_drawing_tabs() const { @@ -5108,7 +5108,7 @@ void TextEdit::set_draw_spaces(bool p_enabled) { } draw_spaces = p_enabled; - update(); + queue_redraw(); } bool TextEdit::is_drawing_spaces() const { @@ -5560,7 +5560,7 @@ void TextEdit::_set_hiding_enabled(bool p_enabled) { _unhide_all_lines(); } hiding_enabled = p_enabled; - update(); + queue_redraw(); } bool TextEdit::_is_hiding_enabled() const { @@ -5577,7 +5577,7 @@ void TextEdit::_unhide_all_lines() { text.set_hidden(i, false); } _update_scrollbars(); - update(); + queue_redraw(); } void TextEdit::_set_line_as_hidden(int p_line, bool p_hidden) { @@ -5590,7 +5590,7 @@ void TextEdit::_set_line_as_hidden(int p_line, bool p_hidden) { if (_is_hiding_enabled() || !p_hidden) { text.set_hidden(p_line, p_hidden); } - update(); + queue_redraw(); } // Symbol lookup. @@ -5600,7 +5600,7 @@ void TextEdit::_set_symbol_lookup_word(const String &p_symbol) { } lookup_symbol_word = p_symbol; - update(); + queue_redraw(); } /* Text manipulation */ @@ -5985,14 +5985,14 @@ void TextEdit::_reset_caret_blink_timer() { if (has_focus()) { caret_blink_timer->stop(); caret_blink_timer->start(); - update(); + queue_redraw(); } } void TextEdit::_toggle_draw_caret() { draw_caret = !draw_caret; if (is_visible_in_tree() && has_focus() && window_has_focus) { - update(); + queue_redraw(); } } @@ -6054,7 +6054,7 @@ void TextEdit::_update_selection_mode_pointer() { set_caret_line(line, false); set_caret_column(col); - update(); + queue_redraw(); click_select_held->start(); } @@ -6106,7 +6106,7 @@ void TextEdit::_update_selection_mode_word() { DisplayServer::get_singleton()->clipboard_set_primary(get_selected_text()); } - update(); + queue_redraw(); click_select_held->start(); } @@ -6137,7 +6137,7 @@ void TextEdit::_update_selection_mode_line() { DisplayServer::get_singleton()->clipboard_set_primary(get_selected_text()); } - update(); + queue_redraw(); click_select_held->start(); } @@ -6163,7 +6163,7 @@ void TextEdit::_post_shift_selection() { if (selection.active && selection.selecting_mode == SelectionMode::SELECTION_MODE_SHIFT) { select(selection.selecting_line, selection.selecting_column, caret.line, caret.column); - update(); + queue_redraw(); } selection.selecting_text = true; @@ -6325,7 +6325,7 @@ void TextEdit::_scroll_moved(double p_to_val) { caret.line_ofs = n_line; caret.wrap_ofs = wi; } - update(); + queue_redraw(); } double TextEdit::_get_visible_lines_offset() const { @@ -6447,7 +6447,7 @@ void TextEdit::_update_minimap_hover() { if (hovering_minimap) { // Only redraw if the hovering status changed. hovering_minimap = false; - update(); + queue_redraw(); } // Return early to avoid running the operations below when not needed. @@ -6460,7 +6460,7 @@ void TextEdit::_update_minimap_hover() { if (new_hovering_minimap != hovering_minimap) { // Only redraw if the hovering status changed. hovering_minimap = new_hovering_minimap; - update(); + queue_redraw(); } } @@ -6522,7 +6522,7 @@ void TextEdit::_update_gutter_width() { if (gutters_width > 0) { gutter_padding = 2; } - update(); + queue_redraw(); } /* Syntax highlighting. */ diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index 916bb2981e..e2fd903e0e 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -299,7 +299,7 @@ void TextureButton::set_normal_texture(const Ref<Texture2D> &p_normal) { } normal = p_normal; - update(); + queue_redraw(); update_minimum_size(); } @@ -309,7 +309,7 @@ void TextureButton::set_pressed_texture(const Ref<Texture2D> &p_pressed) { } pressed = p_pressed; - update(); + queue_redraw(); update_minimum_size(); } @@ -319,7 +319,7 @@ void TextureButton::set_hover_texture(const Ref<Texture2D> &p_hover) { } hover = p_hover; - update(); + queue_redraw(); update_minimum_size(); } @@ -329,7 +329,7 @@ void TextureButton::set_disabled_texture(const Ref<Texture2D> &p_disabled) { } disabled = p_disabled; - update(); + queue_redraw(); } void TextureButton::set_click_mask(const Ref<BitMap> &p_click_mask) { @@ -337,7 +337,7 @@ void TextureButton::set_click_mask(const Ref<BitMap> &p_click_mask) { return; } click_mask = p_click_mask; - update(); + queue_redraw(); update_minimum_size(); } @@ -380,7 +380,7 @@ void TextureButton::set_ignore_texture_size(bool p_ignore) { ignore_texture_size = p_ignore; update_minimum_size(); - update(); + queue_redraw(); } void TextureButton::set_stretch_mode(StretchMode p_stretch_mode) { @@ -389,7 +389,7 @@ void TextureButton::set_stretch_mode(StretchMode p_stretch_mode) { } stretch_mode = p_stretch_mode; - update(); + queue_redraw(); } TextureButton::StretchMode TextureButton::get_stretch_mode() const { @@ -402,7 +402,7 @@ void TextureButton::set_flip_h(bool p_flip) { } hflip = p_flip; - update(); + queue_redraw(); } bool TextureButton::is_flipped_h() const { @@ -415,7 +415,7 @@ void TextureButton::set_flip_v(bool p_flip) { } vflip = p_flip; - update(); + queue_redraw(); } bool TextureButton::is_flipped_v() const { diff --git a/scene/gui/texture_progress_bar.cpp b/scene/gui/texture_progress_bar.cpp index 2a9e1a8990..a9982b3ece 100644 --- a/scene/gui/texture_progress_bar.cpp +++ b/scene/gui/texture_progress_bar.cpp @@ -38,7 +38,7 @@ void TextureProgressBar::set_under_texture(const Ref<Texture2D> &p_texture) { } under = p_texture; - update(); + queue_redraw(); update_minimum_size(); } @@ -52,7 +52,7 @@ void TextureProgressBar::set_over_texture(const Ref<Texture2D> &p_texture) { } over = p_texture; - update(); + queue_redraw(); if (under.is_null()) { update_minimum_size(); } @@ -70,7 +70,7 @@ void TextureProgressBar::set_stretch_margin(Side p_side, int p_size) { } stretch_margin[p_side] = p_size; - update(); + queue_redraw(); update_minimum_size(); } @@ -85,7 +85,7 @@ void TextureProgressBar::set_nine_patch_stretch(bool p_stretch) { } nine_patch_stretch = p_stretch; - update(); + queue_redraw(); update_minimum_size(); } @@ -113,7 +113,7 @@ void TextureProgressBar::set_progress_texture(const Ref<Texture2D> &p_texture) { } progress = p_texture; - update(); + queue_redraw(); update_minimum_size(); } @@ -127,7 +127,7 @@ void TextureProgressBar::set_progress_offset(Point2 p_offset) { } progress_offset = p_offset; - update(); + queue_redraw(); } Point2 TextureProgressBar::get_progress_offset() const { @@ -140,7 +140,7 @@ void TextureProgressBar::set_tint_under(const Color &p_tint) { } tint_under = p_tint; - update(); + queue_redraw(); } Color TextureProgressBar::get_tint_under() const { @@ -153,7 +153,7 @@ void TextureProgressBar::set_tint_progress(const Color &p_tint) { } tint_progress = p_tint; - update(); + queue_redraw(); } Color TextureProgressBar::get_tint_progress() const { @@ -166,7 +166,7 @@ void TextureProgressBar::set_tint_over(const Color &p_tint) { } tint_over = p_tint; - update(); + queue_redraw(); } Color TextureProgressBar::get_tint_over() const { @@ -591,7 +591,7 @@ void TextureProgressBar::set_fill_mode(int p_fill) { } mode = (FillMode)p_fill; - update(); + queue_redraw(); } int TextureProgressBar::get_fill_mode() { @@ -611,7 +611,7 @@ void TextureProgressBar::set_radial_initial_angle(float p_angle) { } rad_init_angle = p_angle; - update(); + queue_redraw(); } float TextureProgressBar::get_radial_initial_angle() { @@ -626,7 +626,7 @@ void TextureProgressBar::set_fill_degrees(float p_angle) { } rad_max_degrees = angle_clamped; - update(); + queue_redraw(); } float TextureProgressBar::get_fill_degrees() { @@ -639,7 +639,7 @@ void TextureProgressBar::set_radial_center_offset(const Point2 &p_off) { } rad_center_off = p_off; - update(); + queue_redraw(); } Point2 TextureProgressBar::get_radial_center_offset() { diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index 4dd1c74c12..da53da20b0 100644 --- a/scene/gui/texture_rect.cpp +++ b/scene/gui/texture_rect.cpp @@ -150,7 +150,7 @@ void TextureRect::_bind_methods() { void TextureRect::_texture_changed() { if (texture.is_valid()) { - update(); + queue_redraw(); update_minimum_size(); } } @@ -170,7 +170,7 @@ void TextureRect::set_texture(const Ref<Texture2D> &p_tex) { texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TextureRect::_texture_changed)); } - update(); + queue_redraw(); update_minimum_size(); } @@ -184,7 +184,7 @@ void TextureRect::set_ignore_texture_size(bool p_ignore) { } ignore_texture_size = p_ignore; - update(); + queue_redraw(); update_minimum_size(); } @@ -198,7 +198,7 @@ void TextureRect::set_stretch_mode(StretchMode p_mode) { } stretch_mode = p_mode; - update(); + queue_redraw(); } TextureRect::StretchMode TextureRect::get_stretch_mode() const { @@ -211,7 +211,7 @@ void TextureRect::set_flip_h(bool p_flip) { } hflip = p_flip; - update(); + queue_redraw(); } bool TextureRect::is_flipped_h() const { @@ -224,7 +224,7 @@ void TextureRect::set_flip_v(bool p_flip) { } vflip = p_flip; - update(); + queue_redraw(); } bool TextureRect::is_flipped_v() const { diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 2b19ee4d0b..3c6be008f2 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -126,13 +126,13 @@ void TreeItem::_change_tree(Tree *p_tree) { tree->pressing_for_editor = false; } - tree->update(); + tree->queue_redraw(); } tree = p_tree; if (tree) { - tree->update(); + tree->queue_redraw(); cells.resize(tree->columns.size()); } } @@ -551,7 +551,7 @@ void TreeItem::set_collapsed(bool p_collapsed) { select(tree->selected_col); } - tree->update(); + tree->queue_redraw(); } } @@ -569,7 +569,7 @@ void TreeItem::set_visible(bool p_visible) { } visible = p_visible; if (tree) { - tree->update(); + tree->queue_redraw(); _changed_notify(); } } @@ -610,7 +610,7 @@ TreeItem *TreeItem::create_child(int p_idx) { TreeItem *ti = memnew(TreeItem(tree)); if (tree) { ti->cells.resize(tree->columns.size()); - tree->update(); + tree->queue_redraw(); } TreeItem *l_prev = nullptr; @@ -880,7 +880,7 @@ void TreeItem::move_before(TreeItem *p_item) { p_item->prev = this; if (tree && old_tree == tree) { - tree->update(); + tree->queue_redraw(); } validate_cache(); @@ -924,7 +924,7 @@ void TreeItem::move_after(TreeItem *p_item) { } if (tree && old_tree == tree) { - tree->update(); + tree->queue_redraw(); } validate_cache(); } @@ -939,7 +939,7 @@ void TreeItem::remove_child(TreeItem *p_item) { p_item->parent = nullptr; if (tree) { - tree->update(); + tree->queue_redraw(); } validate_cache(); } @@ -972,7 +972,7 @@ void TreeItem::set_as_cursor(int p_column) { } tree->selected_item = this; tree->selected_col = p_column; - tree->update(); + tree->queue_redraw(); } void TreeItem::select(int p_column) { @@ -1013,7 +1013,7 @@ Ref<Texture2D> TreeItem::get_button(int p_column, int p_idx) const { return cells[p_column].buttons[p_idx].texture; } -String TreeItem::get_button_tooltip(int p_column, int p_idx) const { +String TreeItem::get_button_tooltip_text(int p_column, int p_idx) const { ERR_FAIL_INDEX_V(p_column, cells.size(), String()); ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), String()); return cells[p_column].buttons[p_idx].tooltip; @@ -1160,12 +1160,12 @@ int TreeItem::get_custom_font_size(int p_column) const { return cells[p_column].custom_font_size; } -void TreeItem::set_tooltip(int p_column, const String &p_tooltip) { +void TreeItem::set_tooltip_text(int p_column, const String &p_tooltip) { ERR_FAIL_INDEX(p_column, cells.size()); cells.write[p_column].tooltip = p_tooltip; } -String TreeItem::get_tooltip(int p_column) const { +String TreeItem::get_tooltip_text(int p_column) const { ERR_FAIL_INDEX_V(p_column, cells.size(), ""); return cells[p_column].tooltip; } @@ -1441,9 +1441,9 @@ void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("set_custom_as_button", "column", "enable"), &TreeItem::set_custom_as_button); ClassDB::bind_method(D_METHOD("is_custom_set_as_button", "column"), &TreeItem::is_custom_set_as_button); - ClassDB::bind_method(D_METHOD("add_button", "column", "button", "id", "disabled", "tooltip"), &TreeItem::add_button, DEFVAL(-1), DEFVAL(false), DEFVAL("")); + ClassDB::bind_method(D_METHOD("add_button", "column", "button", "id", "disabled", "tooltip_text"), &TreeItem::add_button, DEFVAL(-1), DEFVAL(false), DEFVAL("")); ClassDB::bind_method(D_METHOD("get_button_count", "column"), &TreeItem::get_button_count); - ClassDB::bind_method(D_METHOD("get_button_tooltip", "column", "button_idx"), &TreeItem::get_button_tooltip); + ClassDB::bind_method(D_METHOD("get_button_tooltip_text", "column", "button_idx"), &TreeItem::get_button_tooltip_text); ClassDB::bind_method(D_METHOD("get_button_id", "column", "button_idx"), &TreeItem::get_button_id); ClassDB::bind_method(D_METHOD("get_button_by_id", "column", "id"), &TreeItem::get_button_by_id); ClassDB::bind_method(D_METHOD("get_button", "column", "button_idx"), &TreeItem::get_button); @@ -1452,8 +1452,8 @@ void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("set_button_disabled", "column", "button_idx", "disabled"), &TreeItem::set_button_disabled); ClassDB::bind_method(D_METHOD("is_button_disabled", "column", "button_idx"), &TreeItem::is_button_disabled); - ClassDB::bind_method(D_METHOD("set_tooltip", "column", "tooltip"), &TreeItem::set_tooltip); - ClassDB::bind_method(D_METHOD("get_tooltip", "column"), &TreeItem::get_tooltip); + ClassDB::bind_method(D_METHOD("set_tooltip_text", "column", "tooltip"), &TreeItem::set_tooltip_text); + ClassDB::bind_method(D_METHOD("get_tooltip_text", "column"), &TreeItem::get_tooltip_text); ClassDB::bind_method(D_METHOD("set_text_alignment", "column", "text_alignment"), &TreeItem::set_text_alignment); ClassDB::bind_method(D_METHOD("get_text_alignment", "column"), &TreeItem::get_text_alignment); @@ -2658,7 +2658,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int cache.click_item = p_item; cache.click_column = col; cache.click_pos = click_pos; - update(); + queue_redraw(); return -1; } @@ -2716,7 +2716,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int emit_signal(SNAME("multi_selected"),p_item,col,true); } */ - update(); + queue_redraw(); } } } @@ -2935,7 +2935,7 @@ void Tree::_text_editor_submit(String p_text) { } item_edited(popup_edited_item_col, popup_edited_item); - update(); + queue_redraw(); } void Tree::value_editor_changed(double p_value) { @@ -2952,7 +2952,7 @@ void Tree::value_editor_changed(double p_value) { text_editor->set_text(String::num(c.val, Math::range_step_decimals(c.step))); item_edited(popup_edited_item_col, popup_edited_item); - update(); + queue_redraw(); } void Tree::popup_select(int p_option) { @@ -2966,7 +2966,7 @@ void Tree::popup_select(int p_option) { popup_edited_item->cells.write[popup_edited_item_col].val = p_option; //popup_edited_item->edited_signal.call( popup_edited_item_col ); - update(); + queue_redraw(); item_edited(popup_edited_item_col, popup_edited_item); } @@ -2993,7 +2993,7 @@ void Tree::_go_left() { selected_item->select(selected_col - 1); } } - update(); + queue_redraw(); accept_event(); ensure_cursor_is_visible(); } @@ -3014,7 +3014,7 @@ void Tree::_go_right() { selected_item->select(selected_col + 1); } } - update(); + queue_redraw(); ensure_cursor_is_visible(); accept_event(); } @@ -3043,7 +3043,7 @@ void Tree::_go_up() { } selected_item = prev; emit_signal(SNAME("cell_selected")); - update(); + queue_redraw(); } else { int col = selected_col < 0 ? 0 : selected_col; while (prev && !prev->cells[col].selectable) { @@ -3086,7 +3086,7 @@ void Tree::_go_down() { selected_item = next; emit_signal(SNAME("cell_selected")); - update(); + queue_redraw(); } else { int col = selected_col < 0 ? 0 : selected_col; @@ -3196,7 +3196,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) { if (select_mode == SELECT_MULTI) { selected_item = next; emit_signal(SNAME("cell_selected")); - update(); + queue_redraw(); } else { while (next && !next->cells[selected_col].selectable) { next = next->get_next_visible(); @@ -3234,7 +3234,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) { if (select_mode == SELECT_MULTI) { selected_item = prev; emit_signal(SNAME("cell_selected")); - update(); + queue_redraw(); } else { while (prev && !prev->cells[selected_col].selectable) { prev = prev->get_prev_visible(); @@ -3358,11 +3358,11 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) { if (drop_mode_flags) { if (it != drop_mode_over) { drop_mode_over = it; - update(); + queue_redraw(); } if (it && section != drop_mode_section) { drop_mode_section = section; - update(); + queue_redraw(); } } @@ -3371,14 +3371,14 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) { if (it != old_it || col != old_col) { if (old_it && old_col >= old_it->cells.size()) { - // Columns may have changed since last update(). - update(); + // Columns may have changed since last redraw(). + queue_redraw(); } else { // Only need to update if mouse enters/exits a button bool was_over_button = old_it && old_it->cells[old_col].custom_button; bool is_over_button = it && it->cells[col].custom_button; if (was_over_button || is_over_button) { - update(); + queue_redraw(); } } } @@ -3387,7 +3387,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) { // Update if mouse enters/exits columns if (cache.hover_type != old_hover || cache.hover_index != old_index) { - update(); + queue_redraw(); } if (pressing_for_editor && popup_pressing_edited_item && (popup_pressing_edited_item->get_cell_mode(popup_pressing_edited_item_column) == TreeItem::CELL_MODE_RANGE)) { @@ -3526,7 +3526,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) { cache.click_id = -1; cache.click_item = nullptr; cache.click_column = 0; - update(); + queue_redraw(); return; } @@ -3556,7 +3556,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) { if (pos.x < static_cast<real_t>(len)) { cache.click_type = Cache::CLICK_TITLE; cache.click_index = i; - update(); + queue_redraw(); break; } } @@ -3852,7 +3852,7 @@ void Tree::_notification(int p_what) { case NOTIFICATION_MOUSE_EXIT: { if (cache.hover_type != Cache::CLICK_NONE) { cache.hover_type = Cache::CLICK_NONE; - update(); + queue_redraw(); } } break; @@ -3868,7 +3868,7 @@ void Tree::_notification(int p_what) { drop_mode_flags = 0; scrolling = false; set_physics_process_internal(false); - update(); + queue_redraw(); } break; case NOTIFICATION_DRAG_BEGIN: { @@ -4110,7 +4110,7 @@ void Tree::item_changed(int p_column, TreeItem *p_item) { if (p_item != nullptr && p_column >= 0 && p_column < p_item->cells.size()) { p_item->cells.write[p_column].dirty = true; } - update(); + queue_redraw(); } void Tree::item_selected(int p_column, TreeItem *p_item) { @@ -4129,7 +4129,7 @@ void Tree::item_selected(int p_column, TreeItem *p_item) { } else { select_single_item(p_item, root, p_column); } - update(); + queue_redraw(); } void Tree::item_deselected(int p_column, TreeItem *p_item) { @@ -4144,7 +4144,7 @@ void Tree::item_deselected(int p_column, TreeItem *p_item) { if (select_mode == SELECT_MULTI || select_mode == SELECT_SINGLE) { p_item->cells.write[p_column].selected = false; } - update(); + queue_redraw(); } void Tree::set_select_mode(SelectMode p_mode) { @@ -4167,7 +4167,7 @@ void Tree::deselect_all() { selected_item = nullptr; selected_col = -1; - update(); + queue_redraw(); } bool Tree::is_anything_selected() { @@ -4196,7 +4196,7 @@ void Tree::clear() { popup_edited_item = nullptr; popup_pressing_edited_item = nullptr; - update(); + queue_redraw(); }; void Tree::set_hide_root(bool p_enabled) { @@ -4205,7 +4205,7 @@ void Tree::set_hide_root(bool p_enabled) { } hide_root = p_enabled; - update(); + queue_redraw(); } bool Tree::is_root_hidden() const { @@ -4223,7 +4223,7 @@ void Tree::set_column_custom_minimum_width(int p_column, int p_min_width) { return; } columns.write[p_column].custom_min_width = p_min_width; - update(); + queue_redraw(); } void Tree::set_column_expand(int p_column, bool p_expand) { @@ -4234,7 +4234,7 @@ void Tree::set_column_expand(int p_column, bool p_expand) { } columns.write[p_column].expand = p_expand; - update(); + queue_redraw(); } void Tree::set_column_expand_ratio(int p_column, int p_ratio) { @@ -4245,7 +4245,7 @@ void Tree::set_column_expand_ratio(int p_column, int p_ratio) { } columns.write[p_column].expand_ratio = p_ratio; - update(); + queue_redraw(); } void Tree::set_column_clip_content(int p_column, bool p_fit) { @@ -4256,7 +4256,7 @@ void Tree::set_column_clip_content(int p_column, bool p_fit) { } columns.write[p_column].clip_content = p_fit; - update(); + queue_redraw(); } bool Tree::is_column_expanding(int p_column) const { @@ -4429,7 +4429,7 @@ void Tree::set_columns(int p_columns) { if (selected_col >= p_columns) { selected_col = p_columns - 1; } - update(); + queue_redraw(); } int Tree::get_columns() const { @@ -4437,7 +4437,7 @@ int Tree::get_columns() const { } void Tree::_scroll_moved(float) { - update(); + queue_redraw(); } Rect2 Tree::get_custom_popup_rect() const { @@ -4582,7 +4582,7 @@ void Tree::set_column_titles_visible(bool p_show) { } show_column_titles = p_show; - update(); + queue_redraw(); } bool Tree::are_column_titles_visible() const { @@ -4601,7 +4601,7 @@ void Tree::set_column_title(int p_column, const String &p_title) { } columns.write[p_column].title = p_title; update_column(p_column); - update(); + queue_redraw(); } String Tree::get_column_title(int p_column) const { @@ -4615,7 +4615,7 @@ void Tree::set_column_title_direction(int p_column, Control::TextDirection p_tex if (columns[p_column].text_direction != p_text_direction) { columns.write[p_column].text_direction = p_text_direction; update_column(p_column); - update(); + queue_redraw(); } } @@ -4629,7 +4629,7 @@ void Tree::set_column_title_language(int p_column, const String &p_language) { if (columns[p_column].language != p_language) { columns.write[p_column].language = p_language; update_column(p_column); - update(); + queue_redraw(); } } @@ -5005,10 +5005,10 @@ String Tree::get_tooltip(const Point2 &p_pos) const { col_width -= size.width; } String ret; - if (it->get_tooltip(col) == "") { + if (it->get_tooltip_text(col) == "") { ret = it->get_text(col); } else { - ret = it->get_tooltip(col); + ret = it->get_tooltip_text(col); } return ret; } @@ -5027,7 +5027,7 @@ void Tree::set_hide_folding(bool p_hide) { } hide_folding = p_hide; - update(); + queue_redraw(); } bool Tree::is_folding_hidden() const { @@ -5043,7 +5043,7 @@ void Tree::set_drop_mode_flags(int p_flags) { drop_mode_over = nullptr; } - update(); + queue_redraw(); } int Tree::get_drop_mode_flags() const { diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 7f9c00b1b9..8eabdd60a1 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -245,7 +245,7 @@ public: void add_button(int p_column, const Ref<Texture2D> &p_button, int p_id = -1, bool p_disabled = false, const String &p_tooltip = ""); int get_button_count(int p_column) const; - String get_button_tooltip(int p_column, int p_idx) const; + String get_button_tooltip_text(int p_column, int p_idx) const; Ref<Texture2D> get_button(int p_column, int p_idx) const; int get_button_id(int p_column, int p_idx) const; void erase_button(int p_column, int p_idx); @@ -308,8 +308,8 @@ public: void set_custom_as_button(int p_column, bool p_button); bool is_custom_set_as_button(int p_column) const; - void set_tooltip(int p_column, const String &p_tooltip); - String get_tooltip(int p_column) const; + void set_tooltip_text(int p_column, const String &p_tooltip); + String get_tooltip_text(int p_column) const; void set_text_alignment(int p_column, HorizontalAlignment p_alignment); HorizontalAlignment get_text_alignment(int p_column) const; diff --git a/scene/gui/video_stream_player.cpp b/scene/gui/video_stream_player.cpp index 4024d4c80e..1e03ed6e76 100644 --- a/scene/gui/video_stream_player.cpp +++ b/scene/gui/video_stream_player.cpp @@ -213,7 +213,7 @@ void VideoStreamPlayer::set_expand(bool p_expand) { } expand = p_expand; - update(); + queue_redraw(); update_minimum_size(); } @@ -261,7 +261,7 @@ void VideoStreamPlayer::set_stream(const Ref<VideoStream> &p_stream) { AudioServer::get_singleton()->unlock(); } - update(); + queue_redraw(); if (!expand) { update_minimum_size(); diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index 515f4d88a6..61a7600664 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -88,7 +88,7 @@ void CanvasItem::_handle_visibility_change(bool p_visible) { notification(NOTIFICATION_VISIBILITY_CHANGED); if (p_visible) { - update(); + queue_redraw(); } else { emit_signal(SceneStringNames::get_singleton()->hidden); } @@ -121,7 +121,7 @@ CanvasItem *CanvasItem::get_current_item_drawn() { return current_item_drawn; } -void CanvasItem::_update_callback() { +void CanvasItem::_redraw_callback() { if (!is_inside_tree()) { pending_update = false; return; @@ -242,7 +242,7 @@ void CanvasItem::_enter_canvas() { } pending_update = false; - update(); + queue_redraw(); notification(NOTIFICATION_ENTER_CANVAS); } @@ -355,7 +355,7 @@ void CanvasItem::_window_visibility_changed() { } } -void CanvasItem::update() { +void CanvasItem::queue_redraw() { if (!is_inside_tree()) { return; } @@ -365,7 +365,7 @@ void CanvasItem::update() { pending_update = true; - MessageQueue::get_singleton()->push_call(this, SNAME("_update_callback")); + MessageQueue::get_singleton()->push_callable(callable_mp(this, &CanvasItem::_redraw_callback)); } void CanvasItem::set_modulate(const Color &p_modulate) { @@ -438,7 +438,7 @@ int CanvasItem::get_light_mask() const { void CanvasItem::item_rect_changed(bool p_size_changed) { if (p_size_changed) { - update(); + queue_redraw(); } emit_signal(SceneStringNames::get_singleton()->item_rect_changed); } @@ -867,7 +867,6 @@ void CanvasItem::force_update_transform() { void CanvasItem::_bind_methods() { ClassDB::bind_method(D_METHOD("_top_level_raise_self"), &CanvasItem::_top_level_raise_self); - ClassDB::bind_method(D_METHOD("_update_callback"), &CanvasItem::_update_callback); #ifdef TOOLS_ENABLED ClassDB::bind_method(D_METHOD("_edit_set_state", "state"), &CanvasItem::_edit_set_state); @@ -896,7 +895,7 @@ void CanvasItem::_bind_methods() { ClassDB::bind_method(D_METHOD("show"), &CanvasItem::show); ClassDB::bind_method(D_METHOD("hide"), &CanvasItem::hide); - ClassDB::bind_method(D_METHOD("update"), &CanvasItem::update); + ClassDB::bind_method(D_METHOD("queue_redraw"), &CanvasItem::queue_redraw); ClassDB::bind_method(D_METHOD("set_as_top_level", "enable"), &CanvasItem::set_as_top_level); ClassDB::bind_method(D_METHOD("is_set_as_top_level"), &CanvasItem::is_set_as_top_level); @@ -1100,7 +1099,7 @@ void CanvasItem::_update_texture_filter_changed(bool p_propagate) { texture_filter_cache = RS::CanvasItemTextureFilter(texture_filter); } RS::get_singleton()->canvas_item_set_default_texture_filter(get_canvas_item(), texture_filter_cache); - update(); + queue_redraw(); if (p_propagate) { for (CanvasItem *E : children_items) { @@ -1141,7 +1140,7 @@ void CanvasItem::_update_texture_repeat_changed(bool p_propagate) { texture_repeat_cache = RS::CanvasItemTextureRepeat(texture_repeat); } RS::get_singleton()->canvas_item_set_default_texture_repeat(get_canvas_item(), texture_repeat_cache); - update(); + queue_redraw(); if (p_propagate) { for (CanvasItem *E : children_items) { if (!E->top_level && E->texture_repeat == TEXTURE_REPEAT_PARENT_NODE) { diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h index 1e0d4552ce..1abb4edec9 100644 --- a/scene/main/canvas_item.h +++ b/scene/main/canvas_item.h @@ -110,7 +110,7 @@ private: void _propagate_visibility_changed(bool p_parent_visible_in_tree); void _handle_visibility_change(bool p_visible); - void _update_callback(); + void _redraw_callback(); void _enter_canvas(); void _exit_canvas(); @@ -197,7 +197,7 @@ public: void show(); void hide(); - void update(); + void queue_redraw(); void set_clip_children(bool p_enabled); bool is_clipping_children() const; diff --git a/scene/main/node.cpp b/scene/main/node.cpp index cc3d14e5be..289e963077 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -951,14 +951,11 @@ String Node::validate_child_name(Node *p_child) { String Node::adjust_name_casing(const String &p_name) { switch (GLOBAL_GET("editor/node_naming/name_casing").operator int()) { case NAME_CASING_PASCAL_CASE: - return p_name.capitalize().replace(" ", ""); - case NAME_CASING_CAMEL_CASE: { - String name = p_name.capitalize().replace(" ", ""); - name[0] = name.to_lower()[0]; - return name; - } + return p_name.to_pascal_case(); + case NAME_CASING_CAMEL_CASE: + return p_name.to_camel_case(); case NAME_CASING_SNAKE_CASE: - return p_name.capitalize().replace(" ", "_").to_lower(); + return p_name.to_snake_case(); } return p_name; } @@ -2926,7 +2923,7 @@ void Node::_bind_methods() { BIND_CONSTANT(NOTIFICATION_PROCESS); BIND_CONSTANT(NOTIFICATION_PARENTED); BIND_CONSTANT(NOTIFICATION_UNPARENTED); - BIND_CONSTANT(NOTIFICATION_INSTANCED); + BIND_CONSTANT(NOTIFICATION_SCENE_INSTANTIATED); BIND_CONSTANT(NOTIFICATION_DRAG_BEGIN); BIND_CONSTANT(NOTIFICATION_DRAG_END); BIND_CONSTANT(NOTIFICATION_PATH_RENAMED); diff --git a/scene/main/node.h b/scene/main/node.h index 703c580d3f..ae6a997579 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -259,7 +259,7 @@ public: NOTIFICATION_PROCESS = 17, NOTIFICATION_PARENTED = 18, NOTIFICATION_UNPARENTED = 19, - NOTIFICATION_INSTANCED = 20, + NOTIFICATION_SCENE_INSTANTIATED = 20, NOTIFICATION_DRAG_BEGIN = 21, NOTIFICATION_DRAG_END = 22, NOTIFICATION_PATH_RENAMED = 23, diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 109799e23a..ec98ff36a0 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1370,9 +1370,9 @@ void SceneTree::get_argument_options(const StringName &p_function, int p_idx, Li } if (dir_access->dir_exists(filename)) { - directories.push_back(dir_access->get_current_dir().plus_file(filename)); + directories.push_back(dir_access->get_current_dir().path_join(filename)); } else if (filename.ends_with(".tscn") || filename.ends_with(".scn")) { - r_options->push_back("\"" + dir_access->get_current_dir().plus_file(filename) + "\""); + r_options->push_back("\"" + dir_access->get_current_dir().path_join(filename) + "\""); } filename = dir_access->get_next(); @@ -1418,9 +1418,13 @@ SceneTree::SceneTree() { root->set_as_audio_listener_2d(true); current_scene = nullptr; - const int msaa_mode = GLOBAL_DEF_BASIC("rendering/anti_aliasing/quality/msaa", 0); - ProjectSettings::get_singleton()->set_custom_property_info("rendering/anti_aliasing/quality/msaa", PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/msaa", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Average),4× (Slow),8× (Slowest)"))); - root->set_msaa(Viewport::MSAA(msaa_mode)); + const int msaa_mode_2d = GLOBAL_DEF_BASIC("rendering/anti_aliasing/quality/msaa_2d", 0); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/anti_aliasing/quality/msaa_2d", PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/msaa_2d", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Average),4× (Slow),8× (Slowest)"))); + root->set_msaa_2d(Viewport::MSAA(msaa_mode_2d)); + + const int msaa_mode_3d = GLOBAL_DEF_BASIC("rendering/anti_aliasing/quality/msaa_3d", 0); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/anti_aliasing/quality/msaa_3d", PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/msaa_3d", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Average),4× (Slow),8× (Slowest)"))); + root->set_msaa_3d(Viewport::MSAA(msaa_mode_3d)); const int ssaa_mode = GLOBAL_DEF_BASIC("rendering/anti_aliasing/quality/screen_space_aa", 0); ProjectSettings::get_singleton()->set_custom_property_info("rendering/anti_aliasing/quality/screen_space_aa", PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/screen_space_aa", PROPERTY_HINT_ENUM, "Disabled (Fastest),FXAA (Fast)")); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index a5a4e29186..a738c6eabc 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1023,7 +1023,7 @@ void Viewport::_update_canvas_items(Node *p_node) { CanvasItem *ci = Object::cast_to<CanvasItem>(p_node); if (ci) { - ci->update(); + ci->queue_redraw(); } } @@ -2197,7 +2197,7 @@ void Viewport::_gui_control_grab_focus(Control *p_control) { gui.key_focus = p_control; emit_signal(SNAME("gui_focus_changed"), p_control); p_control->notification(Control::NOTIFICATION_FOCUS_ENTER); - p_control->update(); + p_control->queue_redraw(); } void Viewport::_gui_accept_event() { @@ -2865,7 +2865,7 @@ void Viewport::gui_release_focus() { Control *f = gui.key_focus; gui.key_focus = nullptr; f->notification(Control::NOTIFICATION_FOCUS_EXIT, true); - f->update(); + f->queue_redraw(); } } @@ -2873,17 +2873,30 @@ Control *Viewport::gui_get_focus_owner() { return gui.key_focus; } -void Viewport::set_msaa(MSAA p_msaa) { +void Viewport::set_msaa_2d(MSAA p_msaa) { ERR_FAIL_INDEX(p_msaa, MSAA_MAX); - if (msaa == p_msaa) { + if (msaa_2d == p_msaa) { return; } - msaa = p_msaa; - RS::get_singleton()->viewport_set_msaa(viewport, RS::ViewportMSAA(p_msaa)); + msaa_2d = p_msaa; + RS::get_singleton()->viewport_set_msaa_2d(viewport, RS::ViewportMSAA(p_msaa)); } -Viewport::MSAA Viewport::get_msaa() const { - return msaa; +Viewport::MSAA Viewport::get_msaa_2d() const { + return msaa_2d; +} + +void Viewport::set_msaa_3d(MSAA p_msaa) { + ERR_FAIL_INDEX(p_msaa, MSAA_MAX); + if (msaa_3d == p_msaa) { + return; + } + msaa_3d = p_msaa; + RS::get_singleton()->viewport_set_msaa_3d(viewport, RS::ViewportMSAA(p_msaa)); +} + +Viewport::MSAA Viewport::get_msaa_3d() const { + return msaa_3d; } void Viewport::set_screen_space_aa(ScreenSpaceAA p_screen_space_aa) { @@ -3675,8 +3688,11 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_transparent_background", "enable"), &Viewport::set_transparent_background); ClassDB::bind_method(D_METHOD("has_transparent_background"), &Viewport::has_transparent_background); - ClassDB::bind_method(D_METHOD("set_msaa", "msaa"), &Viewport::set_msaa); - ClassDB::bind_method(D_METHOD("get_msaa"), &Viewport::get_msaa); + ClassDB::bind_method(D_METHOD("set_msaa_2d", "msaa"), &Viewport::set_msaa_2d); + ClassDB::bind_method(D_METHOD("get_msaa_2d"), &Viewport::get_msaa_2d); + + ClassDB::bind_method(D_METHOD("set_msaa_3d", "msaa"), &Viewport::set_msaa_3d); + ClassDB::bind_method(D_METHOD("get_msaa_3d"), &Viewport::get_msaa_3d); ClassDB::bind_method(D_METHOD("set_screen_space_aa", "screen_space_aa"), &Viewport::set_screen_space_aa); ClassDB::bind_method(D_METHOD("get_screen_space_aa"), &Viewport::get_screen_space_aa); @@ -3816,7 +3832,8 @@ void Viewport::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_2d_transforms_to_pixel"), "set_snap_2d_transforms_to_pixel", "is_snap_2d_transforms_to_pixel_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_2d_vertices_to_pixel"), "set_snap_2d_vertices_to_pixel", "is_snap_2d_vertices_to_pixel_enabled"); ADD_GROUP("Rendering", ""); - ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Average),4× (Slow),8× (Slowest)")), "set_msaa", "get_msaa"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa_2d", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Average),4× (Slow),8× (Slowest)")), "set_msaa_2d", "get_msaa_2d"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa_3d", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Average),4× (Slow),8× (Slowest)")), "set_msaa_3d", "get_msaa_3d"); ADD_PROPERTY(PropertyInfo(Variant::INT, "screen_space_aa", PROPERTY_HINT_ENUM, "Disabled (Fastest),FXAA (Fast)"), "set_screen_space_aa", "get_screen_space_aa"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_taa"), "set_use_taa", "is_using_taa"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_debanding"), "set_use_debanding", "is_using_debanding"); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 83083cd65a..0b3853ba79 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -297,7 +297,8 @@ private: bool positional_shadow_atlas_16_bits = true; PositionalShadowAtlasQuadrantSubdiv positional_shadow_atlas_quadrant_subdiv[4]; - MSAA msaa = MSAA_DISABLED; + MSAA msaa_2d = MSAA_DISABLED; + MSAA msaa_3d = MSAA_DISABLED; ScreenSpaceAA screen_space_aa = SCREEN_SPACE_AA_DISABLED; bool use_taa = false; @@ -522,8 +523,11 @@ public: void set_positional_shadow_atlas_quadrant_subdiv(int p_quadrant, PositionalShadowAtlasQuadrantSubdiv p_subdiv); PositionalShadowAtlasQuadrantSubdiv get_positional_shadow_atlas_quadrant_subdiv(int p_quadrant) const; - void set_msaa(MSAA p_msaa); - MSAA get_msaa() const; + void set_msaa_2d(MSAA p_msaa); + MSAA get_msaa_2d() const; + + void set_msaa_3d(MSAA p_msaa); + MSAA get_msaa_3d() const; void set_screen_space_aa(ScreenSpaceAA p_screen_space_aa); ScreenSpaceAA get_screen_space_aa() const; diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 410f35e597..73ad1ceff7 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -831,6 +831,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_stylebox("tab_unselected", "TabContainer", style_tab_unselected); theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled); theme->set_stylebox("panel", "TabContainer", make_flat_stylebox(style_normal_color, 0, 0, 0, 0)); + theme->set_stylebox("tabbar_background", "TabContainer", make_empty_stylebox(0, 0, 0, 0)); theme->set_icon("increment", "TabContainer", icons["scroll_button_right"]); theme->set_icon("increment_highlight", "TabContainer", icons["scroll_button_right_hl"]); diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 8ec5678f0a..189d8d5502 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -1427,7 +1427,7 @@ Error FontFile::load_bitmap_font(const String &p_path) { while (!f->eof_reached() && f->get_position() <= off + block_size) { if (c == '\0') { String base_dir = p_path.get_base_dir(); - String file = base_dir.plus_file(String::utf8(cs.ptr(), cs.length())); + String file = base_dir.path_join(String::utf8(cs.ptr(), cs.length())); if (RenderingServer::get_singleton() != nullptr) { Ref<Image> img; img.instantiate(); @@ -1660,7 +1660,7 @@ Error FontFile::load_bitmap_font(const String &p_path) { } if (keys.has("file")) { String base_dir = p_path.get_base_dir(); - String file = base_dir.plus_file(keys["file"]); + String file = base_dir.path_join(keys["file"]); if (RenderingServer::get_singleton() != nullptr) { Ref<Image> img; img.instantiate(); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index bd0e470112..32ddef1693 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -2971,6 +2971,8 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) : set_transparency(TRANSPARENCY_DISABLED); set_alpha_antialiasing(ALPHA_ANTIALIASING_OFF); + // Alpha scissor threshold of 0.5 matches the glTF specification and Label3D default. + // <https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#_material_alphacutoff> set_alpha_scissor_threshold(0.5); set_alpha_hash_scale(1.0); set_alpha_antialiasing_edge(0.3); diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 33334801c3..e0bedad595 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -1755,7 +1755,7 @@ Node *PackedScene::instantiate(GenEditState p_edit_state) const { s->set_scene_file_path(get_path()); } - s->notification(Node::NOTIFICATION_INSTANCED); + s->notification(Node::NOTIFICATION_SCENE_INSTANTIATED); return s; } diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 2b1d91e4ef..0d798d2e27 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -451,7 +451,7 @@ Error ResourceLoaderText::load() { if (!path.contains("://") && path.is_relative_path()) { // path is relative to file being loaded, so convert to a resource path - path = ProjectSettings::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path)); + path = ProjectSettings::get_singleton()->localize_path(local_path.get_base_dir().path_join(path)); } if (remaps.has(path)) { @@ -861,7 +861,7 @@ void ResourceLoaderText::get_dependencies(Ref<FileAccess> p_f, List<String> *p_d if (!using_uid && !path.contains("://") && path.is_relative_path()) { // path is relative to file being loaded, so convert to a resource path - path = ProjectSettings::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path)); + path = ProjectSettings::get_singleton()->localize_path(local_path.get_base_dir().path_join(path)); } if (p_add_types) { @@ -938,7 +938,7 @@ Error ResourceLoaderText::rename_dependencies(Ref<FileAccess> p_f, const String } bool relative = false; if (!path.begins_with("res://")) { - path = base_path.plus_file(path).simplify_path(); + path = base_path.path_join(path).simplify_path(); relative = true; } diff --git a/scene/resources/skeleton_modification_stack_2d.cpp b/scene/resources/skeleton_modification_stack_2d.cpp index 38ec19828f..068c756849 100644 --- a/scene/resources/skeleton_modification_stack_2d.cpp +++ b/scene/resources/skeleton_modification_stack_2d.cpp @@ -138,7 +138,7 @@ void SkeletonModificationStack2D::set_editor_gizmos_dirty(bool p_dirty) { if (!editor_gizmo_dirty && p_dirty) { editor_gizmo_dirty = p_dirty; if (skeleton) { - skeleton->update(); + skeleton->queue_redraw(); } } else { editor_gizmo_dirty = p_dirty; diff --git a/servers/movie_writer/movie_writer.cpp b/servers/movie_writer/movie_writer.cpp index 40b2b2539e..2164dca29e 100644 --- a/servers/movie_writer/movie_writer.cpp +++ b/servers/movie_writer/movie_writer.cpp @@ -191,7 +191,7 @@ void MovieWriter::end() { if (movie_path.is_relative_path()) { // Print absolute path to make finding the file easier, // and to make it clickable in terminal emulators that support this. - movie_path = ProjectSettings::get_singleton()->globalize_path("res://").plus_file(movie_path); + movie_path = ProjectSettings::get_singleton()->globalize_path("res://").path_join(movie_path); } print_line(vformat("Done recording movie at path: %s", movie_path)); diff --git a/servers/rendering/dummy/storage/texture_storage.h b/servers/rendering/dummy/storage/texture_storage.h index 73b1284558..d4f832b5f8 100644 --- a/servers/rendering/dummy/storage/texture_storage.h +++ b/servers/rendering/dummy/storage/texture_storage.h @@ -159,6 +159,7 @@ public: virtual void render_target_set_direct_to_screen(RID p_render_target, bool p_direct_to_screen) override {} virtual bool render_target_was_used(RID p_render_target) override { return false; } virtual void render_target_set_as_unused(RID p_render_target) override {} + virtual void render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) override {} virtual void render_target_request_clear(RID p_render_target, const Color &p_clear_color) override {} virtual bool render_target_is_clear_requested(RID p_render_target) override { return false; } diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp index 967b725b9e..e7abcf5674 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp @@ -267,7 +267,7 @@ RendererCompositorRD::RendererCompositorRD() { if (err != OK) { ERR_PRINT("Can't create shader cache folder, no shader caching will happen: " + shader_cache_dir); } else { - shader_cache_dir = shader_cache_dir.plus_file("shader_cache"); + shader_cache_dir = shader_cache_dir.path_join("shader_cache"); bool shader_cache_enabled = GLOBAL_GET("rendering/shader_compiler/shader_cache/enabled"); if (!Engine::get_singleton()->is_editor_hint() && !shader_cache_enabled) { diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index 7adc36c57c..2d004baf48 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -2484,7 +2484,7 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p rb->height = p_height; rb->fsr_sharpness = p_fsr_sharpness; rb->render_target = p_render_target; - rb->msaa = p_msaa; + rb->msaa_3d = p_msaa; rb->screen_space_aa = p_screen_space_aa; rb->use_taa = p_use_taa; rb->use_debanding = p_use_debanding; @@ -2509,7 +2509,7 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p tf.height = rb->internal_height; // If set to rb->width, msaa won't crash tf.array_layers = rb->view_count; // create a layer for every view tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | (_render_buffers_can_be_storage() ? RD::TEXTURE_USAGE_STORAGE_BIT : 0) | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; - if (rb->msaa != RS::VIEWPORT_MSAA_DISABLED) { + if (rb->msaa_3d != RS::VIEWPORT_MSAA_DISABLED) { tf.usage_bits |= RD::TEXTURE_USAGE_CAN_COPY_TO_BIT; } tf.usage_bits |= RD::TEXTURE_USAGE_INPUT_ATTACHMENT_BIT; // only needed when using subpasses in the mobile renderer @@ -2532,7 +2532,7 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p if (rb->view_count > 1) { tf.texture_type = RD::TEXTURE_TYPE_2D_ARRAY; } - if (rb->msaa == RS::VIEWPORT_MSAA_DISABLED) { + if (rb->msaa_3d == RS::VIEWPORT_MSAA_DISABLED) { tf.format = RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_D24_UNORM_S8_UINT, (RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT)) ? RD::DATA_FORMAT_D24_UNORM_S8_UINT : RD::DATA_FORMAT_D32_SFLOAT_S8_UINT; } else { tf.format = RD::DATA_FORMAT_R32_SFLOAT; @@ -2543,7 +2543,7 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT; tf.array_layers = rb->view_count; // create a layer for every view - if (rb->msaa != RS::VIEWPORT_MSAA_DISABLED) { + if (rb->msaa_3d != RS::VIEWPORT_MSAA_DISABLED) { tf.usage_bits |= RD::TEXTURE_USAGE_CAN_COPY_TO_BIT | RD::TEXTURE_USAGE_STORAGE_BIT; } else { tf.usage_bits |= RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h index 22e9ead243..8e59b21aa8 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h @@ -456,7 +456,7 @@ private: int width = 0; int height = 0; float fsr_sharpness = 0.2f; - RS::ViewportMSAA msaa = RS::VIEWPORT_MSAA_DISABLED; + RS::ViewportMSAA msaa_3d = RS::VIEWPORT_MSAA_DISABLED; RS::ViewportScreenSpaceAA screen_space_aa = RS::VIEWPORT_SCREEN_SPACE_AA_DISABLED; bool use_taa = false; bool use_debanding = false; @@ -1167,23 +1167,51 @@ public: virtual void decals_set_filter(RS::DecalFilter p_filter) override; virtual void light_projectors_set_filter(RS::LightProjectorFilter p_filter) override; - _FORCE_INLINE_ RS::ShadowQuality shadows_quality_get() const { return shadows_quality; } - _FORCE_INLINE_ RS::ShadowQuality directional_shadow_quality_get() const { return directional_shadow_quality; } - _FORCE_INLINE_ float shadows_quality_radius_get() const { return shadows_quality_radius; } - _FORCE_INLINE_ float directional_shadow_quality_radius_get() const { return directional_shadow_quality_radius; } + _FORCE_INLINE_ RS::ShadowQuality shadows_quality_get() const { + return shadows_quality; + } + _FORCE_INLINE_ RS::ShadowQuality directional_shadow_quality_get() const { + return directional_shadow_quality; + } + _FORCE_INLINE_ float shadows_quality_radius_get() const { + return shadows_quality_radius; + } + _FORCE_INLINE_ float directional_shadow_quality_radius_get() const { + return directional_shadow_quality_radius; + } - _FORCE_INLINE_ float *directional_penumbra_shadow_kernel_get() { return directional_penumbra_shadow_kernel; } - _FORCE_INLINE_ float *directional_soft_shadow_kernel_get() { return directional_soft_shadow_kernel; } - _FORCE_INLINE_ float *penumbra_shadow_kernel_get() { return penumbra_shadow_kernel; } - _FORCE_INLINE_ float *soft_shadow_kernel_get() { return soft_shadow_kernel; } + _FORCE_INLINE_ float *directional_penumbra_shadow_kernel_get() { + return directional_penumbra_shadow_kernel; + } + _FORCE_INLINE_ float *directional_soft_shadow_kernel_get() { + return directional_soft_shadow_kernel; + } + _FORCE_INLINE_ float *penumbra_shadow_kernel_get() { + return penumbra_shadow_kernel; + } + _FORCE_INLINE_ float *soft_shadow_kernel_get() { + return soft_shadow_kernel; + } - _FORCE_INLINE_ int directional_penumbra_shadow_samples_get() const { return directional_penumbra_shadow_samples; } - _FORCE_INLINE_ int directional_soft_shadow_samples_get() const { return directional_soft_shadow_samples; } - _FORCE_INLINE_ int penumbra_shadow_samples_get() const { return penumbra_shadow_samples; } - _FORCE_INLINE_ int soft_shadow_samples_get() const { return soft_shadow_samples; } + _FORCE_INLINE_ int directional_penumbra_shadow_samples_get() const { + return directional_penumbra_shadow_samples; + } + _FORCE_INLINE_ int directional_soft_shadow_samples_get() const { + return directional_soft_shadow_samples; + } + _FORCE_INLINE_ int penumbra_shadow_samples_get() const { + return penumbra_shadow_samples; + } + _FORCE_INLINE_ int soft_shadow_samples_get() const { + return soft_shadow_samples; + } - _FORCE_INLINE_ RS::LightProjectorFilter light_projectors_get_filter() const { return light_projectors_filter; } - _FORCE_INLINE_ RS::DecalFilter decals_get_filter() const { return decals_filter; } + _FORCE_INLINE_ RS::LightProjectorFilter light_projectors_get_filter() const { + return light_projectors_filter; + } + _FORCE_INLINE_ RS::DecalFilter decals_get_filter() const { + return decals_filter; + } int get_roughness_layers() const; bool is_using_radiance_cubemap_array() const; diff --git a/servers/rendering/renderer_rd/shader_rd.cpp b/servers/rendering/renderer_rd/shader_rd.cpp index c9b6d09d4c..0f2dea6fe9 100644 --- a/servers/rendering/renderer_rd/shader_rd.cpp +++ b/servers/rendering/renderer_rd/shader_rd.cpp @@ -380,7 +380,7 @@ static const uint32_t cache_file_version = 2; bool ShaderRD::_load_from_cache(Version *p_version) { String sha1 = _version_get_sha1(p_version); - String path = shader_cache_dir.plus_file(name).plus_file(base_sha256).plus_file(sha1) + ".cache"; + String path = shader_cache_dir.path_join(name).path_join(base_sha256).path_join(sha1) + ".cache"; Ref<FileAccess> f = FileAccess::open(path, FileAccess::READ); if (f.is_null()) { @@ -443,7 +443,7 @@ bool ShaderRD::_load_from_cache(Version *p_version) { void ShaderRD::_save_to_cache(Version *p_version) { String sha1 = _version_get_sha1(p_version); - String path = shader_cache_dir.plus_file(name).plus_file(base_sha256).plus_file(sha1) + ".cache"; + String path = shader_cache_dir.path_join(name).path_join(base_sha256).path_join(sha1) + ".cache"; Ref<FileAccess> f = FileAccess::open(path, FileAccess::WRITE); ERR_FAIL_COND(f.is_null()); diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp index 84427e1c93..ce19187071 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp @@ -2121,6 +2121,10 @@ void TextureStorage::_clear_render_target(RenderTarget *rt) { RD::get_singleton()->free(rt->color); } + if (rt->color_multisample.is_valid()) { + RD::get_singleton()->free(rt->color_multisample); + } + if (rt->backbuffer.is_valid()) { RD::get_singleton()->free(rt->backbuffer); rt->backbuffer = RID(); @@ -2132,6 +2136,7 @@ void TextureStorage::_clear_render_target(RenderTarget *rt) { rt->framebuffer = RID(); rt->color = RID(); + rt->color_multisample = RID(); } void TextureStorage::_update_render_target(RenderTarget *rt) { @@ -2153,30 +2158,50 @@ void TextureStorage::_update_render_target(RenderTarget *rt) { rt->color_format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB; rt->image_format = rt->is_transparent ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8; - RD::TextureFormat rd_format; + RD::TextureFormat rd_color_attachment_format; RD::TextureView rd_view; { //attempt register - rd_format.format = rt->color_format; - rd_format.width = rt->size.width; - rd_format.height = rt->size.height; - rd_format.depth = 1; - rd_format.array_layers = rt->view_count; // for stereo we create two (or more) layers, need to see if we can make fallback work like this too if we don't have multiview - rd_format.mipmaps = 1; - if (rd_format.array_layers > 1) { // why are we not using rt->texture_type ?? - rd_format.texture_type = RD::TEXTURE_TYPE_2D_ARRAY; + rd_color_attachment_format.format = rt->color_format; + rd_color_attachment_format.width = rt->size.width; + rd_color_attachment_format.height = rt->size.height; + rd_color_attachment_format.depth = 1; + rd_color_attachment_format.array_layers = rt->view_count; // for stereo we create two (or more) layers, need to see if we can make fallback work like this too if we don't have multiview + rd_color_attachment_format.mipmaps = 1; + if (rd_color_attachment_format.array_layers > 1) { // why are we not using rt->texture_type ?? + rd_color_attachment_format.texture_type = RD::TEXTURE_TYPE_2D_ARRAY; } else { - rd_format.texture_type = RD::TEXTURE_TYPE_2D; + rd_color_attachment_format.texture_type = RD::TEXTURE_TYPE_2D; + } + rd_color_attachment_format.samples = RD::TEXTURE_SAMPLES_1; + rd_color_attachment_format.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT; + rd_color_attachment_format.shareable_formats.push_back(rt->color_format); + rd_color_attachment_format.shareable_formats.push_back(rt->color_format_srgb); + if (rt->msaa != RS::VIEWPORT_MSAA_DISABLED) { + rd_color_attachment_format.is_resolve_buffer = true; } - rd_format.samples = RD::TEXTURE_SAMPLES_1; - rd_format.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT; - rd_format.shareable_formats.push_back(rt->color_format); - rd_format.shareable_formats.push_back(rt->color_format_srgb); } - rt->color = RD::get_singleton()->texture_create(rd_format, rd_view); + rt->color = RD::get_singleton()->texture_create(rd_color_attachment_format, rd_view); ERR_FAIL_COND(rt->color.is_null()); Vector<RID> fb_textures; + + if (rt->msaa != RS::VIEWPORT_MSAA_DISABLED) { + // Use the texture format of the color attachment for the multisample color attachment. + RD::TextureFormat rd_color_multisample_format = rd_color_attachment_format; + const RD::TextureSamples texture_samples[RS::VIEWPORT_MSAA_MAX] = { + RD::TEXTURE_SAMPLES_1, + RD::TEXTURE_SAMPLES_2, + RD::TEXTURE_SAMPLES_4, + RD::TEXTURE_SAMPLES_8, + }; + rd_color_multisample_format.samples = texture_samples[rt->msaa]; + RD::TextureView rd_view_multisample; + rd_color_multisample_format.is_resolve_buffer = false; + rt->color_multisample = RD::get_singleton()->texture_create(rd_color_multisample_format, rd_view_multisample); + fb_textures.push_back(rt->color_multisample); + ERR_FAIL_COND(rt->color_multisample.is_null()); + } fb_textures.push_back(rt->color); rt->framebuffer = RD::get_singleton()->framebuffer_create(fb_textures, RenderingDevice::INVALID_ID, rt->view_count); if (rt->framebuffer.is_null()) { @@ -2335,6 +2360,17 @@ void TextureStorage::render_target_set_as_unused(RID p_render_target) { rt->was_used = false; } +void TextureStorage::render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) { + RenderTarget *rt = render_target_owner.get_or_null(p_render_target); + ERR_FAIL_COND(!rt); + if (p_msaa == rt->msaa) { + return; + } + + rt->msaa = p_msaa; + _update_render_target(rt); +} + Size2 TextureStorage::render_target_get_size(RID p_render_target) { RenderTarget *rt = render_target_owner.get_or_null(p_render_target); ERR_FAIL_COND_V(!rt, Size2()); diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.h b/servers/rendering/renderer_rd/storage_rd/texture_storage.h index 682c951f63..25d355d878 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.h @@ -254,6 +254,9 @@ private: uint32_t view_count; RID framebuffer; RID color; + RID color_multisample; // Needed when MSAA is enabled. + + RS::ViewportMSAA msaa = RS::VIEWPORT_MSAA_DISABLED; //used for retrieving from CPU RD::DataFormat color_format = RD::DATA_FORMAT_R4G4_UNORM_PACK8; @@ -556,6 +559,7 @@ public: virtual void render_target_set_direct_to_screen(RID p_render_target, bool p_direct_to_screen) override; virtual bool render_target_was_used(RID p_render_target) override; virtual void render_target_set_as_unused(RID p_render_target) override; + virtual void render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) override; void render_target_copy_to_back_buffer(RID p_render_target, const Rect2i &p_region, bool p_gen_mipmaps); void render_target_clear_back_buffer(RID p_render_target, const Rect2i &p_region, const Color &p_color); diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index bfb81925bc..b6f515b223 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -177,7 +177,7 @@ void RendererViewport::_configure_3d_render_buffers(Viewport *p_viewport) { // to compensate for the loss of sharpness. const float texture_mipmap_bias = log2f(MIN(scaling_3d_scale, 1.0)) + p_viewport->texture_mipmap_bias; - RSG::scene->render_buffers_configure(p_viewport->render_buffers, p_viewport->render_target, render_width, render_height, width, height, p_viewport->fsr_sharpness, texture_mipmap_bias, p_viewport->msaa, p_viewport->screen_space_aa, p_viewport->use_taa, p_viewport->use_debanding, p_viewport->get_view_count()); + RSG::scene->render_buffers_configure(p_viewport->render_buffers, p_viewport->render_target, render_width, render_height, width, height, p_viewport->fsr_sharpness, texture_mipmap_bias, p_viewport->msaa_3d, p_viewport->screen_space_aa, p_viewport->use_taa, p_viewport->use_debanding, p_viewport->get_view_count()); } } } @@ -1076,14 +1076,25 @@ void RendererViewport::viewport_set_positional_shadow_atlas_quadrant_subdivision RSG::scene->shadow_atlas_set_quadrant_subdivision(viewport->shadow_atlas, p_quadrant, p_subdiv); } -void RendererViewport::viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa) { +void RendererViewport::viewport_set_msaa_2d(RID p_viewport, RS::ViewportMSAA p_msaa) { Viewport *viewport = viewport_owner.get_or_null(p_viewport); ERR_FAIL_COND(!viewport); - if (viewport->msaa == p_msaa) { + if (viewport->msaa_2d == p_msaa) { return; } - viewport->msaa = p_msaa; + viewport->msaa_2d = p_msaa; + RSG::texture_storage->render_target_set_msaa(viewport->render_target, p_msaa); +} + +void RendererViewport::viewport_set_msaa_3d(RID p_viewport, RS::ViewportMSAA p_msaa) { + Viewport *viewport = viewport_owner.get_or_null(p_viewport); + ERR_FAIL_COND(!viewport); + + if (viewport->msaa_3d == p_msaa) { + return; + } + viewport->msaa_3d = p_msaa; _configure_3d_render_buffers(viewport); } diff --git a/servers/rendering/renderer_viewport.h b/servers/rendering/renderer_viewport.h index ab4893a908..f64b2a986f 100644 --- a/servers/rendering/renderer_viewport.h +++ b/servers/rendering/renderer_viewport.h @@ -66,7 +66,8 @@ public: RID render_target_texture; RID render_buffers; - RS::ViewportMSAA msaa = RenderingServer::VIEWPORT_MSAA_DISABLED; + RS::ViewportMSAA msaa_2d = RenderingServer::VIEWPORT_MSAA_DISABLED; + RS::ViewportMSAA msaa_3d = RenderingServer::VIEWPORT_MSAA_DISABLED; RS::ViewportScreenSpaceAA screen_space_aa = RenderingServer::VIEWPORT_SCREEN_SPACE_AA_DISABLED; bool use_taa = false; bool use_debanding = false; @@ -157,7 +158,6 @@ public: measure_render_time = false; debug_draw = RS::VIEWPORT_DEBUG_DRAW_DISABLED; - msaa = RS::VIEWPORT_MSAA_DISABLED; screen_space_aa = RS::VIEWPORT_SCREEN_SPACE_AA_DISABLED; use_debanding = false; use_occlusion_culling = false; @@ -250,7 +250,8 @@ public: void viewport_set_positional_shadow_atlas_size(RID p_viewport, int p_size, bool p_16_bits = true); void viewport_set_positional_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv); - void viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa); + void viewport_set_msaa_2d(RID p_viewport, RS::ViewportMSAA p_msaa); + void viewport_set_msaa_3d(RID p_viewport, RS::ViewportMSAA p_msaa); void viewport_set_screen_space_aa(RID p_viewport, RS::ViewportScreenSpaceAA p_mode); void viewport_set_use_taa(RID p_viewport, bool p_use_taa); void viewport_set_use_debanding(RID p_viewport, bool p_use_debanding); diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index 6dadcab383..276ba8f247 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -462,6 +462,7 @@ public: TextureSamples samples; uint32_t usage_bits; Vector<DataFormat> shareable_formats; + bool is_resolve_buffer = false; TextureFormat() { format = DATA_FORMAT_R8_UNORM; diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h index 9b174d5879..ba70f02ca5 100644 --- a/servers/rendering/rendering_server_default.h +++ b/servers/rendering/rendering_server_default.h @@ -619,7 +619,8 @@ public: FUNC3(viewport_set_positional_shadow_atlas_size, RID, int, bool) FUNC3(viewport_set_sdf_oversize_and_scale, RID, ViewportSDFOversize, ViewportSDFScale) FUNC3(viewport_set_positional_shadow_atlas_quadrant_subdivision, RID, int, int) - FUNC2(viewport_set_msaa, RID, ViewportMSAA) + FUNC2(viewport_set_msaa_2d, RID, ViewportMSAA) + FUNC2(viewport_set_msaa_3d, RID, ViewportMSAA) FUNC2(viewport_set_screen_space_aa, RID, ViewportScreenSpaceAA) FUNC2(viewport_set_use_taa, RID, bool) FUNC2(viewport_set_use_debanding, RID, bool) diff --git a/servers/rendering/storage/texture_storage.h b/servers/rendering/storage/texture_storage.h index 982ab4a958..08ff88d4a5 100644 --- a/servers/rendering/storage/texture_storage.h +++ b/servers/rendering/storage/texture_storage.h @@ -133,6 +133,7 @@ public: virtual void render_target_set_direct_to_screen(RID p_render_target, bool p_direct_to_screen) = 0; virtual bool render_target_was_used(RID p_render_target) = 0; virtual void render_target_set_as_unused(RID p_render_target) = 0; + virtual void render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) = 0; virtual void render_target_request_clear(RID p_render_target, const Color &p_clear_color) = 0; virtual bool render_target_is_clear_requested(RID p_render_target) = 0; diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 30b6faa360..3e850a9798 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -2204,7 +2204,8 @@ void RenderingServer::_bind_methods() { ClassDB::bind_method(D_METHOD("viewport_set_positional_shadow_atlas_size", "viewport", "size", "use_16_bits"), &RenderingServer::viewport_set_positional_shadow_atlas_size, DEFVAL(false)); ClassDB::bind_method(D_METHOD("viewport_set_positional_shadow_atlas_quadrant_subdivision", "viewport", "quadrant", "subdivision"), &RenderingServer::viewport_set_positional_shadow_atlas_quadrant_subdivision); - ClassDB::bind_method(D_METHOD("viewport_set_msaa", "viewport", "msaa"), &RenderingServer::viewport_set_msaa); + ClassDB::bind_method(D_METHOD("viewport_set_msaa_3d", "viewport", "msaa"), &RenderingServer::viewport_set_msaa_3d); + ClassDB::bind_method(D_METHOD("viewport_set_msaa_2d", "viewport", "msaa"), &RenderingServer::viewport_set_msaa_2d); ClassDB::bind_method(D_METHOD("viewport_set_screen_space_aa", "viewport", "mode"), &RenderingServer::viewport_set_screen_space_aa); ClassDB::bind_method(D_METHOD("viewport_set_use_taa", "viewport", "enable"), &RenderingServer::viewport_set_use_taa); ClassDB::bind_method(D_METHOD("viewport_set_use_debanding", "viewport", "enable"), &RenderingServer::viewport_set_use_debanding); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 56295a2c5f..efa8a24325 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -874,7 +874,8 @@ public: VIEWPORT_MSAA_MAX, }; - virtual void viewport_set_msaa(RID p_viewport, ViewportMSAA p_msaa) = 0; + virtual void viewport_set_msaa_3d(RID p_viewport, ViewportMSAA p_msaa) = 0; + virtual void viewport_set_msaa_2d(RID p_viewport, ViewportMSAA p_msaa) = 0; enum ViewportScreenSpaceAA { VIEWPORT_SCREEN_SPACE_AA_DISABLED, diff --git a/tests/core/io/test_config_file.h b/tests/core/io/test_config_file.h index 355aca479e..666719febb 100644 --- a/tests/core/io/test_config_file.h +++ b/tests/core/io/test_config_file.h @@ -127,7 +127,7 @@ TEST_CASE("[ConfigFile] Saving file") { config_file.set_value("quoted", "a=b", 7); #ifdef WINDOWS_ENABLED - const String config_path = OS::get_singleton()->get_environment("TEMP").plus_file("config.ini"); + const String config_path = OS::get_singleton()->get_environment("TEMP").path_join("config.ini"); #else const String config_path = "/tmp/config.ini"; #endif diff --git a/tests/core/io/test_image.h b/tests/core/io/test_image.h index 36e6b83bfd..38b616cda0 100644 --- a/tests/core/io/test_image.h +++ b/tests/core/io/test_image.h @@ -78,8 +78,8 @@ TEST_CASE("[Image] Instantiation") { TEST_CASE("[Image] Saving and loading") { Ref<Image> image = memnew(Image(4, 4, false, Image::FORMAT_RGBA8)); - const String save_path_png = OS::get_singleton()->get_cache_path().plus_file("image.png"); - const String save_path_exr = OS::get_singleton()->get_cache_path().plus_file("image.exr"); + const String save_path_png = OS::get_singleton()->get_cache_path().path_join("image.png"); + const String save_path_exr = OS::get_singleton()->get_cache_path().path_join("image.exr"); // Save PNG Error err; diff --git a/tests/core/io/test_pck_packer.h b/tests/core/io/test_pck_packer.h index d21fbdaf50..8d0e5c402a 100644 --- a/tests/core/io/test_pck_packer.h +++ b/tests/core/io/test_pck_packer.h @@ -42,7 +42,7 @@ namespace TestPCKPacker { TEST_CASE("[PCKPacker] Pack an empty PCK file") { PCKPacker pck_packer; - const String output_pck_path = OS::get_singleton()->get_cache_path().plus_file("output_empty.pck"); + const String output_pck_path = OS::get_singleton()->get_cache_path().path_join("output_empty.pck"); CHECK_MESSAGE( pck_packer.pck_start(output_pck_path) == OK, "Starting a PCK file should return an OK error code."); @@ -66,7 +66,7 @@ TEST_CASE("[PCKPacker] Pack an empty PCK file") { TEST_CASE("[PCKPacker] Pack empty with zero alignment invalid") { PCKPacker pck_packer; - const String output_pck_path = OS::get_singleton()->get_cache_path().plus_file("output_empty.pck"); + const String output_pck_path = OS::get_singleton()->get_cache_path().path_join("output_empty.pck"); ERR_PRINT_OFF; CHECK_MESSAGE(pck_packer.pck_start(output_pck_path, 0) != OK, "PCK with zero alignment should fail."); ERR_PRINT_ON; @@ -74,7 +74,7 @@ TEST_CASE("[PCKPacker] Pack empty with zero alignment invalid") { TEST_CASE("[PCKPacker] Pack empty with invalid key") { PCKPacker pck_packer; - const String output_pck_path = OS::get_singleton()->get_cache_path().plus_file("output_empty.pck"); + const String output_pck_path = OS::get_singleton()->get_cache_path().path_join("output_empty.pck"); ERR_PRINT_OFF; CHECK_MESSAGE(pck_packer.pck_start(output_pck_path, 32, "") != OK, "PCK with invalid key should fail."); ERR_PRINT_ON; @@ -82,7 +82,7 @@ TEST_CASE("[PCKPacker] Pack empty with invalid key") { TEST_CASE("[PCKPacker] Pack a PCK file with some files and directories") { PCKPacker pck_packer; - const String output_pck_path = OS::get_singleton()->get_cache_path().plus_file("output_with_files.pck"); + const String output_pck_path = OS::get_singleton()->get_cache_path().path_join("output_with_files.pck"); CHECK_MESSAGE( pck_packer.pck_start(output_pck_path) == OK, "Starting a PCK file should return an OK error code."); @@ -90,16 +90,16 @@ TEST_CASE("[PCKPacker] Pack a PCK file with some files and directories") { const String base_dir = OS::get_singleton()->get_executable_path().get_base_dir(); CHECK_MESSAGE( - pck_packer.add_file("version.py", base_dir.plus_file("../version.py"), "version.py") == OK, + pck_packer.add_file("version.py", base_dir.path_join("../version.py"), "version.py") == OK, "Adding a file to the PCK should return an OK error code."); CHECK_MESSAGE( - pck_packer.add_file("some/directories with spaces/to/create/icon.png", base_dir.plus_file("../icon.png")) == OK, + pck_packer.add_file("some/directories with spaces/to/create/icon.png", base_dir.path_join("../icon.png")) == OK, "Adding a file to a new subdirectory in the PCK should return an OK error code."); CHECK_MESSAGE( - pck_packer.add_file("some/directories with spaces/to/create/icon.svg", base_dir.plus_file("../icon.svg")) == OK, + pck_packer.add_file("some/directories with spaces/to/create/icon.svg", base_dir.path_join("../icon.svg")) == OK, "Adding a file to an existing subdirectory in the PCK should return an OK error code."); CHECK_MESSAGE( - pck_packer.add_file("some/directories with spaces/to/create/icon.png", base_dir.plus_file("../logo.png")) == OK, + pck_packer.add_file("some/directories with spaces/to/create/icon.png", base_dir.path_join("../logo.png")) == OK, "Overriding a non-flushed file to an existing subdirectory in the PCK should return an OK error code."); CHECK_MESSAGE( pck_packer.flush() == OK, diff --git a/tests/core/io/test_resource.h b/tests/core/io/test_resource.h index c880ca7d2a..2457e06ade 100644 --- a/tests/core/io/test_resource.h +++ b/tests/core/io/test_resource.h @@ -74,8 +74,8 @@ TEST_CASE("[Resource] Saving and loading") { Ref<Resource> child_resource = memnew(Resource); child_resource->set_name("I'm a child resource"); resource->set_meta("other_resource", child_resource); - const String save_path_binary = OS::get_singleton()->get_cache_path().plus_file("resource.res"); - const String save_path_text = OS::get_singleton()->get_cache_path().plus_file("resource.tres"); + const String save_path_binary = OS::get_singleton()->get_cache_path().path_join("resource.res"); + const String save_path_text = OS::get_singleton()->get_cache_path().path_join("resource.tres"); ResourceSaver::save(resource, save_path_binary); ResourceSaver::save(resource, save_path_text); diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h index 62d2051eee..d97da05c04 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -466,11 +466,6 @@ TEST_CASE("[String] String to float") { } } -TEST_CASE("[String] CamelCase to underscore") { - CHECK(String("TestTestStringGD").camelcase_to_underscore(false) == String("Test_Test_String_GD")); - CHECK(String("TestTestStringGD").camelcase_to_underscore(true) == String("test_test_string_gd")); -} - TEST_CASE("[String] Slicing") { String s = "Mars,Jupiter,Saturn,Uranus"; @@ -1096,8 +1091,36 @@ TEST_CASE("[String] IPVX address to string") { } TEST_CASE("[String] Capitalize against many strings") { - String input = "bytes2var"; - String output = "Bytes 2 Var"; + String input = "2D"; + String output = "2d"; + CHECK(input.capitalize() == output); + + input = "2d"; + output = "2d"; + CHECK(input.capitalize() == output); + + input = "2db"; + output = "2 Db"; + CHECK(input.capitalize() == output); + + input = "HTML5 Html5 html5 html_5"; + output = "Html 5 Html 5 Html 5 Html 5"; + CHECK(input.capitalize() == output); + + input = "Node2D Node2d NODE2D NODE_2D node_2d"; + output = "Node 2d Node 2d Node 2d Node 2d Node 2d"; + CHECK(input.capitalize() == output); + + input = "Node2DPosition"; + output = "Node 2d Position"; + CHECK(input.capitalize() == output); + + input = "Number2Digits"; + output = "Number 2 Digits"; + CHECK(input.capitalize() == output); + + input = "bytes2var"; + output = "Bytes 2 Var"; CHECK(input.capitalize() == output); input = "linear2db"; @@ -1112,10 +1135,6 @@ TEST_CASE("[String] Capitalize against many strings") { output = "Sha 256"; CHECK(input.capitalize() == output); - input = "2db"; - output = "2 Db"; - CHECK(input.capitalize() == output); - input = "PascalCase"; output = "Pascal Case"; CHECK(input.capitalize() == output); @@ -1153,6 +1172,50 @@ TEST_CASE("[String] Capitalize against many strings") { CHECK(input.capitalize() == output); } +struct StringCasesTestCase { + const char *input; + const char *camel_case; + const char *pascal_case; + const char *snake_case; +}; + +TEST_CASE("[String] Checking case conversion methods") { + StringCasesTestCase test_cases[] = { + /* clang-format off */ + { "2D", "2d", "2d", "2d" }, + { "2d", "2d", "2d", "2d" }, + { "2db", "2Db", "2Db", "2_db" }, + { "Vector3", "vector3", "Vector3", "vector_3" }, + { "sha256", "sha256", "Sha256", "sha_256" }, + { "Node2D", "node2d", "Node2d", "node_2d" }, + { "RichTextLabel", "richTextLabel", "RichTextLabel", "rich_text_label" }, + { "HTML5", "html5", "Html5", "html_5" }, + { "Node2DPosition", "node2dPosition", "Node2dPosition", "node_2d_position" }, + { "Number2Digits", "number2Digits", "Number2Digits", "number_2_digits" }, + { "get_property_list", "getPropertyList", "GetPropertyList", "get_property_list" }, + { "get_camera_2d", "getCamera2d", "GetCamera2d", "get_camera_2d" }, + { "_physics_process", "physicsProcess", "PhysicsProcess", "_physics_process" }, + { "bytes2var", "bytes2Var", "Bytes2Var", "bytes_2_var" }, + { "linear2db", "linear2Db", "Linear2Db", "linear_2_db" }, + { "sha256sum", "sha256Sum", "Sha256Sum", "sha_256_sum" }, + { "camelCase", "camelCase", "CamelCase", "camel_case" }, + { "PascalCase", "pascalCase", "PascalCase", "pascal_case" }, + { "snake_case", "snakeCase", "SnakeCase", "snake_case" }, + { "Test TEST test", "testTestTest", "TestTestTest", "test_test_test" }, + { nullptr, nullptr, nullptr, nullptr }, + /* clang-format on */ + }; + + int idx = 0; + while (test_cases[idx].input != nullptr) { + String input = test_cases[idx].input; + CHECK(input.to_camel_case() == test_cases[idx].camel_case); + CHECK(input.to_pascal_case() == test_cases[idx].pascal_case); + CHECK(input.to_snake_case() == test_cases[idx].snake_case); + idx++; + } +} + TEST_CASE("[String] Checking string is empty when it should be") { bool state = true; bool success; @@ -1359,7 +1422,7 @@ TEST_CASE("[String] Path functions") { CHECK(String(path[i]).get_file() == file[i]); CHECK(String(path[i]).is_absolute_path() == abs[i]); CHECK(String(path[i]).is_relative_path() != abs[i]); - CHECK(String(path[i]).simplify_path().get_base_dir().plus_file(file[i]) == String(path[i]).simplify_path()); + CHECK(String(path[i]).simplify_path().get_base_dir().path_join(file[i]) == String(path[i]).simplify_path()); } static const char *file_name[3] = { "test.tscn", "test://.xscn", "?tes*t.scn" }; @@ -1663,7 +1726,7 @@ TEST_CASE("[String] Variant ptr indexed set") { TEST_CASE("[Stress][String] Empty via ' == String()'") { for (int i = 0; i < 100000; ++i) { String str = "Hello World!"; - if (str.is_empty()) { + if (str == String()) { continue; } } diff --git a/tests/scene/test_audio_stream_wav.h b/tests/scene/test_audio_stream_wav.h index 92c524525c..cf369c115b 100644 --- a/tests/scene/test_audio_stream_wav.h +++ b/tests/scene/test_audio_stream_wav.h @@ -115,7 +115,7 @@ Vector<uint8_t> gen_pcm16_test(float wav_rate, int wav_count, bool stereo) { } void run_test(String file_name, AudioStreamWAV::Format data_format, bool stereo, float wav_rate, float wav_count) { - String save_path = OS::get_singleton()->get_cache_path().plus_file(file_name); + String save_path = OS::get_singleton()->get_cache_path().path_join(file_name); Vector<uint8_t> test_data; if (data_format == AudioStreamWAV::FORMAT_8_BITS) { @@ -200,7 +200,7 @@ TEST_CASE("[AudioStreamWAV] Alternate mix rate") { } TEST_CASE("[AudioStreamWAV] save_to_wav() adds '.wav' file extension automatically") { - String save_path = OS::get_singleton()->get_cache_path().plus_file("test_wav_extension"); + String save_path = OS::get_singleton()->get_cache_path().path_join("test_wav_extension"); Vector<uint8_t> test_data = gen_pcm8_test(WAV_RATE, WAV_COUNT, false); Ref<AudioStreamWAV> stream = memnew(AudioStreamWAV); stream->set_data(test_data); @@ -230,7 +230,7 @@ TEST_CASE("[AudioStreamWAV] Save empty file") { } TEST_CASE("[AudioStreamWAV] Saving IMA ADPCM is not supported") { - String save_path = OS::get_singleton()->get_cache_path().plus_file("test_adpcm.wav"); + String save_path = OS::get_singleton()->get_cache_path().path_join("test_adpcm.wav"); Ref<AudioStreamWAV> stream = memnew(AudioStreamWAV); stream->set_format(AudioStreamWAV::FORMAT_IMA_ADPCM); ERR_PRINT_OFF; diff --git a/tests/test_utils.cpp b/tests/test_utils.cpp index 11cb6398aa..ce12a30381 100644 --- a/tests/test_utils.cpp +++ b/tests/test_utils.cpp @@ -34,7 +34,7 @@ String TestUtils::get_data_path(const String &p_file) { String data_path = "../tests/data"; - return get_executable_dir().plus_file(data_path.plus_file(p_file)); + return get_executable_dir().path_join(data_path.path_join(p_file)); } String TestUtils::get_executable_dir() { |