diff options
281 files changed, 3307 insertions, 1719 deletions
diff --git a/.github/actions/godot-build/action.yml b/.github/actions/godot-build/action.yml index 93d6f076b7..ebc301dd0f 100644 --- a/.github/actions/godot-build/action.yml +++ b/.github/actions/godot-build/action.yml @@ -18,12 +18,12 @@ inputs: required: false scons-cache: description: The SCons cache path. - default: ${{ github.workspace }}/.scons-cache/ + default: ${{ github.workspace }}/.scons_cache/ scons-cache-limit: description: The SCons cache size limit. # actions/cache has 10 GiB limit, and GitHub runners have a 14 GiB disk. # Limit to 7 GiB to avoid having the extracted cache fill the disk. - default: 7168 + default: 7 runs: using: composite @@ -32,10 +32,8 @@ runs: shell: sh env: SCONSFLAGS: ${{ inputs.sconsflags }} - SCONS_CACHE: ${{ inputs.scons-cache }} - SCONS_CACHE_LIMIT: ${{ inputs.scons-cache-limit }} run: | - echo "Building with flags:" platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }} + echo "Building with flags:" platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }} "cache_path=${{ inputs.scons-cache }}" cache_limit=${{ inputs.scons-cache-limit }} if [ "${{ inputs.target }}" != "editor" ]; then # Ensure we don't include editor code in export template builds. @@ -49,5 +47,5 @@ runs: export BUILD_NAME="gh" fi - scons platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }} + scons platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }} "cache_path=${{ inputs.scons-cache }}" cache_limit=${{ inputs.scons-cache-limit }} ls -l bin/ diff --git a/.github/actions/godot-cache-restore/action.yml b/.github/actions/godot-cache-restore/action.yml index 7abec20a28..e2a1b97019 100644 --- a/.github/actions/godot-cache-restore/action.yml +++ b/.github/actions/godot-cache-restore/action.yml @@ -6,7 +6,7 @@ inputs: default: ${{ github.job }} scons-cache: description: The SCons cache path. - default: ${{ github.workspace }}/.scons-cache/ + default: ${{ github.workspace }}/.scons_cache/ runs: using: composite @@ -29,7 +29,6 @@ runs: # 4. A partial match for the same base branch only (not ideal, matches any PR with the same base branch). restore-keys: | - ${{ inputs.cache-name }}-${{ env.GODOT_BASE_BRANCH }}-${{ github.ref }}-${{ github.sha }} ${{ inputs.cache-name }}-${{ env.GODOT_BASE_BRANCH }}-${{ github.ref }} ${{ inputs.cache-name }}-${{ env.GODOT_BASE_BRANCH }}-refs/heads/${{ env.GODOT_BASE_BRANCH }} ${{ inputs.cache-name }}-${{ env.GODOT_BASE_BRANCH }} diff --git a/.github/actions/godot-cache-save/action.yml b/.github/actions/godot-cache-save/action.yml index df877cec67..42aa836406 100644 --- a/.github/actions/godot-cache-save/action.yml +++ b/.github/actions/godot-cache-save/action.yml @@ -6,7 +6,7 @@ inputs: default: ${{ github.job }} scons-cache: description: The SCons cache path. - default: ${{ github.workspace }}/.scons-cache/ + default: ${{ github.workspace }}/.scons_cache/ runs: using: composite diff --git a/.github/actions/godot-deps/action.yml b/.github/actions/godot-deps/action.yml index eb9bdef1e7..bd9a1f55ed 100644 --- a/.github/actions/godot-deps/action.yml +++ b/.github/actions/godot-deps/action.yml @@ -27,6 +27,5 @@ runs: shell: bash run: | python -c "import sys; print(sys.version)" - python -m pip install wheel python -m pip install scons==${{ inputs.scons-version }} scons --version diff --git a/.github/workflows/godot_cpp_test.yml b/.github/workflows/godot_cpp_test.yml index dc82a7cb3c..af99a4b035 100644 --- a/.github/workflows/godot_cpp_test.yml +++ b/.github/workflows/godot_cpp_test.yml @@ -52,9 +52,6 @@ jobs: # continue-on-error: true - name: Build godot-cpp test extension - env: # Keep synced with godot-build. - SCONS_CACHE: ${{ github.workspace }}/.scons-cache/ - SCONS_CACHE_LIMIT: 7168 run: scons --directory=./godot-cpp/test target=template_debug dev_build=yes verbose=yes # - name: Save Godot build cache diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index cf653caa3d..bd4e2856e3 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -17,8 +17,8 @@ concurrency: jobs: build-linux: - # If unspecified, stay one LTS before latest to increase portability of Linux artifacts. - runs-on: ${{ matrix.os || 'ubuntu-22.04' }} + # Stay one LTS before latest to increase portability of Linux artifacts. + runs-on: ubuntu-22.04 name: ${{ matrix.name }} strategy: fail-fast: false @@ -61,8 +61,6 @@ jobs: artifact: false # Test our oldest supported SCons/Python versions on one arbitrary editor build. legacy-scons: true - # Python 3.6 unavailable on 22.04. - os: ubuntu-20.04 - name: Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld) cache-name: linux-editor-thread-sanitizer @@ -132,8 +130,8 @@ jobs: uses: ./.github/actions/godot-deps with: # Sync with Ensure*Version in SConstruct. - python-version: 3.6 - scons-version: 3.1.2 + python-version: 3.8 + scons-version: 4.0 - name: Setup GCC problem matcher uses: ammaraskar/gcc-problem-matcher@master diff --git a/.gitignore b/.gitignore index 32a43b8c63..f72ea1ac51 100644 --- a/.gitignore +++ b/.gitignore @@ -36,8 +36,8 @@ compile_commands.json platform/windows/godot_res.res # Ninja build files -build.ninja -.ninja +*.ninja +.ninja/ run_ninja_env.bat # Generated by Godot binary @@ -77,6 +77,9 @@ venv __pycache__/ *.pyc +# Python modules +.*_cache/ + # Documentation doc/_build/ @@ -164,9 +167,6 @@ gmon.out # Kdevelop *.kdev4 -# Mypy -.mypy_cache - # Qt Creator *.config *.creator diff --git a/SConstruct b/SConstruct index ee34d421e0..7c7d3d25a0 100644 --- a/SConstruct +++ b/SConstruct @@ -1,8 +1,8 @@ #!/usr/bin/env python from misc.utility.scons_hints import * -EnsureSConsVersion(3, 1, 2) -EnsurePythonVersion(3, 6) +EnsureSConsVersion(4, 0) +EnsurePythonVersion(3, 8) # System import atexit @@ -59,7 +59,7 @@ import glsl_builders import methods import scu_builders from methods import print_error, print_warning -from platform_methods import architecture_aliases, architectures +from platform_methods import architecture_aliases, architectures, compatibility_platform_aliases if ARGUMENTS.get("target", "editor") == "editor": _helper_module("editor.editor_builders", "editor/editor_builders.py") @@ -271,6 +271,8 @@ opts.Add(BoolVariable("scu_build", "Use single compilation unit build", False)) opts.Add("scu_limit", "Max includes per SCU file when using scu_build (determines RAM use)", "0") opts.Add(BoolVariable("engine_update_check", "Enable engine update checks in the Project Manager", True)) opts.Add(BoolVariable("steamapi", "Enable minimal SteamAPI integration for usage time tracking (editor only)", False)) +opts.Add("cache_path", "Path to a directory where SCons cache files will be stored. No value disables the cache.", "") +opts.Add("cache_limit", "Max size (in GiB) for the SCons cache. 0 means no limit.", "0") # Thirdparty libraries opts.Add(BoolVariable("builtin_brotli", "Use the built-in Brotli library", True)) @@ -321,6 +323,9 @@ opts.Add("rcflags", "Custom flags for Windows resource compiler") # in following code (especially platform and custom_modules). opts.Update(env) +# Setup caching logic early to catch everything. +methods.prepare_cache(env) + # Copy custom environment variables if set. if env["import_env_vars"]: for env_var in str(env["import_env_vars"]).split(","): @@ -350,27 +355,18 @@ if env["platform"] == "": if env["platform"] != "": print(f'Automatically detected platform: {env["platform"]}') -if env["platform"] == "osx": - # Deprecated alias kept for compatibility. - print_warning('Platform "osx" has been renamed to "macos" in Godot 4. Building for platform "macos".') - env["platform"] = "macos" - -if env["platform"] == "iphone": - # Deprecated alias kept for compatibility. - print_warning('Platform "iphone" has been renamed to "ios" in Godot 4. Building for platform "ios".') - env["platform"] = "ios" - -if env["platform"] in ["linux", "bsd", "x11"]: - if env["platform"] == "x11": - # Deprecated alias kept for compatibility. - print_warning('Platform "x11" has been renamed to "linuxbsd" in Godot 4. Building for platform "linuxbsd".') - # Alias for convenience. - env["platform"] = "linuxbsd" +# Deprecated aliases kept for compatibility. +if env["platform"] in compatibility_platform_aliases: + alias = env["platform"] + platform = compatibility_platform_aliases[alias] + print_warning( + f'Platform "{alias}" has been renamed to "{platform}" in Godot 4. Building for platform "{platform}".' + ) + env["platform"] = platform -if env["platform"] == "javascript": - # Deprecated alias kept for compatibility. - print_warning('Platform "javascript" has been renamed to "web" in Godot 4. Building for platform "web".') - env["platform"] = "web" +# Alias for convenience. +if env["platform"] in ["linux", "bsd"]: + env["platform"] = "linuxbsd" if env["platform"] not in platform_list: text = "The following platforms are available:\n\t{}\n".format("\n\t".join(platform_list)) @@ -667,40 +663,32 @@ elif methods.using_gcc(env): "to switch to posix threads." ) Exit(255) - if env["debug_paths_relative"] and cc_version_major < 8: - print_warning("GCC < 8 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.") - env["debug_paths_relative"] = False elif methods.using_clang(env): # Apple LLVM versions differ from upstream LLVM version \o/, compare # in https://en.wikipedia.org/wiki/Xcode#Toolchain_versions - if env["platform"] == "macos" or env["platform"] == "ios": - vanilla = methods.is_vanilla_clang(env) - if vanilla and cc_version_major < 6: - print_error( - "Detected Clang version older than 6, which does not fully support " - "C++17. Supported versions are Clang 6 and later." - ) - Exit(255) - elif not vanilla and cc_version_major < 10: + if methods.is_apple_clang(env): + if cc_version_major < 10: print_error( "Detected Apple Clang version older than 10, which does not fully " "support C++17. Supported versions are Apple Clang 10 and later." ) Exit(255) - if env["debug_paths_relative"] and not vanilla and cc_version_major < 12: + elif env["debug_paths_relative"] and cc_version_major < 12: print_warning( "Apple Clang < 12 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option." ) env["debug_paths_relative"] = False - elif cc_version_major < 6: - print_error( - "Detected Clang version older than 6, which does not fully support " - "C++17. Supported versions are Clang 6 and later." - ) - Exit(255) - if env["debug_paths_relative"] and cc_version_major < 10: - print_warning("Clang < 10 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.") - env["debug_paths_relative"] = False + else: + if cc_version_major < 6: + print_error( + "Detected Clang version older than 6, which does not fully support " + "C++17. Supported versions are Clang 6 and later." + ) + Exit(255) + elif env["debug_paths_relative"] and cc_version_major < 10: + print_warning("Clang < 10 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.") + env["debug_paths_relative"] = False + elif env.msvc: # Ensure latest minor builds of Visual Studio 2017/2019. # https://github.com/godotengine/godot/pull/94995#issuecomment-2336464574 @@ -764,7 +752,7 @@ else: project_path = Dir("#").abspath env.Append(CCFLAGS=[f"-ffile-prefix-map={project_path}=."]) else: - if methods.using_clang(env) and not methods.is_vanilla_clang(env): + if methods.is_apple_clang(env): # Apple Clang, its linker doesn't like -s. env.Append(LINKFLAGS=["-Wl,-S", "-Wl,-x", "-Wl,-dead_strip"]) else: @@ -1050,23 +1038,7 @@ GLSL_BUILDERS = { } env.Append(BUILDERS=GLSL_BUILDERS) -scons_cache_path = os.environ.get("SCONS_CACHE") -if scons_cache_path is not None: - CacheDir(scons_cache_path) - print("Scons cache enabled... (path: '" + scons_cache_path + "')") - -if env["vsproj"]: - env.vs_incs = [] - env.vs_srcs = [] - if env["compiledb"]: - if env.scons_version < (4, 0, 0): - # Generating the compilation DB (`compile_commands.json`) requires SCons 4.0.0 or later. - print_error( - "The `compiledb=yes` option requires SCons 4.0 or later, but your version is %s." % scons_raw_version - ) - Exit(255) - env.Tool("compilation_db") env.Alias("compiledb", env.CompilationDatabase()) @@ -1078,7 +1050,7 @@ if env["ninja"]: SetOption("experimental", "ninja") env["NINJA_FILE_NAME"] = env["ninja_file"] env["NINJA_DISABLE_AUTO_RUN"] = not env["ninja_auto_run"] - env.Tool("ninja", "build.ninja") + env.Tool("ninja", env["ninja_file"]) # Threads if env["threads"]: @@ -1140,7 +1112,7 @@ atexit.register(print_elapsed_time) def purge_flaky_files(): - paths_to_keep = ["build.ninja"] + paths_to_keep = [env["ninja_file"]] for build_failure in GetBuildFailures(): path = build_failure.node.path if os.path.isfile(path) and path not in paths_to_keep: @@ -1148,5 +1120,3 @@ def purge_flaky_files(): atexit.register(purge_flaky_files) - -methods.clean_cache(env) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 092177bc15..9b2efd89e1 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -194,7 +194,7 @@ String ProjectSettings::localize_path(const String &p_path) const { return cwd.replace_first(res_path, "res://"); } else { - int sep = path.rfind("/"); + int sep = path.rfind_char('/'); if (sep == -1) { return "res://" + path; } @@ -300,7 +300,7 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) { } { // Feature overrides. - int dot = p_name.operator String().find("."); + int dot = p_name.operator String().find_char('.'); if (dot != -1) { Vector<String> s = p_name.operator String().split("."); @@ -435,7 +435,7 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const { for (const _VCSort &E : vclist) { String prop_info_name = E.name; - int dot = prop_info_name.find("."); + int dot = prop_info_name.find_char('.'); if (dot != -1 && !custom_prop_info.has(prop_info_name)) { prop_info_name = prop_info_name.substr(0, dot); } @@ -1092,7 +1092,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust String category = E.name; String name = E.name; - int div = category.find("/"); + int div = category.find_char('/'); if (div < 0) { category = ""; @@ -1408,7 +1408,7 @@ void ProjectSettings::_add_builtin_input_map() { } Dictionary action; - action["deadzone"] = Variant(0.2f); + action["deadzone"] = Variant(InputMap::DEFAULT_DEADZONE); action["events"] = events; String action_name = "input/" + E.key; diff --git a/core/core_bind.compat.inc b/core/core_bind.compat.inc index 3e8ac3c5de..22c78623da 100644 --- a/core/core_bind.compat.inc +++ b/core/core_bind.compat.inc @@ -44,11 +44,16 @@ void Semaphore::_bind_compatibility_methods() { // OS +String OS::_read_string_from_stdin_bind_compat_91201() { + return read_string_from_stdin(1024); +} + Dictionary OS::_execute_with_pipe_bind_compat_94434(const String &p_path, const Vector<String> &p_arguments) { return execute_with_pipe(p_path, p_arguments, true); } void OS::_bind_compatibility_methods() { + ClassDB::bind_compatibility_method(D_METHOD("read_string_from_stdin"), &OS::_read_string_from_stdin_bind_compat_91201); ClassDB::bind_compatibility_method(D_METHOD("execute_with_pipe", "path", "arguments"), &OS::_execute_with_pipe_bind_compat_94434); } diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 967a7fba75..925551d933 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -308,8 +308,24 @@ Error OS::shell_show_in_file_manager(const String &p_path, bool p_open_folder) { return ::OS::get_singleton()->shell_show_in_file_manager(p_path, p_open_folder); } -String OS::read_string_from_stdin() { - return ::OS::get_singleton()->get_stdin_string(); +String OS::read_string_from_stdin(int64_t p_buffer_size) { + return ::OS::get_singleton()->get_stdin_string(p_buffer_size); +} + +PackedByteArray OS::read_buffer_from_stdin(int64_t p_buffer_size) { + return ::OS::get_singleton()->get_stdin_buffer(p_buffer_size); +} + +OS::StdHandleType OS::get_stdin_type() const { + return (OS::StdHandleType)::OS::get_singleton()->get_stdin_type(); +} + +OS::StdHandleType OS::get_stdout_type() const { + return (OS::StdHandleType)::OS::get_singleton()->get_stdout_type(); +} + +OS::StdHandleType OS::get_stderr_type() const { + return (OS::StdHandleType)::OS::get_singleton()->get_stderr_type(); } int OS::execute(const String &p_path, const Vector<String> &p_arguments, Array r_output, bool p_read_stderr, bool p_open_console) { @@ -633,7 +649,13 @@ void OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_system_font_path", "font_name", "weight", "stretch", "italic"), &OS::get_system_font_path, DEFVAL(400), DEFVAL(100), DEFVAL(false)); ClassDB::bind_method(D_METHOD("get_system_font_path_for_text", "font_name", "text", "locale", "script", "weight", "stretch", "italic"), &OS::get_system_font_path_for_text, DEFVAL(String()), DEFVAL(String()), DEFVAL(400), DEFVAL(100), DEFVAL(false)); ClassDB::bind_method(D_METHOD("get_executable_path"), &OS::get_executable_path); - ClassDB::bind_method(D_METHOD("read_string_from_stdin"), &OS::read_string_from_stdin); + + ClassDB::bind_method(D_METHOD("read_string_from_stdin", "buffer_size"), &OS::read_string_from_stdin); + ClassDB::bind_method(D_METHOD("read_buffer_from_stdin", "buffer_size"), &OS::read_buffer_from_stdin); + ClassDB::bind_method(D_METHOD("get_stdin_type"), &OS::get_stdin_type); + ClassDB::bind_method(D_METHOD("get_stdout_type"), &OS::get_stdout_type); + ClassDB::bind_method(D_METHOD("get_stderr_type"), &OS::get_stderr_type); + ClassDB::bind_method(D_METHOD("execute", "path", "arguments", "output", "read_stderr", "open_console"), &OS::execute, DEFVAL_ARRAY, DEFVAL(false), DEFVAL(false)); ClassDB::bind_method(D_METHOD("execute_with_pipe", "path", "arguments", "blocking"), &OS::execute_with_pipe, DEFVAL(true)); ClassDB::bind_method(D_METHOD("create_process", "path", "arguments", "open_console"), &OS::create_process, DEFVAL(false)); @@ -725,6 +747,12 @@ void OS::_bind_methods() { BIND_ENUM_CONSTANT(SYSTEM_DIR_MUSIC); BIND_ENUM_CONSTANT(SYSTEM_DIR_PICTURES); BIND_ENUM_CONSTANT(SYSTEM_DIR_RINGTONES); + + BIND_ENUM_CONSTANT(STD_HANDLE_INVALID); + BIND_ENUM_CONSTANT(STD_HANDLE_CONSOLE); + BIND_ENUM_CONSTANT(STD_HANDLE_FILE); + BIND_ENUM_CONSTANT(STD_HANDLE_PIPE); + BIND_ENUM_CONSTANT(STD_HANDLE_UNKNOWN); } ////// Geometry2D ////// diff --git a/core/core_bind.h b/core/core_bind.h index 3ae54017fe..d013e348bd 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -134,6 +134,7 @@ protected: #ifndef DISABLE_DEPRECATED Dictionary _execute_with_pipe_bind_compat_94434(const String &p_path, const Vector<String> &p_arguments); + String _read_string_from_stdin_bind_compat_91201(); static void _bind_compatibility_methods(); #endif @@ -148,6 +149,14 @@ public: PackedByteArray get_entropy(int p_bytes); String get_system_ca_certificates(); + enum StdHandleType { + STD_HANDLE_INVALID, + STD_HANDLE_CONSOLE, + STD_HANDLE_FILE, + STD_HANDLE_PIPE, + STD_HANDLE_UNKNOWN, + }; + virtual PackedStringArray get_connected_midi_inputs(); virtual void open_midi_inputs(); virtual void close_midi_inputs(); @@ -168,7 +177,13 @@ public: String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const; Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const; String get_executable_path() const; - String read_string_from_stdin(); + + String read_string_from_stdin(int64_t p_buffer_size = 1024); + PackedByteArray read_buffer_from_stdin(int64_t p_buffer_size = 1024); + StdHandleType get_stdin_type() const; + StdHandleType get_stdout_type() const; + StdHandleType get_stderr_type() const; + int execute(const String &p_path, const Vector<String> &p_arguments, Array r_output = ClassDB::default_array_arg, bool p_read_stderr = false, bool p_open_console = false); Dictionary execute_with_pipe(const String &p_path, const Vector<String> &p_arguments, bool p_blocking = true); int create_process(const String &p_path, const Vector<String> &p_arguments, bool p_open_console = false); @@ -644,6 +659,7 @@ VARIANT_BITFIELD_CAST(core_bind::ResourceSaver::SaverFlags); VARIANT_ENUM_CAST(core_bind::OS::RenderingDriver); VARIANT_ENUM_CAST(core_bind::OS::SystemDir); +VARIANT_ENUM_CAST(core_bind::OS::StdHandleType); VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyBooleanOperation); VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyJoinType); diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp index 6d2868cef2..a9f87ad825 100644 --- a/core/debugger/engine_debugger.cpp +++ b/core/debugger/engine_debugger.cpp @@ -163,7 +163,7 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, co for (int i = 0; i < p_breakpoints.size(); i++) { const String &bp = p_breakpoints[i]; - int sp = bp.rfind(":"); + int sp = bp.rfind_char(':'); ERR_CONTINUE_MSG(sp == -1, vformat("Invalid breakpoint: '%s', expected file:line format.", bp)); singleton_script_debugger->insert_breakpoint(bp.substr(sp + 1, bp.length()).to_int(), bp.substr(0, sp)); diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp index dc46ffc307..a5d807f66b 100644 --- a/core/debugger/local_debugger.cpp +++ b/core/debugger/local_debugger.cpp @@ -171,7 +171,7 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) { } else { String key_value = line.get_slicec(' ', 1); - int value_pos = key_value.find("="); + int value_pos = key_value.find_char('='); if (value_pos < 0) { print_line("Error: Invalid set format. Use: set key=value"); @@ -208,10 +208,10 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) { print_variables(members, values, variable_prefix); } else if (line.begins_with("p") || line.begins_with("print")) { - if (line.get_slice_count(" ") <= 1) { - print_line("Usage: print <expre>"); + if (line.find_char(' ') < 0) { + print_line("Usage: print <expression>"); } else { - String expr = line.get_slicec(' ', 2); + String expr = line.split(" ", true, 1)[1]; String res = script_lang->debug_parse_stack_level_expression(current_frame, expr); print_line(res); } @@ -344,7 +344,7 @@ Pair<String, int> LocalDebugger::to_breakpoint(const String &p_line) { String breakpoint_part = p_line.get_slicec(' ', 1); Pair<String, int> breakpoint; - int last_colon = breakpoint_part.rfind(":"); + int last_colon = breakpoint_part.rfind_char(':'); if (last_colon < 0) { print_line("Error: Invalid breakpoint format. Expected [source:line]"); return breakpoint; diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index a02354b377..f8e42e6d92 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -338,7 +338,7 @@ void RemoteDebugger::_send_stack_vars(List<String> &p_names, List<Variant> &p_va } Error RemoteDebugger::_try_capture(const String &p_msg, const Array &p_data, bool &r_captured) { - const int idx = p_msg.find(":"); + const int idx = p_msg.find_char(':'); r_captured = false; if (idx < 0) { // No prefix, unknown message. return OK; @@ -610,7 +610,7 @@ void RemoteDebugger::poll_events(bool p_is_idle) { ERR_CONTINUE(arr[1].get_type() != Variant::ARRAY); const String cmd = arr[0]; - const int idx = cmd.find(":"); + const int idx = cmd.find_char(':'); bool parsed = false; if (idx < 0) { // Not prefix, use scripts capture. capture_parse("core", cmd, arr[1], parsed); diff --git a/core/debugger/remote_debugger_peer.cpp b/core/debugger/remote_debugger_peer.cpp index 793db7330f..d38fbc8d91 100644 --- a/core/debugger/remote_debugger_peer.cpp +++ b/core/debugger/remote_debugger_peer.cpp @@ -224,7 +224,7 @@ RemoteDebuggerPeer *RemoteDebuggerPeerTCP::create(const String &p_uri) { uint16_t debug_port = 6007; if (debug_host.contains(":")) { - int sep_pos = debug_host.rfind(":"); + int sep_pos = debug_host.rfind_char(':'); debug_port = debug_host.substr(sep_pos + 1).to_int(); debug_host = debug_host.substr(0, sep_pos); } diff --git a/core/input/input.cpp b/core/input/input.cpp index 7e2227c729..a0c00d7716 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -236,7 +236,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S continue; } - String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); + String name = pi.name.substr(pi.name.find_char('/') + 1, pi.name.length()); r_options->push_back(name.quote()); } } diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index d125bad252..4733aaf220 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -1097,7 +1097,7 @@ JoyAxis InputEventJoypadMotion::get_axis() const { void InputEventJoypadMotion::set_axis_value(float p_value) { axis_value = p_value; - pressed = Math::abs(axis_value) >= 0.5f; + pressed = Math::abs(axis_value) >= InputMap::DEFAULT_DEADZONE; emit_changed(); } diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index 6378f18545..54f20a0bcc 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -42,7 +42,7 @@ InputMap *InputMap::singleton = nullptr; void InputMap::_bind_methods() { ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action); ClassDB::bind_method(D_METHOD("get_actions"), &InputMap::_get_actions); - ClassDB::bind_method(D_METHOD("add_action", "action", "deadzone"), &InputMap::add_action, DEFVAL(0.2f)); + ClassDB::bind_method(D_METHOD("add_action", "action", "deadzone"), &InputMap::add_action, DEFVAL(DEFAULT_DEADZONE)); ClassDB::bind_method(D_METHOD("erase_action", "action"), &InputMap::erase_action); ClassDB::bind_method(D_METHOD("action_set_deadzone", "action", "deadzone"), &InputMap::action_set_deadzone); @@ -104,7 +104,7 @@ void InputMap::get_argument_options(const StringName &p_function, int p_idx, Lis continue; } - String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); + String name = pi.name.substr(pi.name.find_char('/') + 1, pi.name.length()); r_options->push_back(name.quote()); } } @@ -302,10 +302,10 @@ void InputMap::load_from_project_settings() { continue; } - String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); + String name = pi.name.substr(pi.name.find_char('/') + 1, pi.name.length()); Dictionary action = GLOBAL_GET(pi.name); - float deadzone = action.has("deadzone") ? (float)action["deadzone"] : 0.2f; + float deadzone = action.has("deadzone") ? (float)action["deadzone"] : DEFAULT_DEADZONE; Array events = action["events"]; add_action(name, deadzone); diff --git a/core/input/input_map.h b/core/input/input_map.h index 45798490f7..2b2a025332 100644 --- a/core/input/input_map.h +++ b/core/input/input_map.h @@ -49,6 +49,8 @@ public: List<Ref<InputEvent>> inputs; }; + static constexpr float DEFAULT_DEADZONE = 0.2f; + private: static InputMap *singleton; @@ -74,7 +76,7 @@ public: bool has_action(const StringName &p_action) const; List<StringName> get_actions() const; - void add_action(const StringName &p_action, float p_deadzone = 0.2); + void add_action(const StringName &p_action, float p_deadzone = DEFAULT_DEADZONE); void erase_action(const StringName &p_action); float action_get_deadzone(const StringName &p_action); diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp index 5d2f65ca99..14588923cb 100644 --- a/core/io/dir_access.cpp +++ b/core/io/dir_access.cpp @@ -155,9 +155,9 @@ Error DirAccess::make_dir_recursive(const String &p_dir) { } else if (full_dir.begins_with("user://")) { base = "user://"; } else if (full_dir.is_network_share_path()) { - int pos = full_dir.find("/", 2); + int pos = full_dir.find_char('/', 2); ERR_FAIL_COND_V(pos < 0, ERR_INVALID_PARAMETER); - pos = full_dir.find("/", pos + 1); + pos = full_dir.find_char('/', pos + 1); ERR_FAIL_COND_V(pos < 0, ERR_INVALID_PARAMETER); base = full_dir.substr(0, pos + 1); } else if (full_dir.begins_with("/")) { diff --git a/core/io/file_access.compat.inc b/core/io/file_access.compat.inc new file mode 100644 index 0000000000..ed16050126 --- /dev/null +++ b/core/io/file_access.compat.inc @@ -0,0 +1,41 @@ +/**************************************************************************/ +/* file_access.compat.inc */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef DISABLE_DEPRECATED + +Ref<FileAccess> FileAccess::_open_encrypted_bind_compat_98918(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key) { + return open_encrypted(p_path, p_mode_flags, p_key, Vector<uint8_t>()); +} + +void FileAccess::_bind_compatibility_methods() { + ClassDB::bind_compatibility_static_method("FileAccess", D_METHOD("open_encrypted", "path", "mode_flags", "key"), &FileAccess::_open_encrypted_bind_compat_98918); +} + +#endif // DISABLE_DEPRECATED diff --git a/core/io/file_access.cpp b/core/io/file_access.cpp index d8bf645a7d..dd826e626b 100644 --- a/core/io/file_access.cpp +++ b/core/io/file_access.cpp @@ -29,6 +29,7 @@ /**************************************************************************/ #include "file_access.h" +#include "file_access.compat.inc" #include "core/config/project_settings.h" #include "core/crypto/crypto_core.h" @@ -124,7 +125,7 @@ Ref<FileAccess> FileAccess::_open(const String &p_path, ModeFlags p_mode_flags) return fa; } -Ref<FileAccess> FileAccess::open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key) { +Ref<FileAccess> FileAccess::open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key, const Vector<uint8_t> &p_iv) { Ref<FileAccess> fa = _open(p_path, p_mode_flags); if (fa.is_null()) { return fa; @@ -132,7 +133,7 @@ Ref<FileAccess> FileAccess::open_encrypted(const String &p_path, ModeFlags p_mod Ref<FileAccessEncrypted> fae; fae.instantiate(); - Error err = fae->open_and_parse(fa, p_key, (p_mode_flags == WRITE) ? FileAccessEncrypted::MODE_WRITE_AES256 : FileAccessEncrypted::MODE_READ); + Error err = fae->open_and_parse(fa, p_key, (p_mode_flags == WRITE) ? FileAccessEncrypted::MODE_WRITE_AES256 : FileAccessEncrypted::MODE_READ, true, p_iv); last_file_open_error = err; if (err) { return Ref<FileAccess>(); @@ -806,7 +807,7 @@ String FileAccess::get_sha256(const String &p_file) { void FileAccess::_bind_methods() { ClassDB::bind_static_method("FileAccess", D_METHOD("open", "path", "flags"), &FileAccess::_open); - ClassDB::bind_static_method("FileAccess", D_METHOD("open_encrypted", "path", "mode_flags", "key"), &FileAccess::open_encrypted); + ClassDB::bind_static_method("FileAccess", D_METHOD("open_encrypted", "path", "mode_flags", "key", "iv"), &FileAccess::open_encrypted, DEFVAL(Vector<uint8_t>())); ClassDB::bind_static_method("FileAccess", D_METHOD("open_encrypted_with_pass", "path", "mode_flags", "pass"), &FileAccess::open_encrypted_pass); ClassDB::bind_static_method("FileAccess", D_METHOD("open_compressed", "path", "mode_flags", "compression_mode"), &FileAccess::open_compressed, DEFVAL(0)); ClassDB::bind_static_method("FileAccess", D_METHOD("get_open_error"), &FileAccess::get_open_error); diff --git a/core/io/file_access.h b/core/io/file_access.h index 7f5687fe03..88c8110a51 100644 --- a/core/io/file_access.h +++ b/core/io/file_access.h @@ -109,6 +109,12 @@ protected: static FileCloseFailNotify close_fail_notify; +#ifndef DISABLE_DEPRECATED + static Ref<FileAccess> _open_encrypted_bind_compat_98918(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key); + + static void _bind_compatibility_methods(); +#endif + private: static bool backup_save; thread_local static Error last_file_open_error; @@ -199,7 +205,7 @@ public: static Ref<FileAccess> create_for_path(const String &p_path); static Ref<FileAccess> open(const String &p_path, int p_mode_flags, Error *r_error = nullptr); /// Create a file access (for the current platform) this is the only portable way of accessing files. - static Ref<FileAccess> open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key); + static Ref<FileAccess> open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key, const Vector<uint8_t> &p_iv = Vector<uint8_t>()); static Ref<FileAccess> open_encrypted_pass(const String &p_path, ModeFlags p_mode_flags, const String &p_pass); static Ref<FileAccess> open_compressed(const String &p_path, ModeFlags p_mode_flags, CompressionMode p_compress_mode = COMPRESSION_FASTLZ); static Error get_open_error(); diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index 24be9ef230..ba26f2e07b 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -36,7 +36,7 @@ #include <stdio.h> -Error FileAccessEncrypted::open_and_parse(Ref<FileAccess> p_base, const Vector<uint8_t> &p_key, Mode p_mode, bool p_with_magic) { +Error FileAccessEncrypted::open_and_parse(Ref<FileAccess> p_base, const Vector<uint8_t> &p_key, Mode p_mode, bool p_with_magic, const Vector<uint8_t> &p_iv) { ERR_FAIL_COND_V_MSG(file.is_valid(), ERR_ALREADY_IN_USE, vformat("Can't open file while another file from path '%s' is open.", file->get_path_absolute())); ERR_FAIL_COND_V(p_key.size() != 32, ERR_INVALID_PARAMETER); @@ -49,6 +49,16 @@ Error FileAccessEncrypted::open_and_parse(Ref<FileAccess> p_base, const Vector<u writing = true; file = p_base; key = p_key; + if (p_iv.is_empty()) { + iv.resize(16); + CryptoCore::RandomGenerator rng; + ERR_FAIL_COND_V_MSG(rng.init(), FAILED, "Failed to initialize random number generator."); + Error err = rng.get_random_bytes(iv.ptrw(), 16); + ERR_FAIL_COND_V(err != OK, err); + } else { + ERR_FAIL_COND_V(p_iv.size() != 16, ERR_INVALID_PARAMETER); + iv = p_iv; + } } else if (p_mode == MODE_READ) { writing = false; @@ -63,10 +73,8 @@ Error FileAccessEncrypted::open_and_parse(Ref<FileAccess> p_base, const Vector<u p_base->get_buffer(md5d, 16); length = p_base->get_64(); - unsigned char iv[16]; - for (int i = 0; i < 16; i++) { - iv[i] = p_base->get_8(); - } + iv.resize(16); + p_base->get_buffer(iv.ptrw(), 16); base = p_base->get_position(); ERR_FAIL_COND_V(p_base->get_length() < base + length, ERR_FILE_CORRUPT); @@ -83,7 +91,7 @@ Error FileAccessEncrypted::open_and_parse(Ref<FileAccess> p_base, const Vector<u CryptoCore::AESContext ctx; ctx.set_encode_key(key.ptrw(), 256); // Due to the nature of CFB, same key schedule is used for both encryption and decryption! - ctx.decrypt_cfb(ds, iv, data.ptrw(), data.ptrw()); + ctx.decrypt_cfb(ds, iv.ptrw(), data.ptrw(), data.ptrw()); } data.resize(length); @@ -145,14 +153,9 @@ void FileAccessEncrypted::_close() { file->store_buffer(hash, 16); file->store_64(data.size()); + file->store_buffer(iv.ptr(), 16); - unsigned char iv[16]; - for (int i = 0; i < 16; i++) { - iv[i] = Math::rand() % 256; - file->store_8(iv[i]); - } - - ctx.encrypt_cfb(len, iv, compressed.ptrw(), compressed.ptrw()); + ctx.encrypt_cfb(len, iv.ptrw(), compressed.ptrw(), compressed.ptrw()); file->store_buffer(compressed.ptr(), compressed.size()); data.clear(); diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h index 5f8c803d60..63a8cab145 100644 --- a/core/io/file_access_encrypted.h +++ b/core/io/file_access_encrypted.h @@ -44,6 +44,7 @@ public: }; private: + Vector<uint8_t> iv; Vector<uint8_t> key; bool writing = false; Ref<FileAccess> file; @@ -57,9 +58,11 @@ private: void _close(); public: - Error open_and_parse(Ref<FileAccess> p_base, const Vector<uint8_t> &p_key, Mode p_mode, bool p_with_magic = true); + Error open_and_parse(Ref<FileAccess> p_base, const Vector<uint8_t> &p_key, Mode p_mode, bool p_with_magic = true, const Vector<uint8_t> &p_iv = Vector<uint8_t>()); Error open_and_parse_password(Ref<FileAccess> p_base, const String &p_key, Mode p_mode); + Vector<uint8_t> get_iv() const { return iv; } + virtual Error open_internal(const String &p_path, int p_mode_flags) override; ///< open a file virtual bool is_open() const override; ///< true when file is open diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index b9af1bfb57..8b6b445cea 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -590,8 +590,6 @@ String DirAccessPack::get_current_dir(bool p_include_drive) const { } bool DirAccessPack::file_exists(String p_file) { - p_file = fix_path(p_file); - PackedData::PackedDir *pd = _find_dir(p_file.get_base_dir()); if (!pd) { return false; @@ -600,8 +598,6 @@ bool DirAccessPack::file_exists(String p_file) { } bool DirAccessPack::dir_exists(String p_dir) { - p_dir = fix_path(p_dir); - return _find_dir(p_dir) != nullptr; } diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index bf44b3a2db..b957a43de2 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -205,7 +205,7 @@ Ref<FileAccess> PackedData::try_open_path(const String &p_path) { } bool PackedData::has_path(const String &p_path) { - return files.has(PathMD5(p_path.simplify_path().md5_buffer())); + return files.has(PathMD5(p_path.simplify_path().trim_prefix("res://").md5_buffer())); } bool PackedData::has_directory(const String &p_path) { diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 9e426c4908..b7a324e710 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -101,7 +101,7 @@ Error HTTPClient::verify_headers(const Vector<String> &p_headers) { for (int i = 0; i < p_headers.size(); i++) { String sanitized = p_headers[i].strip_edges(); ERR_FAIL_COND_V_MSG(sanitized.is_empty(), ERR_INVALID_PARAMETER, vformat("Invalid HTTP header at index %d: empty.", i)); - ERR_FAIL_COND_V_MSG(sanitized.find(":") < 1, ERR_INVALID_PARAMETER, + ERR_FAIL_COND_V_MSG(sanitized.find_char(':') < 1, ERR_INVALID_PARAMETER, vformat("Invalid HTTP header at index %d: String must contain header-value pair, delimited by ':', but was: '%s'.", i, p_headers[i])); } @@ -113,7 +113,7 @@ Dictionary HTTPClient::_get_response_headers_as_dictionary() { get_response_headers(&rh); Dictionary ret; for (const String &s : rh) { - int sp = s.find(":"); + int sp = s.find_char(':'); if (sp == -1) { continue; } diff --git a/core/io/http_client_tcp.cpp b/core/io/http_client_tcp.cpp index 237ba30a80..1382aecb38 100644 --- a/core/io/http_client_tcp.cpp +++ b/core/io/http_client_tcp.cpp @@ -508,11 +508,11 @@ Error HTTPClientTCP::poll() { continue; } if (s.begins_with("content-length:")) { - body_size = s.substr(s.find(":") + 1, s.length()).strip_edges().to_int(); + body_size = s.substr(s.find_char(':') + 1, s.length()).strip_edges().to_int(); body_left = body_size; } else if (s.begins_with("transfer-encoding:")) { - String encoding = header.substr(header.find(":") + 1, header.length()).strip_edges(); + String encoding = header.substr(header.find_char(':') + 1, header.length()).strip_edges(); if (encoding == "chunked") { chunked = true; } diff --git a/core/io/image.cpp b/core/io/image.cpp index fbf37cbee7..fa4484bb63 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -2611,23 +2611,25 @@ Image::AlphaMode Image::detect_alpha() const { } Error Image::load(const String &p_path) { + String path = ResourceUID::ensure_path(p_path); #ifdef DEBUG_ENABLED - if (p_path.begins_with("res://") && ResourceLoader::exists(p_path)) { - WARN_PRINT(vformat("Loaded resource as image file, this will not work on export: '%s'. Instead, import the image file as an Image resource and load it normally as a resource.", p_path)); + if (path.begins_with("res://") && ResourceLoader::exists(path)) { + WARN_PRINT(vformat("Loaded resource as image file, this will not work on export: '%s'. Instead, import the image file as an Image resource and load it normally as a resource.", path)); } #endif - return ImageLoader::load_image(p_path, this); + return ImageLoader::load_image(ResourceUID::ensure_path(p_path), this); } Ref<Image> Image::load_from_file(const String &p_path) { + String path = ResourceUID::ensure_path(p_path); #ifdef DEBUG_ENABLED - if (p_path.begins_with("res://") && ResourceLoader::exists(p_path)) { - WARN_PRINT(vformat("Loaded resource as image file, this will not work on export: '%s'. Instead, import the image file as an Image resource and load it normally as a resource.", p_path)); + if (path.begins_with("res://") && ResourceLoader::exists(path)) { + WARN_PRINT(vformat("Loaded resource as image file, this will not work on export: '%s'. Instead, import the image file as an Image resource and load it normally as a resource.", path)); } #endif Ref<Image> image; image.instantiate(); - Error err = ImageLoader::load_image(p_path, image); + Error err = ImageLoader::load_image(path, image); if (err != OK) { ERR_FAIL_V_MSG(Ref<Image>(), vformat("Failed to load image. Error %d", err)); } diff --git a/core/io/plist.cpp b/core/io/plist.cpp index 32e83c31f2..26b8c39495 100644 --- a/core/io/plist.cpp +++ b/core/io/plist.cpp @@ -661,12 +661,12 @@ bool PList::load_string(const String &p_string, String &r_err_out) { List<Ref<PListNode>> stack; String key; while (pos >= 0) { - int open_token_s = p_string.find("<", pos); + int open_token_s = p_string.find_char('<', pos); if (open_token_s == -1) { r_err_out = "Unexpected end of data. No tags found."; return false; } - int open_token_e = p_string.find(">", open_token_s); + int open_token_e = p_string.find_char('>', open_token_s); pos = open_token_e; String token = p_string.substr(open_token_s + 1, open_token_e - open_token_s - 1); @@ -676,7 +676,7 @@ bool PList::load_string(const String &p_string, String &r_err_out) { } String value; if (token[0] == '?' || token[0] == '!') { // Skip <?xml ... ?> and <!DOCTYPE ... > - int end_token_e = p_string.find(">", open_token_s); + int end_token_e = p_string.find_char('>', open_token_s); pos = end_token_e; continue; } @@ -769,7 +769,7 @@ bool PList::load_string(const String &p_string, String &r_err_out) { r_err_out = vformat("Mismatched <%s> tag.", token); return false; } - int end_token_e = p_string.find(">", end_token_s); + int end_token_e = p_string.find_char('>', end_token_s); pos = end_token_e; String end_token = p_string.substr(end_token_s + 2, end_token_e - end_token_s - 2); if (end_token != token) { diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 3fea697d0b..ecd0a91aa4 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -1206,7 +1206,7 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem int best_score = 0; for (int i = 0; i < res_remaps.size(); i++) { - int split = res_remaps[i].rfind(":"); + int split = res_remaps[i].rfind_char(':'); if (split == -1) { continue; } @@ -1498,11 +1498,11 @@ Vector<String> ResourceLoader::list_directory(const String &p_directory) { } } else { if (d.ends_with(".import") || d.ends_with(".remap") || d.ends_with(".uid")) { - d = d.substr(0, d.rfind(".")); + d = d.substr(0, d.rfind_char('.')); } if (d.ends_with(".gdc")) { - d = d.substr(0, d.rfind(".")); + d = d.substr(0, d.rfind_char('.')); d += ".gd"; } diff --git a/core/io/resource_uid.cpp b/core/io/resource_uid.cpp index c14121a53b..946bc524e5 100644 --- a/core/io/resource_uid.cpp +++ b/core/io/resource_uid.cpp @@ -34,6 +34,7 @@ #include "core/crypto/crypto_core.h" #include "core/io/dir_access.h" #include "core/io/file_access.h" +#include "core/io/resource_loader.h" // These constants are off by 1, causing the 'z' and '9' characters never to be used. // This cannot be fixed without breaking compatibility; see GH-83843. @@ -139,6 +140,21 @@ void ResourceUID::remove_id(ID p_id) { unique_ids.erase(p_id); } +String ResourceUID::uid_to_path(const String &p_uid) { + return singleton->get_id_path(singleton->text_to_id(p_uid)); +} + +String ResourceUID::path_to_uid(const String &p_path) { + return singleton->id_to_text(ResourceLoader::get_resource_uid(p_path)); +} + +String ResourceUID::ensure_path(const String &p_uid_or_path) { + if (p_uid_or_path.begins_with("uid://")) { + return uid_to_path(p_uid_or_path); + } + return p_uid_or_path; +} + Error ResourceUID::save_to_cache() { String cache_file = get_cache_file(); if (!FileAccess::exists(cache_file)) { diff --git a/core/io/resource_uid.h b/core/io/resource_uid.h index e56b89f603..7b735d296a 100644 --- a/core/io/resource_uid.h +++ b/core/io/resource_uid.h @@ -73,6 +73,10 @@ public: String get_id_path(ID p_id) const; void remove_id(ID p_id); + static String uid_to_path(const String &p_uid); + static String path_to_uid(const String &p_path); + static String ensure_path(const String &p_uid_or_path); + Error load_from_cache(bool p_reset); Error save_to_cache(); Error update_cache(); diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index 7a11d06df6..1761d6fa23 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -108,7 +108,7 @@ Ref<Resource> TranslationLoaderPO::load_translation(Ref<FileAccess> f, Error *r_ // Record plural rule. int p_start = config.find("Plural-Forms"); if (p_start != -1) { - int p_end = config.find("\n", p_start); + int p_end = config.find_char('\n', p_start); translation->set_plural_rule(config.substr(p_start, p_end - p_start)); } } else { @@ -224,7 +224,7 @@ Ref<Resource> TranslationLoaderPO::load_translation(Ref<FileAccess> f, Error *r_ // Record plural rule. int p_start = config.find("Plural-Forms"); if (p_start != -1) { - int p_end = config.find("\n", p_start); + int p_end = config.find_char('\n', p_start); translation->set_plural_rule(config.substr(p_start, p_end - p_start)); plural_forms = translation->get_plural_forms(); } @@ -324,7 +324,7 @@ Ref<Resource> TranslationLoaderPO::load_translation(Ref<FileAccess> f, Error *r_ Vector<String> configs = config.split("\n"); for (int i = 0; i < configs.size(); i++) { String c = configs[i].strip_edges(); - int p = c.find(":"); + int p = c.find_char(':'); if (p == -1) { continue; } diff --git a/core/os/os.h b/core/os/os.h index 4bb177eb77..ffdb905aba 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -94,7 +94,15 @@ public: enum RenderThreadMode { RENDER_THREAD_UNSAFE, RENDER_THREAD_SAFE, - RENDER_SEPARATE_THREAD + RENDER_SEPARATE_THREAD, + }; + + enum StdHandleType { + STD_HANDLE_INVALID, + STD_HANDLE_CONSOLE, + STD_HANDLE_FILE, + STD_HANDLE_PIPE, + STD_HANDLE_UNKNOWN, }; protected: @@ -146,7 +154,12 @@ public: void print_rich(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3; void printerr(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3; - virtual String get_stdin_string() = 0; + virtual String get_stdin_string(int64_t p_buffer_size = 1024) = 0; + virtual PackedByteArray get_stdin_buffer(int64_t p_buffer_size = 1024) = 0; + + virtual StdHandleType get_stdin_type() const { return STD_HANDLE_UNKNOWN; } + virtual StdHandleType get_stdout_type() const { return STD_HANDLE_UNKNOWN; } + virtual StdHandleType get_stderr_type() const { return STD_HANDLE_UNKNOWN; } virtual Error get_entropy(uint8_t *r_buffer, int p_bytes) = 0; // Should return cryptographically-safe random bytes. virtual String get_system_ca_certificates() { return ""; } // Concatenated certificates in PEM format. diff --git a/core/string/node_path.cpp b/core/string/node_path.cpp index 3faf3bb0c5..40c81edf4c 100644 --- a/core/string/node_path.cpp +++ b/core/string/node_path.cpp @@ -407,7 +407,7 @@ NodePath::NodePath(const String &p_path) { bool absolute = (path[0] == '/'); bool last_is_slash = true; int slices = 0; - int subpath_pos = path.find(":"); + int subpath_pos = path.find_char(':'); if (subpath_pos != -1) { int from = subpath_pos + 1; diff --git a/core/string/translation_po.cpp b/core/string/translation_po.cpp index da79e472e7..7eb8a2afeb 100644 --- a/core/string/translation_po.cpp +++ b/core/string/translation_po.cpp @@ -227,11 +227,11 @@ void TranslationPO::set_plural_rule(const String &p_plural_rule) { // Set plural_forms and plural_rule. // p_plural_rule passed in has the form "Plural-Forms: nplurals=2; plural=(n >= 2);". - int first_semi_col = p_plural_rule.find(";"); - plural_forms = p_plural_rule.substr(p_plural_rule.find("=") + 1, first_semi_col - (p_plural_rule.find("=") + 1)).to_int(); + int first_semi_col = p_plural_rule.find_char(';'); + plural_forms = p_plural_rule.substr(p_plural_rule.find_char('=') + 1, first_semi_col - (p_plural_rule.find_char('=') + 1)).to_int(); - int expression_start = p_plural_rule.find("=", first_semi_col) + 1; - int second_semi_col = p_plural_rule.rfind(";"); + int expression_start = p_plural_rule.find_char('=', first_semi_col) + 1; + int second_semi_col = p_plural_rule.rfind_char(';'); plural_rule = p_plural_rule.substr(expression_start, second_semi_col - expression_start).strip_edges(); // Setup the cache to make evaluating plural rule faster later on. diff --git a/core/string/translation_server.cpp b/core/string/translation_server.cpp index 4f09360ba8..31c221dad7 100644 --- a/core/string/translation_server.cpp +++ b/core/string/translation_server.cpp @@ -411,8 +411,6 @@ StringName TranslationServer::translate_plural(const StringName &p_message, cons return main_domain->translate_plural(p_message, p_message_plural, p_n, p_context); } -TranslationServer *TranslationServer::singleton = nullptr; - bool TranslationServer::_load_translations(const String &p_from) { if (ProjectSettings::get_singleton()->has_setting(p_from)) { const Vector<String> &translation_names = GLOBAL_GET(p_from); diff --git a/core/string/translation_server.h b/core/string/translation_server.h index fac41035ae..bc59c34a38 100644 --- a/core/string/translation_server.h +++ b/core/string/translation_server.h @@ -50,7 +50,7 @@ class TranslationServer : public Object { bool enabled = true; - static TranslationServer *singleton; + static inline TranslationServer *singleton = nullptr; bool _load_translations(const String &p_from); String _standardize_locale(const String &p_locale, bool p_add_defaults) const; diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 521dfe0b8c..9e99fc3b2f 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -246,27 +246,27 @@ Error String::parse_url(String &r_scheme, String &r_host, int &r_port, String &r base = base.substr(pos + 3, base.length() - pos - 3); } } - pos = base.find("#"); + pos = base.find_char('#'); // Fragment if (pos != -1) { r_fragment = base.substr(pos + 1); base = base.substr(0, pos); } - pos = base.find("/"); + pos = base.find_char('/'); // Path if (pos != -1) { r_path = base.substr(pos, base.length() - pos); base = base.substr(0, pos); } // Host - pos = base.find("@"); + pos = base.find_char('@'); if (pos != -1) { // Strip credentials base = base.substr(pos + 1, base.length() - pos - 1); } if (base.begins_with("[")) { // Literal IPv6 - pos = base.rfind("]"); + pos = base.rfind_char(']'); if (pos == -1) { return ERR_INVALID_PARAMETER; } @@ -277,7 +277,7 @@ Error String::parse_url(String &r_scheme, String &r_host, int &r_port, String &r if (base.get_slice_count(":") > 2) { return ERR_INVALID_PARAMETER; } - pos = base.rfind(":"); + pos = base.rfind_char(':'); if (pos == -1) { r_host = base; base = ""; @@ -2641,7 +2641,7 @@ int64_t String::to_int() const { return 0; } - int to = (find(".") >= 0) ? find(".") : length(); + int to = (find_char('.') >= 0) ? find_char('.') : length(); int64_t integer = 0; int64_t sign = 1; @@ -4580,7 +4580,7 @@ String String::simplify_path() const { if (p == -1) { p = s.find(":\\"); } - if (p != -1 && p < s.find("/")) { + if (p != -1 && p < s.find_char('/')) { drive = s.substr(0, p + 2); s = s.substr(p + 2); } @@ -5025,7 +5025,7 @@ String String::xml_unescape() const { String String::pad_decimals(int p_digits) const { String s = *this; - int c = s.find("."); + int c = s.find_char('.'); if (c == -1) { if (p_digits <= 0) { @@ -5049,7 +5049,7 @@ String String::pad_decimals(int p_digits) const { String String::pad_zeros(int p_digits) const { String s = *this; - int end = s.find("."); + int end = s.find_char('.'); if (end == -1) { end = s.length(); @@ -5316,7 +5316,7 @@ String String::validate_filename() const { } bool String::is_valid_ip_address() const { - if (find(":") >= 0) { + if (find_char(':') >= 0) { Vector<String> ip = split(":"); for (int i = 0; i < ip.size(); i++) { const String &n = ip[i]; @@ -5386,13 +5386,13 @@ String String::get_base_dir() const { // Windows UNC network share path. if (end == 0) { if (is_network_share_path()) { - basepos = find("/", 2); + basepos = find_char('/', 2); if (basepos == -1) { - basepos = find("\\", 2); + basepos = find_char('\\', 2); } - int servpos = find("/", basepos + 1); + int servpos = find_char('/', basepos + 1); if (servpos == -1) { - servpos = find("\\", basepos + 1); + servpos = find_char('\\', basepos + 1); } if (servpos != -1) { end = servpos + 1; @@ -5416,7 +5416,7 @@ String String::get_base_dir() const { rs = *this; } - int sep = MAX(rs.rfind("/"), rs.rfind("\\")); + int sep = MAX(rs.rfind_char('/'), rs.rfind_char('\\')); if (sep == -1) { return base; } @@ -5425,7 +5425,7 @@ String String::get_base_dir() const { } String String::get_file() const { - int sep = MAX(rfind("/"), rfind("\\")); + int sep = MAX(rfind_char('/'), rfind_char('\\')); if (sep == -1) { return *this; } @@ -5434,8 +5434,8 @@ String String::get_file() const { } String String::get_extension() const { - int pos = rfind("."); - if (pos < 0 || pos < MAX(rfind("/"), rfind("\\"))) { + int pos = rfind_char('.'); + if (pos < 0 || pos < MAX(rfind_char('/'), rfind_char('\\'))) { return ""; } @@ -5533,8 +5533,8 @@ String String::validate_node_name() const { } String String::get_basename() const { - int pos = rfind("."); - if (pos < 0 || pos < MAX(rfind("/"), rfind("\\"))) { + int pos = rfind_char('.'); + if (pos < 0 || pos < MAX(rfind_char('/'), rfind_char('\\'))) { return *this; } diff --git a/core/templates/a_hash_map.h b/core/templates/a_hash_map.h index 29983ea268..6e3a978d50 100644 --- a/core/templates/a_hash_map.h +++ b/core/templates/a_hash_map.h @@ -622,10 +622,11 @@ public: } // Inserts an element without checking if it already exists. - void insert_new(const TKey &p_key, const TValue &p_value) { + Iterator insert_new(const TKey &p_key, const TValue &p_value) { DEV_ASSERT(!has(p_key)); uint32_t hash = _hash(p_key); - _insert_element(p_key, p_value, hash); + uint32_t pos = _insert_element(p_key, p_value, hash); + return Iterator(elements + pos, elements, elements + num_elements); } /* Array methods. */ diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp index 5ce90cd8ff..ddeea27118 100644 --- a/core/variant/callable.cpp +++ b/core/variant/callable.cpp @@ -206,19 +206,17 @@ int Callable::get_bound_arguments_count() const { } } -void Callable::get_bound_arguments_ref(Vector<Variant> &r_arguments, int &r_argcount) const { +void Callable::get_bound_arguments_ref(Vector<Variant> &r_arguments) const { if (!is_null() && is_custom()) { - custom->get_bound_arguments(r_arguments, r_argcount); + custom->get_bound_arguments(r_arguments); } else { r_arguments.clear(); - r_argcount = 0; } } Array Callable::get_bound_arguments() const { Vector<Variant> arr; - int ac; - get_bound_arguments_ref(arr, ac); + get_bound_arguments_ref(arr); Array ret; ret.resize(arr.size()); for (int i = 0; i < arr.size(); i++) { @@ -227,6 +225,14 @@ Array Callable::get_bound_arguments() const { return ret; } +int Callable::get_unbound_arguments_count() const { + if (!is_null() && is_custom()) { + return custom->get_unbound_arguments_count(); + } else { + return 0; + } +} + CallableCustom *Callable::get_custom() const { ERR_FAIL_COND_V_MSG(!is_custom(), nullptr, vformat("Can't get custom on non-CallableCustom \"%s\".", operator String())); @@ -464,9 +470,12 @@ int CallableCustom::get_bound_arguments_count() const { return 0; } -void CallableCustom::get_bound_arguments(Vector<Variant> &r_arguments, int &r_argcount) const { - r_arguments = Vector<Variant>(); - r_argcount = 0; +void CallableCustom::get_bound_arguments(Vector<Variant> &r_arguments) const { + r_arguments.clear(); +} + +int CallableCustom::get_unbound_arguments_count() const { + return 0; } CallableCustom::CallableCustom() { diff --git a/core/variant/callable.h b/core/variant/callable.h index e3c940a0e5..e76b888ac2 100644 --- a/core/variant/callable.h +++ b/core/variant/callable.h @@ -111,8 +111,9 @@ public: CallableCustom *get_custom() const; int get_argument_count(bool *r_is_valid = nullptr) const; int get_bound_arguments_count() const; - void get_bound_arguments_ref(Vector<Variant> &r_arguments, int &r_argcount) const; // Internal engine use, the exposed one is below. + void get_bound_arguments_ref(Vector<Variant> &r_arguments) const; // Internal engine use, the exposed one is below. Array get_bound_arguments() const; + int get_unbound_arguments_count() const; uint32_t hash() const; @@ -158,7 +159,8 @@ public: virtual const Callable *get_base_comparator() const; virtual int get_argument_count(bool &r_is_valid) const; virtual int get_bound_arguments_count() const; - virtual void get_bound_arguments(Vector<Variant> &r_arguments, int &r_argcount) const; + virtual void get_bound_arguments(Vector<Variant> &r_arguments) const; + virtual int get_unbound_arguments_count() const; CallableCustom(); virtual ~CallableCustom() {} diff --git a/core/variant/callable_bind.cpp b/core/variant/callable_bind.cpp index afb889551e..43cac263c1 100644 --- a/core/variant/callable_bind.cpp +++ b/core/variant/callable_bind.cpp @@ -100,44 +100,42 @@ int CallableCustomBind::get_argument_count(bool &r_is_valid) const { } int CallableCustomBind::get_bound_arguments_count() const { - return callable.get_bound_arguments_count() + binds.size(); + return callable.get_bound_arguments_count() + MAX(0, binds.size() - callable.get_unbound_arguments_count()); } -void CallableCustomBind::get_bound_arguments(Vector<Variant> &r_arguments, int &r_argcount) const { - Vector<Variant> sub_args; - int sub_count; - callable.get_bound_arguments_ref(sub_args, sub_count); +void CallableCustomBind::get_bound_arguments(Vector<Variant> &r_arguments) const { + Vector<Variant> sub_bound_args; + callable.get_bound_arguments_ref(sub_bound_args); + int sub_bound_count = sub_bound_args.size(); - if (sub_count == 0) { + int sub_unbound_count = callable.get_unbound_arguments_count(); + + if (sub_bound_count == 0 && sub_unbound_count == 0) { r_arguments = binds; - r_argcount = binds.size(); return; } - int new_count = sub_count + binds.size(); - r_argcount = new_count; + int added_count = MAX(0, binds.size() - sub_unbound_count); + int new_count = sub_bound_count + added_count; - if (new_count <= 0) { - // Removed more arguments than it adds. - r_arguments = Vector<Variant>(); + if (added_count <= 0) { + // All added arguments are consumed by `sub_unbound_count`. + r_arguments = sub_bound_args; return; } r_arguments.resize(new_count); - - if (sub_count > 0) { - for (int i = 0; i < sub_count; i++) { - r_arguments.write[i] = sub_args[i]; - } - for (int i = 0; i < binds.size(); i++) { - r_arguments.write[i + sub_count] = binds[i]; - } - r_argcount = new_count; - } else { - for (int i = 0; i < binds.size() + sub_count; i++) { - r_arguments.write[i] = binds[i - sub_count]; - } + Variant *args = r_arguments.ptrw(); + for (int i = 0; i < added_count; i++) { + args[i] = binds[i]; } + for (int i = 0; i < sub_bound_count; i++) { + args[i + added_count] = sub_bound_args[i]; + } +} + +int CallableCustomBind::get_unbound_arguments_count() const { + return MAX(0, callable.get_unbound_arguments_count() - binds.size()); } void CallableCustomBind::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const { @@ -242,22 +240,15 @@ int CallableCustomUnbind::get_argument_count(bool &r_is_valid) const { } int CallableCustomUnbind::get_bound_arguments_count() const { - return callable.get_bound_arguments_count() - argcount; + return callable.get_bound_arguments_count(); } -void CallableCustomUnbind::get_bound_arguments(Vector<Variant> &r_arguments, int &r_argcount) const { - Vector<Variant> sub_args; - int sub_count; - callable.get_bound_arguments_ref(sub_args, sub_count); - - r_argcount = sub_args.size() - argcount; +void CallableCustomUnbind::get_bound_arguments(Vector<Variant> &r_arguments) const { + callable.get_bound_arguments_ref(r_arguments); +} - if (argcount >= sub_args.size()) { - r_arguments = Vector<Variant>(); - } else { - sub_args.resize(sub_args.size() - argcount); - r_arguments = sub_args; - } +int CallableCustomUnbind::get_unbound_arguments_count() const { + return callable.get_unbound_arguments_count() + argcount; } void CallableCustomUnbind::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const { diff --git a/core/variant/callable_bind.h b/core/variant/callable_bind.h index 43cebb45f0..1346277197 100644 --- a/core/variant/callable_bind.h +++ b/core/variant/callable_bind.h @@ -55,7 +55,8 @@ public: virtual const Callable *get_base_comparator() const override; virtual int get_argument_count(bool &r_is_valid) const override; virtual int get_bound_arguments_count() const override; - virtual void get_bound_arguments(Vector<Variant> &r_arguments, int &r_argcount) const override; + virtual void get_bound_arguments(Vector<Variant> &r_arguments) const override; + virtual int get_unbound_arguments_count() const override; Callable get_callable() { return callable; } Vector<Variant> get_binds() { return binds; } @@ -84,7 +85,8 @@ public: virtual const Callable *get_base_comparator() const override; virtual int get_argument_count(bool &r_is_valid) const override; virtual int get_bound_arguments_count() const override; - virtual void get_bound_arguments(Vector<Variant> &r_arguments, int &r_argcount) const override; + virtual void get_bound_arguments(Vector<Variant> &r_arguments) const override; + virtual int get_unbound_arguments_count() const override; Callable get_callable() { return callable; } int get_unbinds() { return argcount; } diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 54936eb8a2..3e74dc4e67 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -3664,18 +3664,20 @@ String Variant::get_call_error_text(Object *p_base, const StringName &p_method, String Variant::get_callable_error_text(const Callable &p_callable, const Variant **p_argptrs, int p_argcount, const Callable::CallError &ce) { Vector<Variant> binds; - int args_bound; - p_callable.get_bound_arguments_ref(binds, args_bound); - if (args_bound <= 0) { - return get_call_error_text(p_callable.get_object(), p_callable.get_method(), p_argptrs, MAX(0, p_argcount + args_bound), ce); + p_callable.get_bound_arguments_ref(binds); + + int args_unbound = p_callable.get_unbound_arguments_count(); + + if (p_argcount - args_unbound < 0) { + return "Callable unbinds " + itos(args_unbound) + " arguments, but called with " + itos(p_argcount); } else { Vector<const Variant *> argptrs; - argptrs.resize(p_argcount + binds.size()); - for (int i = 0; i < p_argcount; i++) { + argptrs.resize(p_argcount - args_unbound + binds.size()); + for (int i = 0; i < p_argcount - args_unbound; i++) { argptrs.write[i] = p_argptrs[i]; } for (int i = 0; i < binds.size(); i++) { - argptrs.write[i + p_argcount] = &binds[i]; + argptrs.write[i + p_argcount - args_unbound] = &binds[i]; } return get_call_error_text(p_callable.get_object(), p_callable.get_method(), (const Variant **)argptrs.ptr(), argptrs.size(), ce); } diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 29e11462c9..381b848b2b 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -2116,6 +2116,7 @@ static void _register_variant_builtin_methods_misc() { bind_function(Callable, get_argument_count, _VariantCall::func_Callable_get_argument_count, sarray(), varray()); bind_method(Callable, get_bound_arguments_count, sarray(), varray()); bind_method(Callable, get_bound_arguments, sarray(), varray()); + bind_method(Callable, get_unbound_arguments_count, sarray(), varray()); bind_method(Callable, hash, sarray(), varray()); bind_method(Callable, bindv, sarray("arguments"), varray()); bind_method(Callable, unbind, sarray("argcount"), varray()); diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 66f15f7494..1721134d08 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -991,8 +991,8 @@ [codeblock] var a = rand_from_seed(4) - print(a[0]) # Prints 2879024997 - print(a[1]) # Prints 4 + print(a[0]) # Prints 2879024997 + print(a[1]) # Prints 4 [/codeblock] </description> </method> @@ -2981,7 +2981,7 @@ Editing the property prompts the user for restarting the editor. </constant> <constant name="PROPERTY_USAGE_SCRIPT_VARIABLE" value="4096" enum="PropertyUsageFlags" is_bitfield="true"> - The property is a script variable which should be serialized and saved in the scene file. + The property is a script variable. [constant PROPERTY_USAGE_SCRIPT_VARIABLE] can be used to distinguish between exported script variables from built-in variables (which don't have this usage flag). By default, [constant PROPERTY_USAGE_SCRIPT_VARIABLE] is [b]not[/b] applied to variables that are created by overriding [method Object._get_property_list] in a script. </constant> <constant name="PROPERTY_USAGE_STORE_IF_NULL" value="8192" enum="PropertyUsageFlags" is_bitfield="true"> The property value of type [Object] will be stored even if its value is [code]null[/code]. @@ -2992,7 +2992,7 @@ <constant name="PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE" value="32768" enum="PropertyUsageFlags" is_bitfield="true" deprecated="This flag is not used by the engine."> </constant> <constant name="PROPERTY_USAGE_CLASS_IS_ENUM" value="65536" enum="PropertyUsageFlags" is_bitfield="true"> - The property is an enum, i.e. it only takes named integer constants from its associated enumeration. + The property is a variable of enum type, i.e. it only takes named integer constants from its associated enumeration. </constant> <constant name="PROPERTY_USAGE_NIL_IS_VARIANT" value="131072" enum="PropertyUsageFlags" is_bitfield="true"> If property has [code]nil[/code] as default value, its type will be [Variant]. diff --git a/doc/classes/AnimationNodeAnimation.xml b/doc/classes/AnimationNodeAnimation.xml index 70c3e5a26e..f4490bc167 100644 --- a/doc/classes/AnimationNodeAnimation.xml +++ b/doc/classes/AnimationNodeAnimation.xml @@ -12,6 +12,10 @@ <link title="Third Person Shooter (TPS) Demo">https://godotengine.org/asset-library/asset/2710</link> </tutorials> <members> + <member name="advance_on_start" type="bool" setter="set_advance_on_start" getter="is_advance_on_start" default="false"> + If [code]true[/code], on receiving a request to play an animation from the start, the first frame is not drawn, but only processed, and playback starts from the next frame. + See also the notes of [method AnimationPlayer.play]. + </member> <member name="animation" type="StringName" setter="set_animation" getter="get_animation" default="&"""> Animation to use as an output. It is one of the animations provided by [member AnimationTree.anim_player]. </member> diff --git a/doc/classes/AudioEffectSpectrumAnalyzer.xml b/doc/classes/AudioEffectSpectrumAnalyzer.xml index b90f87ef5b..5cbf3fb1cb 100644 --- a/doc/classes/AudioEffectSpectrumAnalyzer.xml +++ b/doc/classes/AudioEffectSpectrumAnalyzer.xml @@ -5,7 +5,7 @@ </brief_description> <description> This audio effect does not affect sound output, but can be used for real-time audio visualizations. - This resource configures an [AudioEffectSpectrumAnalyzerInstance], which performs the actual analysis at runtime. An instance can be acquired with [method AudioServer.get_bus_effect_instance]. + This resource configures an [AudioEffectSpectrumAnalyzerInstance], which performs the actual analysis at runtime. An instance can be obtained with [method AudioServer.get_bus_effect_instance]. See also [AudioStreamGenerator] for procedurally generating sounds. </description> <tutorials> diff --git a/doc/classes/AudioEffectSpectrumAnalyzerInstance.xml b/doc/classes/AudioEffectSpectrumAnalyzerInstance.xml index 184f80db2e..833ccafa6f 100644 --- a/doc/classes/AudioEffectSpectrumAnalyzerInstance.xml +++ b/doc/classes/AudioEffectSpectrumAnalyzerInstance.xml @@ -5,7 +5,7 @@ </brief_description> <description> The runtime part of an [AudioEffectSpectrumAnalyzer], which can be used to query the magnitude of a frequency range on its host bus. - An instance of this class can be acquired with [method AudioServer.get_bus_effect_instance]. + An instance of this class can be obtained with [method AudioServer.get_bus_effect_instance]. </description> <tutorials> <link title="Audio Spectrum Visualizer Demo">https://godotengine.org/asset-library/asset/2762</link> diff --git a/doc/classes/Callable.xml b/doc/classes/Callable.xml index 0c8f3c66f5..cf3c3e06fd 100644 --- a/doc/classes/Callable.xml +++ b/doc/classes/Callable.xml @@ -155,13 +155,21 @@ <method name="get_bound_arguments" qualifiers="const"> <return type="Array" /> <description> - Return the bound arguments (as long as [method get_bound_arguments_count] is greater than zero), or empty (if [method get_bound_arguments_count] is less than or equal to zero). + Returns the array of arguments bound via successive [method bind] or [method unbind] calls. These arguments will be added [i]after[/i] the arguments passed to the call, from which [method get_unbound_arguments_count] arguments on the right have been previously excluded. + [codeblock] + func get_effective_arguments(callable, call_args): + assert(call_args.size() - callable.get_unbound_arguments_count() >= 0) + var result = call_args.slice(0, call_args.size() - callable.get_unbound_arguments_count()) + result.append_array(callable.get_bound_arguments()) + return result + [/codeblock] </description> </method> <method name="get_bound_arguments_count" qualifiers="const"> <return type="int" /> <description> - Returns the total amount of arguments bound (or unbound) via successive [method bind] or [method unbind] calls. If the amount of arguments unbound is greater than the ones bound, this function returns a value less than zero. + Returns the total amount of arguments bound via successive [method bind] or [method unbind] calls. This is the same as the size of the array returned by [method get_bound_arguments]. See [method get_bound_arguments] for details. + [b]Note:[/b] The [method get_bound_arguments_count] and [method get_unbound_arguments_count] methods can both return positive values. </description> </method> <method name="get_method" qualifiers="const"> @@ -182,6 +190,13 @@ Returns the ID of this [Callable]'s object (see [method Object.get_instance_id]). </description> </method> + <method name="get_unbound_arguments_count" qualifiers="const"> + <return type="int" /> + <description> + Returns the total amount of arguments unbound via successive [method bind] or [method unbind] calls. See [method get_bound_arguments] for details. + [b]Note:[/b] The [method get_bound_arguments_count] and [method get_unbound_arguments_count] methods can both return positive values. + </description> + </method> <method name="hash" qualifiers="const"> <return type="int" /> <description> diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml index 4e6535f3ca..5710e08423 100644 --- a/doc/classes/CanvasItem.xml +++ b/doc/classes/CanvasItem.xml @@ -633,7 +633,7 @@ </member> <member name="y_sort_enabled" type="bool" setter="set_y_sort_enabled" getter="is_y_sort_enabled" default="false"> If [code]true[/code], this and child [CanvasItem] nodes with a higher Y position are rendered in front of nodes with a lower Y position. If [code]false[/code], this and child [CanvasItem] nodes are rendered normally in scene tree order. - With Y-sorting enabled on a parent node ('A') but disabled on a child node ('B'), the child node ('B') is sorted but its children ('C1', 'C2', etc) render together on the same Y position as the child node ('B'). This allows you to organize the render order of a scene without changing the scene tree. + With Y-sorting enabled on a parent node ('A') but disabled on a child node ('B'), the child node ('B') is sorted but its children ('C1', 'C2', etc.) render together on the same Y position as the child node ('B'). This allows you to organize the render order of a scene without changing the scene tree. Nodes sort relative to each other only if they are on the same [member z_index]. </member> <member name="z_as_relative" type="bool" setter="set_z_as_relative" getter="is_z_relative" default="true"> diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 80c5f8d96d..342e20759e 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -168,7 +168,7 @@ The returned node must be of type [Control] or Control-derived. It can have child nodes of any type. It is freed when the tooltip disappears, so make sure you always provide a new instance (if you want to use a pre-existing node from your scene tree, you can duplicate it and pass the duplicated instance). When [code]null[/code] or a non-Control node is returned, the default tooltip will be used instead. The returned node will be added as child to a [PopupPanel], so you should only provide the contents of that panel. That [PopupPanel] can be themed using [method Theme.set_stylebox] for the type [code]"TooltipPanel"[/code] (see [member tooltip_text] for an example). [b]Note:[/b] The tooltip is shrunk to minimal size. If you want to ensure it's fully visible, you might want to set its [member custom_minimum_size] to some non-zero value. - [b]Note:[/b] The node (and any relevant children) should be [member CanvasItem.visible] when returned, otherwise, the viewport that instantiates it will not be able to calculate its minimum size reliably. + [b]Note:[/b] The node (and any relevant children) should have their [member CanvasItem.visible] set to [code]true[/code] when returned, otherwise, the viewport that instantiates it will not be able to calculate its minimum size reliably. [b]Example:[/b] Use a constructed node as a tooltip: [codeblocks] [gdscript] @@ -559,7 +559,7 @@ <method name="grab_click_focus"> <return type="void" /> <description> - Creates an [InputEventMouseButton] that attempts to click the control. If the event is received, the control acquires focus. + Creates an [InputEventMouseButton] that attempts to click the control. If the event is received, the control gains focus. [codeblocks] [gdscript] func _process(delta): diff --git a/doc/classes/Curve3D.xml b/doc/classes/Curve3D.xml index 9157649af2..f8386b73b2 100644 --- a/doc/classes/Curve3D.xml +++ b/doc/classes/Curve3D.xml @@ -204,6 +204,9 @@ <member name="bake_interval" type="float" setter="set_bake_interval" getter="get_bake_interval" default="0.2"> The distance in meters between two adjacent cached points. Changing it forces the cache to be recomputed the next time the [method get_baked_points] or [method get_baked_length] function is called. The smaller the distance, the more points in the cache and the more memory it will consume, so use with care. </member> + <member name="closed" type="bool" setter="set_closed" getter="is_closed" default="false"> + If [code]true[/code], and the curve has more than 2 control points, the last point and the first one will be connected in a loop. + </member> <member name="point_count" type="int" setter="set_point_count" getter="get_point_count" default="0"> The number of points describing the curve. </member> diff --git a/doc/classes/DirAccess.xml b/doc/classes/DirAccess.xml index dcd2d527e2..0f5844fd63 100644 --- a/doc/classes/DirAccess.xml +++ b/doc/classes/DirAccess.xml @@ -14,7 +14,7 @@ # Static DirAccess.make_dir_absolute("user://levels/world1") [/codeblock] - [b]Note:[/b] Many resources types are imported (e.g. textures or sound files), and their source asset will not be included in the exported game, as only the imported version is used. Use [ResourceLoader] to access imported resources. + [b]Note:[/b] Accessing project ("res://") directories once exported may behave unexpectedly as some files are converted to engine-specific formats and their original source files may not be present in the expected PCK package. Because of this, to access resources in an exported project, it is recommended to use [ResourceLoader] instead of [FileAccess]. Here is an example on how to iterate through the files of a directory: [codeblocks] [gdscript] @@ -116,6 +116,7 @@ <param index="0" name="path" type="String" /> <description> Returns whether the target directory exists. The argument can be relative to the current directory, or an absolute path. + [b]Note:[/b] The returned [bool] in the editor and after exporting when used on a path in the [code]res://[/code] directory may be different. Some files are converted to engine-specific formats when exported, potentially changing the directory structure. </description> </method> <method name="dir_exists_absolute" qualifiers="static"> @@ -123,6 +124,7 @@ <param index="0" name="path" type="String" /> <description> Static version of [method dir_exists]. Supports only absolute paths. + [b]Note:[/b] The returned [bool] in the editor and after exporting when used on a path in the [code]res://[/code] directory may be different. Some files are converted to engine-specific formats when exported, potentially changing the directory structure. </description> </method> <method name="file_exists"> @@ -131,6 +133,7 @@ <description> Returns whether the target file exists. The argument can be relative to the current directory, or an absolute path. For a static equivalent, use [method FileAccess.file_exists]. + [b]Note:[/b] Many resources types are imported (e.g. textures or sound files), and their source asset will not be included in the exported game, as only the imported version is used. See [method ResourceLoader.exists] for an alternative approach that takes resource remapping into account. </description> </method> <method name="get_current_dir" qualifiers="const"> @@ -151,6 +154,7 @@ <description> Returns a [PackedStringArray] containing filenames of the directory contents, excluding files. The array is sorted alphabetically. Affected by [member include_hidden] and [member include_navigational]. + [b]Note:[/b] The returned directories in the editor and after exporting in the [code]res://[/code] directory may differ as some files are converted to engine-specific formats when exported. </description> </method> <method name="get_directories_at" qualifiers="static"> @@ -159,6 +163,7 @@ <description> Returns a [PackedStringArray] containing filenames of the directory contents, excluding files, at the given [param path]. The array is sorted alphabetically. Use [method get_directories] if you want more control of what gets included. + [b]Note:[/b] The returned directories in the editor and after exporting in the [code]res://[/code] directory may differ as some files are converted to engine-specific formats when exported. </description> </method> <method name="get_drive_count" qualifiers="static"> @@ -194,6 +199,7 @@ <description> Returns a [PackedStringArray] containing filenames of the directory contents, excluding directories, at the given [param path]. The array is sorted alphabetically. Use [method get_files] if you want more control of what gets included. + [b]Note:[/b] When used on a [code]res://[/code] path in an exported project, only the files included in the PCK at the given folder level are returned. In practice, this means that since imported resources are stored in a top-level [code].godot/[/code] folder, only paths to [code].gd[/code] and [code].import[/code] files are returned (plus a few other files, such as [code]project.godot[/code] or [code]project.binary[/code] and the project icon). In an exported project, the list of returned files will also vary depending on [member ProjectSettings.editor/export/convert_text_resources_to_binary]. </description> </method> <method name="get_next"> diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml index dafa86d42e..e2a352de9a 100644 --- a/doc/classes/DisplayServer.xml +++ b/doc/classes/DisplayServer.xml @@ -237,7 +237,7 @@ <return type="int" /> <param index="0" name="rect" type="Rect2" /> <description> - Returns index of the screen which contains specified rectangle. + Returns the index of the screen that overlaps the most with the given rectangle. Returns [code]-1[/code] if the rectangle doesn't overlap with any screen or has no area. </description> </method> <method name="get_swap_cancel_ok"> diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml index 0304499a61..624e828520 100644 --- a/doc/classes/EditorInterface.xml +++ b/doc/classes/EditorInterface.xml @@ -117,6 +117,12 @@ [b]Note:[/b] When creating custom editor UI, prefer accessing theme items directly from your GUI nodes using the [code]get_theme_*[/code] methods. </description> </method> + <method name="get_editor_toaster" qualifiers="const"> + <return type="EditorToaster" /> + <description> + Returns the editor's [EditorToaster]. + </description> + </method> <method name="get_editor_undo_redo" qualifiers="const"> <return type="EditorUndoRedoManager" /> <description> diff --git a/doc/classes/EditorNode3DGizmoPlugin.xml b/doc/classes/EditorNode3DGizmoPlugin.xml index 8fd7c167d9..6a91e3559d 100644 --- a/doc/classes/EditorNode3DGizmoPlugin.xml +++ b/doc/classes/EditorNode3DGizmoPlugin.xml @@ -54,7 +54,7 @@ <return type="EditorNode3DGizmo" /> <param index="0" name="for_node_3d" type="Node3D" /> <description> - Override this method to return a custom [EditorNode3DGizmo] for the spatial nodes of your choice, return [code]null[/code] for the rest of nodes. See also [method _has_gizmo]. + Override this method to return a custom [EditorNode3DGizmo] for the 3D nodes of your choice, return [code]null[/code] for the rest of nodes. See also [method _has_gizmo]. </description> </method> <method name="_get_gizmo_name" qualifiers="virtual const"> diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index 8189f253fb..2cc9e08dd3 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -416,7 +416,7 @@ <param index="1" name="title" type="String" /> <param index="2" name="shortcut" type="Shortcut" default="null" /> <description> - Adds a control to the bottom panel (together with Output, Debug, Animation, etc). Returns a reference to the button added. It's up to you to hide/show the button when needed. When your plugin is deactivated, make sure to remove your custom control with [method remove_control_from_bottom_panel] and free it with [method Node.queue_free]. + Adds a control to the bottom panel (together with Output, Debug, Animation, etc.). Returns a reference to the button added. It's up to you to hide/show the button when needed. When your plugin is deactivated, make sure to remove your custom control with [method remove_control_from_bottom_panel] and free it with [method Node.queue_free]. Optionally, you can specify a shortcut parameter. When pressed, this shortcut will toggle the bottom panel's visibility. See the default editor bottom panel shortcuts in the Editor Settings for inspiration. Per convention, they all use [kbd]Alt[/kbd] modifier. </description> </method> diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 15b03ddbd8..c35a376c85 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -359,7 +359,7 @@ <member name="editors/3d/navigation/navigation_scheme" type="int" setter="" getter=""> The navigation scheme preset to use in the 3D editor. Changing this setting will affect the mouse button and modifier controls used to navigate the 3D editor viewport. All schemes can use [kbd]Mouse wheel[/kbd] to zoom. - - [b]Godot:[/b] [kbd]Middle mouse button[/kbd] to orbit. [kbd]Shift + Middle mouse button[/kbd] to pan. [kbd]Ctrl + Shift + Middle mouse button[/kbd] to zoom. + - [b]Godot:[/b] [kbd]Middle mouse button[/kbd] to orbit. [kbd]Shift + Middle mouse button[/kbd] to pan. [kbd]Ctrl + Middle mouse button[/kbd] to zoom. - [b]Maya:[/b] [kbd]Alt + Left mouse button[/kbd] to orbit. [kbd]Middle mouse button[/kbd] to pan, [kbd]Shift + Middle mouse button[/kbd] to pan 10 times faster. [kbd]Alt + Right mouse button[/kbd] to zoom. - [b]Modo:[/b] [kbd]Alt + Left mouse button[/kbd] to orbit. [kbd]Alt + Shift + Left mouse button[/kbd] to pan. [kbd]Ctrl + Alt + Left mouse button[/kbd] to zoom. See also [member editors/3d/navigation/orbit_mouse_button], [member editors/3d/navigation/pan_mouse_button], [member editors/3d/navigation/zoom_mouse_button], and [member editors/3d/freelook/freelook_navigation_scheme]. diff --git a/doc/classes/EditorToaster.xml b/doc/classes/EditorToaster.xml new file mode 100644 index 0000000000..c30b94c989 --- /dev/null +++ b/doc/classes/EditorToaster.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="EditorToaster" inherits="HBoxContainer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> + <brief_description> + Manages toast notifications within the editor. + </brief_description> + <description> + This object manages the functionality and display of toast notifications within the editor, ensuring timely and informative alerts are presented to users. + [b]Note:[/b] This class shouldn't be instantiated directly. Instead, access the singleton using [method EditorInterface.get_editor_toaster]. + </description> + <tutorials> + </tutorials> + <methods> + <method name="push_toast"> + <return type="void" /> + <param index="0" name="message" type="String" /> + <param index="1" name="severity" type="int" enum="EditorToaster.Severity" default="0" /> + <param index="2" name="tooltip" type="String" default="""" /> + <description> + Pushes a toast notification to the editor for display. + </description> + </method> + </methods> + <constants> + <constant name="SEVERITY_INFO" value="0" enum="Severity"> + Toast will display with an INFO severity. + </constant> + <constant name="SEVERITY_WARNING" value="1" enum="Severity"> + Toast will display with a WARNING severity and have a corresponding color. + </constant> + <constant name="SEVERITY_ERROR" value="2" enum="Severity"> + Toast will display with an ERROR severity and have a corresponding color. + </constant> + </constants> +</class> diff --git a/doc/classes/EditorTranslationParserPlugin.xml b/doc/classes/EditorTranslationParserPlugin.xml index 43bbeaefa7..b9dc654de3 100644 --- a/doc/classes/EditorTranslationParserPlugin.xml +++ b/doc/classes/EditorTranslationParserPlugin.xml @@ -99,6 +99,14 @@ <tutorials> </tutorials> <methods> + <method name="_get_comments" qualifiers="virtual"> + <return type="void" /> + <param index="0" name="msgids_comment" type="String[]" /> + <param index="1" name="msgids_context_plural_comment" type="String[]" /> + <description> + If overridden, called after [method _parse_file] to get comments for the parsed entries. This method should fill the arrays with the same number of elements and in the same order as [method _parse_file]. + </description> + </method> <method name="_get_recognized_extensions" qualifiers="virtual const"> <return type="PackedStringArray" /> <description> diff --git a/doc/classes/FileAccess.xml b/doc/classes/FileAccess.xml index b782937a8a..5c89b64429 100644 --- a/doc/classes/FileAccess.xml +++ b/doc/classes/FileAccess.xml @@ -308,6 +308,7 @@ <param index="0" name="path" type="String" /> <param index="1" name="mode_flags" type="int" enum="FileAccess.ModeFlags" /> <param index="2" name="key" type="PackedByteArray" /> + <param index="3" name="iv" type="PackedByteArray" default="PackedByteArray()" /> <description> Creates a new [FileAccess] object and opens an encrypted file in write or read mode. You need to pass a binary key to encrypt/decrypt it. [b]Note:[/b] The provided key must be 32 bytes long. diff --git a/doc/classes/GeometryInstance3D.xml b/doc/classes/GeometryInstance3D.xml index f4075af186..0c45154c8a 100644 --- a/doc/classes/GeometryInstance3D.xml +++ b/doc/classes/GeometryInstance3D.xml @@ -39,8 +39,12 @@ <member name="extra_cull_margin" type="float" setter="set_extra_cull_margin" getter="get_extra_cull_margin" default="0.0"> The extra distance added to the GeometryInstance3D's bounding box ([AABB]) to increase its cull box. </member> - <member name="gi_lightmap_scale" type="int" setter="set_lightmap_scale" getter="get_lightmap_scale" enum="GeometryInstance3D.LightmapScale" default="0"> + <member name="gi_lightmap_scale" type="int" setter="set_lightmap_scale" getter="get_lightmap_scale" enum="GeometryInstance3D.LightmapScale" default="0" deprecated="Use [member gi_lightmap_texel_scale] instead."> + The texel density to use for lightmapping in [LightmapGI]. + </member> + <member name="gi_lightmap_texel_scale" type="float" setter="set_lightmap_texel_scale" getter="get_lightmap_texel_scale" default="1.0"> The texel density to use for lightmapping in [LightmapGI]. Greater scale values provide higher resolution in the lightmap, which can result in sharper shadows for lights that have both direct and indirect light baked. However, greater scale values will also increase the space taken by the mesh in the lightmap texture, which increases the memory, storage, and bake time requirements. When using a single mesh at different scales, consider adjusting this value to keep the lightmap texel density consistent across meshes. + For example, doubling [member gi_lightmap_texel_scale] doubles the lightmap texture resolution for this object [i]on each axis[/i], so it will [i]quadruple[/i] the texel count. </member> <member name="gi_mode" type="int" setter="set_gi_mode" getter="get_gi_mode" enum="GeometryInstance3D.GIMode" default="1" keywords="global_illumination_mode, light_bake_mode"> The global illumination mode to use for the whole geometry. To avoid inconsistent results, use a mode that matches the purpose of the mesh during gameplay (static/dynamic). @@ -111,19 +115,19 @@ <constant name="GI_MODE_DYNAMIC" value="2" enum="GIMode"> Dynamic global illumination mode. Use for dynamic objects that contribute to global illumination. This GI mode is only effective when using [VoxelGI], but it has a higher performance impact than [constant GI_MODE_STATIC]. When using other GI methods, this will act the same as [constant GI_MODE_DISABLED]. When using [LightmapGI], the object will receive indirect lighting using lightmap probes instead of using the baked lightmap texture. </constant> - <constant name="LIGHTMAP_SCALE_1X" value="0" enum="LightmapScale"> + <constant name="LIGHTMAP_SCALE_1X" value="0" enum="LightmapScale" deprecated="Use [member gi_lightmap_texel_scale] instead."> The standard texel density for lightmapping with [LightmapGI]. </constant> - <constant name="LIGHTMAP_SCALE_2X" value="1" enum="LightmapScale"> + <constant name="LIGHTMAP_SCALE_2X" value="1" enum="LightmapScale" deprecated="Use [member gi_lightmap_texel_scale] instead."> Multiplies texel density by 2× for lightmapping with [LightmapGI]. To ensure consistency in texel density, use this when scaling a mesh by a factor between 1.5 and 3.0. </constant> - <constant name="LIGHTMAP_SCALE_4X" value="2" enum="LightmapScale"> + <constant name="LIGHTMAP_SCALE_4X" value="2" enum="LightmapScale" deprecated="Use [member gi_lightmap_texel_scale] instead."> Multiplies texel density by 4× for lightmapping with [LightmapGI]. To ensure consistency in texel density, use this when scaling a mesh by a factor between 3.0 and 6.0. </constant> - <constant name="LIGHTMAP_SCALE_8X" value="3" enum="LightmapScale"> + <constant name="LIGHTMAP_SCALE_8X" value="3" enum="LightmapScale" deprecated="Use [member gi_lightmap_texel_scale] instead."> Multiplies texel density by 8× for lightmapping with [LightmapGI]. To ensure consistency in texel density, use this when scaling a mesh by a factor greater than 6.0. </constant> - <constant name="LIGHTMAP_SCALE_MAX" value="4" enum="LightmapScale"> + <constant name="LIGHTMAP_SCALE_MAX" value="4" enum="LightmapScale" deprecated="Use [member gi_lightmap_texel_scale] instead."> Represents the size of the [enum LightmapScale] enum. </constant> <constant name="VISIBILITY_RANGE_FADE_DISABLED" value="0" enum="VisibilityRangeFadeMode"> diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index fdaeb54bdf..7754a61e8c 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -29,7 +29,7 @@ <description> Adds an item to the item list with specified text. Returns the index of an added item. Specify an [param icon], or use [code]null[/code] as the [param icon] for a list item with no icon. - If selectable is [code]true[/code], the list item will be selectable. + If [param selectable] is [code]true[/code], the list item will be selectable. </description> </method> <method name="clear"> diff --git a/doc/classes/LightmapGI.xml b/doc/classes/LightmapGI.xml index e7d44411ef..0a492364ec 100644 --- a/doc/classes/LightmapGI.xml +++ b/doc/classes/LightmapGI.xml @@ -66,10 +66,11 @@ </member> <member name="quality" type="int" setter="set_bake_quality" getter="get_bake_quality" enum="LightmapGI.BakeQuality" default="1"> The quality preset to use when baking lightmaps. This affects bake times, but output file sizes remain mostly identical across quality levels. - To further speed up bake times, decrease [member bounces], disable [member use_denoiser] and increase the lightmap texel size on 3D scenes in the Import doc. + To further speed up bake times, decrease [member bounces], disable [member use_denoiser] and increase the lightmap texel size on 3D scenes in the Import dock. </member> <member name="texel_scale" type="float" setter="set_texel_scale" getter="get_texel_scale" default="1.0"> Scales the lightmap texel density of all meshes for the current bake. This is a multiplier that builds upon the existing lightmap texel size defined in each imported 3D scene, along with the per-mesh density multiplier (which is designed to be used when the same mesh is used at different scales). Lower values will result in faster bake times. + For example, doubling [member texel_scale] doubles the lightmap texture resolution for all objects [i]on each axis[/i], so it will [i]quadruple[/i] the texel count. </member> <member name="use_denoiser" type="bool" setter="set_use_denoiser" getter="is_using_denoiser" default="true"> If [code]true[/code], uses a GPU-based denoising algorithm on the generated lightmap. This eliminates most noise within the generated lightmap at the cost of longer bake times. File sizes are generally not impacted significantly by the use of a denoiser, although lossless compression may do a better job at compressing a denoised image. diff --git a/doc/classes/MainLoop.xml b/doc/classes/MainLoop.xml index 17cc0d78d3..2d88876d24 100644 --- a/doc/classes/MainLoop.xml +++ b/doc/classes/MainLoop.xml @@ -5,7 +5,7 @@ </brief_description> <description> [MainLoop] is the abstract base class for a Godot project's game loop. It is inherited by [SceneTree], which is the default game loop implementation used in Godot projects, though it is also possible to write and use one's own [MainLoop] subclass instead of the scene tree. - Upon the application start, a [MainLoop] implementation must be provided to the OS; otherwise, the application will exit. This happens automatically (and a [SceneTree] is created) unless a [MainLoop] [Script] is provided from the command line (with e.g. [code]godot -s my_loop.gd[/code]) or the "Main Loop Type" project setting is overwritten. + Upon the application start, a [MainLoop] implementation must be provided to the OS; otherwise, the application will exit. This happens automatically (and a [SceneTree] is created) unless a [MainLoop] [Script] is provided from the command line (with e.g. [code]godot -s my_loop.gd[/code]) or the [member ProjectSettings.application/run/main_loop_type] project setting is overwritten. Here is an example script implementing a simple [MainLoop]: [codeblocks] [gdscript] diff --git a/doc/classes/MultiplayerAPI.xml b/doc/classes/MultiplayerAPI.xml index d5016867a7..75cb13d25d 100644 --- a/doc/classes/MultiplayerAPI.xml +++ b/doc/classes/MultiplayerAPI.xml @@ -88,7 +88,7 @@ <param index="3" name="arguments" type="Array" default="[]" /> <description> Sends an RPC to the target [param peer]. The given [param method] will be called on the remote [param object] with the provided [param arguments]. The RPC may also be called locally depending on the implementation and RPC configuration. See [method Node.rpc] and [method Node.rpc_config]. - [b]Note:[/b] Prefer using [method Node.rpc], [method Node.rpc_id], or [code]my_method.rpc(peer, arg1, arg2, ...)[/code] (in GDScript), since they are faster. This method is mostly useful in conjunction with [MultiplayerAPIExtension] when augmenting or replacing the multiplayer capabilities. + [b]Note:[/b] Prefer using [method Node.rpc], [method Node.rpc_id], or [code]my_method.rpc(peer, arg1, arg2, ...)[/code] (in GDScript), since they are faster. This method is mostly useful in conjunction with [MultiplayerAPIExtension] when extending or replacing the multiplayer capabilities. </description> </method> <method name="set_default_interface" qualifiers="static"> diff --git a/doc/classes/MultiplayerAPIExtension.xml b/doc/classes/MultiplayerAPIExtension.xml index cc6d3b7fcf..acb6a2c176 100644 --- a/doc/classes/MultiplayerAPIExtension.xml +++ b/doc/classes/MultiplayerAPIExtension.xml @@ -4,14 +4,14 @@ Base class used for extending the [MultiplayerAPI]. </brief_description> <description> - This class can be used to augment or replace the default [MultiplayerAPI] implementation via script or extensions. - The following example augment the default implementation ([SceneMultiplayer]) by logging every RPC being made, and every object being configured for replication. + This class can be used to extend or replace the default [MultiplayerAPI] implementation via script or extensions. + The following example extend the default implementation ([SceneMultiplayer]) by logging every RPC being made, and every object being configured for replication. [codeblocks] [gdscript] extends MultiplayerAPIExtension class_name LogMultiplayer - # We want to augment the default SceneMultiplayer. + # We want to extend the default SceneMultiplayer. var base_multiplayer = SceneMultiplayer.new() func _init(): @@ -49,7 +49,7 @@ print("Removing node %s from the spawn list. Spawner: %s" % [object, config]) return base_multiplayer.object_configuration_remove(object, config) - # These can be optional, but in our case we want to augment SceneMultiplayer, so forward everything. + # These can be optional, but in our case we want to extend SceneMultiplayer, so forward everything. func _set_multiplayer_peer(p_peer: MultiplayerPeer): base_multiplayer.multiplayer_peer = p_peer @@ -69,7 +69,7 @@ # autoload.gd func _enter_tree(): # Sets our custom multiplayer as the main one in SceneTree. - get_tree().set_multiplayer(LogMultiplayer.new()) + get_tree().set_multiplayer(LogMultiplayer.new()) [/gdscript] [/codeblocks] Native extensions can alternatively use the [method MultiplayerAPI.set_default_interface] method during initialization to configure themselves as the default implementation. diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 49350597f5..5ab7c27f4f 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -23,7 +23,7 @@ <return type="void" /> <description> Shuts down the system MIDI driver. Godot will no longer receive [InputEventMIDI]. See also [method open_midi_inputs] and [method get_connected_midi_inputs]. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. + [b]Note:[/b] This method is implemented on Linux, macOS, and Windows. </description> </method> <method name="crash"> @@ -244,7 +244,7 @@ <return type="PackedStringArray" /> <description> Returns an array of connected MIDI device names, if they exist. Returns an empty array if the system MIDI driver has not previously been initialized with [method open_midi_inputs]. See also [method close_midi_inputs]. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. + [b]Note:[/b] This method is implemented on Linux, macOS, and Windows. </description> </method> <method name="get_data_dir" qualifiers="const"> @@ -466,6 +466,24 @@ Returns the amount of static memory being used by the program in bytes. Only works in debug builds. </description> </method> + <method name="get_stderr_type" qualifiers="const"> + <return type="int" enum="OS.StdHandleType" /> + <description> + Returns type of the standard error device. + </description> + </method> + <method name="get_stdin_type" qualifiers="const"> + <return type="int" enum="OS.StdHandleType" /> + <description> + Returns type of the standard input device. + </description> + </method> + <method name="get_stdout_type" qualifiers="const"> + <return type="int" enum="OS.StdHandleType" /> + <description> + Returns type of the standard output device. + </description> + </method> <method name="get_system_ca_certificates"> <return type="String" /> <description> @@ -680,15 +698,31 @@ <return type="void" /> <description> Initializes the singleton for the system MIDI driver, allowing Godot to receive [InputEventMIDI]. See also [method get_connected_midi_inputs] and [method close_midi_inputs]. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. + [b]Note:[/b] This method is implemented on Linux, macOS, and Windows. + </description> + </method> + <method name="read_buffer_from_stdin"> + <return type="PackedByteArray" /> + <param index="0" name="buffer_size" type="int" /> + <description> + Reads a user input as raw data from the standard input. This operation can be [i]blocking[/i], which causes the window to freeze if [method read_string_from_stdin] is called on the main thread. + - If standard input is console, this method will block until the program receives a line break in standard input (usually by the user pressing [kbd]Enter[/kbd]). + - If standard input is pipe, this method will block until a specific amount of data is read or pipe is closed. + - If standard input is a file, this method will read a specific amount of data (or less if end-of-file is reached) and return immediately. + [b]Note:[/b] This method is implemented on Linux, macOS, and Windows. + [b]Note:[/b] On exported Windows builds, run the console wrapper executable to access the terminal. If standard input is console, calling this method without console wrapped will freeze permanently. If standard input is pipe or file, it can be used without console wrapper. If you need a single executable with full console support, use a custom build compiled with the [code]windows_subsystem=console[/code] flag. </description> </method> <method name="read_string_from_stdin"> <return type="String" /> + <param index="0" name="buffer_size" type="int" /> <description> - Reads a user input string from the standard input (usually the terminal). This operation is [i]blocking[/i], which causes the window to freeze if [method read_string_from_stdin] is called on the main thread. The thread calling [method read_string_from_stdin] will block until the program receives a line break in standard input (usually by the user pressing [kbd]Enter[/kbd]). - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. - [b]Note:[/b] On exported Windows builds, run the console wrapper executable to access the terminal. Otherwise, the standard input will not work correctly. If you need a single executable with console support, use a custom build compiled with the [code]windows_subsystem=console[/code] flag. + Reads a user input as a UTF-8 encoded string from the standard input. This operation can be [i]blocking[/i], which causes the window to freeze if [method read_string_from_stdin] is called on the main thread. + - If standard input is console, this method will block until the program receives a line break in standard input (usually by the user pressing [kbd]Enter[/kbd]). + - If standard input is pipe, this method will block until a specific amount of data is read or pipe is closed. + - If standard input is a file, this method will read a specific amount of data (or less if end-of-file is reached) and return immediately. + [b]Note:[/b] This method is implemented on Linux, macOS, and Windows. + [b]Note:[/b] On exported Windows builds, run the console wrapper executable to access the terminal. If standard input is console, calling this method without console wrapped will freeze permanently. If standard input is pipe or file, it can be used without console wrapper. If you need a single executable with full console support, use a custom build compiled with the [code]windows_subsystem=console[/code] flag. </description> </method> <method name="request_permission"> @@ -831,5 +865,20 @@ <constant name="SYSTEM_DIR_RINGTONES" value="7" enum="SystemDir"> Refers to the Ringtones directory path. </constant> + <constant name="STD_HANDLE_INVALID" value="0" enum="StdHandleType"> + Standard I/O device is invalid. No data can be received from or sent to these standard I/O devices. + </constant> + <constant name="STD_HANDLE_CONSOLE" value="1" enum="StdHandleType"> + Standard I/O device is a console. This typically occurs when Godot is run from a terminal with no redirection. This is also used for all standard I/O devices when running Godot from the editor, at least on desktop platforms. + </constant> + <constant name="STD_HANDLE_FILE" value="2" enum="StdHandleType"> + Standard I/O device is a regular file. This typically occurs with redirection from a terminal, e.g. [code]godot > stdout.txt[/code], [code]godot < stdin.txt[/code] or [code]godot > stdout_stderr.txt 2>&1[/code]. + </constant> + <constant name="STD_HANDLE_PIPE" value="3" enum="StdHandleType"> + Standard I/O device is a FIFO/pipe. This typically occurs with pipe usage from a terminal, e.g. [code]echo "Hello" | godot[/code]. + </constant> + <constant name="STD_HANDLE_UNKNOWN" value="4" enum="StdHandleType"> + Standard I/O device type is unknown. + </constant> </constants> </class> diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml index 81f666dd16..d0c193ea31 100644 --- a/doc/classes/Object.xml +++ b/doc/classes/Object.xml @@ -343,7 +343,7 @@ return "Welcome to Godot 4!" func _init(): - print(self) # Prints Welcome to Godot 4!" + print(self) # Prints "Welcome to Godot 4!" var a = str(self) # a is "Welcome to Godot 4!" [/codeblock] </description> @@ -406,7 +406,7 @@ <param index="0" name="signal" type="String" /> <param index="1" name="arguments" type="Array" default="[]" /> <description> - Adds a user-defined [param signal]. Optional arguments for the signal can be added as an [Array] of dictionaries, each defining a [code]name[/code] [String] and a [code]type[/code] [int] (see [enum Variant.Type]). See also [method has_user_signal] and [method remove_user_signal]. + Adds a user-defined signal named [param signal]. Optional arguments for the signal can be added as an [Array] of dictionaries, each defining a [code]name[/code] [String] and a [code]type[/code] [int] (see [enum Variant.Type]). See also [method has_user_signal] and [method remove_user_signal]. [codeblocks] [gdscript] add_user_signal("hurt", [ diff --git a/doc/classes/PhysicalBone3D.xml b/doc/classes/PhysicalBone3D.xml index eda9fd6af5..e2ad3db0a5 100644 --- a/doc/classes/PhysicalBone3D.xml +++ b/doc/classes/PhysicalBone3D.xml @@ -57,7 +57,7 @@ </methods> <members> <member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" default="0.0"> - Damps the body's rotation. By default, the body will use the [b]Default Angular Damp[/b] in [b]Project > Project Settings > Physics > 3d[/b] or any value override set by an [Area3D] the body is in. Depending on [member angular_damp_mode], you can set [member angular_damp] to be added to or to replace the body's damping value. + Damps the body's rotation. By default, the body will use the [member ProjectSettings.physics/3d/default_angular_damp] project setting or any value override set by an [Area3D] the body is in. Depending on [member angular_damp_mode], you can set [member angular_damp] to be added to or to replace the body's damping value. See [member ProjectSettings.physics/3d/default_angular_damp] for more details about damping. </member> <member name="angular_damp_mode" type="int" setter="set_angular_damp_mode" getter="get_angular_damp_mode" enum="PhysicalBone3D.DampMode" default="0"> diff --git a/doc/classes/Range.xml b/doc/classes/Range.xml index 820ff04b70..a76676489f 100644 --- a/doc/classes/Range.xml +++ b/doc/classes/Range.xml @@ -54,7 +54,7 @@ Minimum value. Range is clamped if [member value] is less than [member min_value]. </member> <member name="page" type="float" setter="set_page" getter="get_page" default="0.0"> - Page size. Used mainly for [ScrollBar]. ScrollBar's length is its size multiplied by [member page] over the difference between [member min_value] and [member max_value]. + Page size. Used mainly for [ScrollBar]. A [ScrollBar]'s grabber length is the [ScrollBar]'s size multiplied by [member page] over the difference between [member min_value] and [member max_value]. </member> <member name="ratio" type="float" setter="set_as_ratio" getter="get_as_ratio"> The value mapped between 0 and 1. diff --git a/doc/classes/RenderData.xml b/doc/classes/RenderData.xml index 065505e6c6..c2a598c43f 100644 --- a/doc/classes/RenderData.xml +++ b/doc/classes/RenderData.xml @@ -19,7 +19,7 @@ <method name="get_environment" qualifiers="const"> <return type="RID" /> <description> - Returns the [RID] of the environments object in the [RenderingServer] being used to render this viewport. + Returns the [RID] of the environment object in the [RenderingServer] being used to render this viewport. </description> </method> <method name="get_render_scene_buffers" qualifiers="const"> diff --git a/doc/classes/RenderSceneBuffersRD.xml b/doc/classes/RenderSceneBuffersRD.xml index 7b5aac5b61..6a5aba1dbc 100644 --- a/doc/classes/RenderSceneBuffersRD.xml +++ b/doc/classes/RenderSceneBuffersRD.xml @@ -52,7 +52,7 @@ <param index="2" name="view_name" type="StringName" /> <param index="3" name="view" type="RDTextureView" /> <description> - Create a new texture view for an existing texture and cache this under the given view_name. Will return the existing teture view if it already exists. Will error if the source texture doesn't exist. + Create a new texture view for an existing texture and cache this under the given [param view_name]. Will return the existing texture view if it already exists. Will error if the source texture doesn't exist. </description> </method> <method name="get_color_layer"> diff --git a/doc/classes/ResourceImporterTexture.xml b/doc/classes/ResourceImporterTexture.xml index 0761702aa1..a39e48c7bf 100644 --- a/doc/classes/ResourceImporterTexture.xml +++ b/doc/classes/ResourceImporterTexture.xml @@ -90,9 +90,13 @@ <member name="process/size_limit" type="int" setter="" getter="" default="0"> If set to a value greater than [code]0[/code], the size of the texture is limited on import to a value smaller than or equal to the value specified here. For non-square textures, the size limit affects the longer dimension, with the shorter dimension scaled to preserve aspect ratio. Resizing is performed using cubic interpolation. This can be used to reduce memory usage without affecting the source images, or avoid issues with textures not displaying on mobile/web platforms (as these usually can't display textures larger than 4096×4096). + [b]Note:[/b] Even if this is set to [code]0[/code], import size is limited to the following dimensions for technical reasons. Depending on [member compress/mode], textures will be downsampled on import if necessary: + - [b]Lossy:[/b] 16383 pixels width or height, whichever is larger; + - [b]Basis Universal:[/b] 16384 pixels width or height, whichever is larger; + - [b]All other modes:[/b] 32768 pixels width or height, whichever is larger. </member> <member name="roughness/mode" type="int" setter="" getter="" default="0"> - The color channel to consider as a roughness map in this texture. Only effective if Roughness > Src Normal is not empty. + The color channel to consider as a roughness map in this texture. Only effective if [member roughness/src_normal] is not empty. </member> <member name="roughness/src_normal" type="String" setter="" getter="" default=""""> The path to the texture to consider as a normal map for roughness filtering on import. Specifying this can help decrease specular aliasing slightly in 3D. diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml index 5661d1a276..1977b238e4 100644 --- a/doc/classes/RigidBody2D.xml +++ b/doc/classes/RigidBody2D.xml @@ -123,7 +123,7 @@ </methods> <members> <member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" default="0.0"> - Damps the body's rotation. By default, the body will use the [b]Default Angular Damp[/b] in [b]Project > Project Settings > Physics > 2d[/b] or any value override set by an [Area2D] the body is in. Depending on [member angular_damp_mode], you can set [member angular_damp] to be added to or to replace the body's damping value. + Damps the body's rotation. By default, the body will use the [member ProjectSettings.physics/2d/default_angular_damp] setting or any value override set by an [Area2D] the body is in. Depending on [member angular_damp_mode], you can set [member angular_damp] to be added to or to replace the body's damping value. See [member ProjectSettings.physics/2d/default_angular_damp] for more details about damping. </member> <member name="angular_damp_mode" type="int" setter="set_angular_damp_mode" getter="get_angular_damp_mode" enum="RigidBody2D.DampMode" default="0"> @@ -172,7 +172,7 @@ For a body that is always frozen, use [StaticBody2D] or [AnimatableBody2D] instead. </member> <member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0"> - Multiplies the gravity applied to the body. The body's gravity is calculated from the [b]Default Gravity[/b] value in [b]Project > Project Settings > Physics > 2d[/b] and/or any additional gravity vector applied by [Area2D]s. + Multiplies the gravity applied to the body. The body's gravity is calculated from the [member ProjectSettings.physics/2d/default_gravity] project setting and/or any additional gravity vector applied by [Area2D]s. </member> <member name="inertia" type="float" setter="set_inertia" getter="get_inertia" default="0.0"> The body's moment of inertia. This is like mass, but for rotation: it determines how much torque it takes to rotate the body. The moment of inertia is usually computed automatically from the mass and the shapes, but this property allows you to set a custom value. @@ -201,7 +201,7 @@ [/codeblocks] </member> <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" default="0.0"> - Damps the body's movement. By default, the body will use the [b]Default Linear Damp[/b] in [b]Project > Project Settings > Physics > 2d[/b] or any value override set by an [Area2D] the body is in. Depending on [member linear_damp_mode], you can set [member linear_damp] to be added to or to replace the body's damping value. + Damps the body's movement. By default, the body will use the [member ProjectSettings.physics/2d/default_linear_damp] setting or any value override set by an [Area2D] the body is in. Depending on [member linear_damp_mode], you can set [member linear_damp] to be added to or to replace the body's damping value. See [member ProjectSettings.physics/2d/default_linear_damp] for more details about damping. </member> <member name="linear_damp_mode" type="int" setter="set_linear_damp_mode" getter="get_linear_damp_mode" enum="RigidBody2D.DampMode" default="0"> diff --git a/doc/classes/RigidBody3D.xml b/doc/classes/RigidBody3D.xml index 9a299ade57..de6d5cde3d 100644 --- a/doc/classes/RigidBody3D.xml +++ b/doc/classes/RigidBody3D.xml @@ -130,7 +130,7 @@ </methods> <members> <member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" default="0.0"> - Damps the body's rotation. By default, the body will use the [b]Default Angular Damp[/b] in [b]Project > Project Settings > Physics > 3d[/b] or any value override set by an [Area3D] the body is in. Depending on [member angular_damp_mode], you can set [member angular_damp] to be added to or to replace the body's damping value. + Damps the body's rotation. By default, the body will use the [member ProjectSettings.physics/3d/default_angular_damp] project setting or any value override set by an [Area3D] the body is in. Depending on [member angular_damp_mode], you can set [member angular_damp] to be added to or to replace the body's damping value. See [member ProjectSettings.physics/3d/default_angular_damp] for more details about damping. </member> <member name="angular_damp_mode" type="int" setter="set_angular_damp_mode" getter="get_angular_damp_mode" enum="RigidBody3D.DampMode" default="0"> @@ -208,7 +208,7 @@ [/codeblocks] </member> <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" default="0.0"> - Damps the body's movement. By default, the body will use the [b]Default Linear Damp[/b] in [b]Project > Project Settings > Physics > 3d[/b] or any value override set by an [Area3D] the body is in. Depending on [member linear_damp_mode], you can set [member linear_damp] to be added to or to replace the body's damping value. + Damps the body's movement. By default, the body will use the [member ProjectSettings.physics/3d/default_linear_damp] project setting or any value override set by an [Area3D] the body is in. Depending on [member linear_damp_mode], you can set [member linear_damp] to be added to or to replace the body's damping value. See [member ProjectSettings.physics/3d/default_linear_damp] for more details about damping. </member> <member name="linear_damp_mode" type="int" setter="set_linear_damp_mode" getter="get_linear_damp_mode" enum="RigidBody3D.DampMode" default="0"> diff --git a/doc/classes/SplitContainer.xml b/doc/classes/SplitContainer.xml index 650c396190..daafbbdd87 100644 --- a/doc/classes/SplitContainer.xml +++ b/doc/classes/SplitContainer.xml @@ -30,7 +30,7 @@ </methods> <members> <member name="collapsed" type="bool" setter="set_collapsed" getter="is_collapsed" default="false"> - If [code]true[/code], the area of the first [Control] will be collapsed and the dragger will be disabled. + If [code]true[/code], the dragger will be disabled and the children will be sized as if the [member split_offset] was [code]0[/code]. </member> <member name="drag_area_highlight_in_editor" type="bool" setter="set_drag_area_highlight_in_editor" getter="is_drag_area_highlight_in_editor_enabled" default="false"> Highlights the drag area [Rect2] so you can see where it is during development. The drag area is gold if [member dragging_enabled] is [code]true[/code], and red if [code]false[/code]. diff --git a/doc/classes/String.xml b/doc/classes/String.xml index e59734cf03..d0512b8e1c 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -248,7 +248,7 @@ <param index="1" name="placeholder" type="String" default=""{_}"" /> <description> Formats the string by replacing all occurrences of [param placeholder] with the elements of [param values]. - [param values] can be a [Dictionary], an [Array] or an [Object]. Any underscores in [param placeholder] will be replaced with the corresponding keys in advance. Array elements use their index as keys. + [param values] can be a [Dictionary], an [Array], or an [Object]. Any underscores in [param placeholder] will be replaced with the corresponding keys in advance. Array elements use their index as keys. [codeblock] # Prints "Waiting for Godot is a play by Samuel Beckett, and Godot Engine is named after it." var use_array_values = "Waiting for {0} is a play by {1}, and {0} Engine is named after it." @@ -265,7 +265,7 @@ [/codeblock] When passing an [Object], the property names from [method Object.get_property_list] are used as keys. [codeblock] - # Prints: Visible true, position (0, 0). + # Prints "Visible true, position (0, 0)" var node = Node2D.new() print("Visible {visible}, position {position}".format(node)) [/codeblock] diff --git a/doc/classes/StringName.xml b/doc/classes/StringName.xml index 4982bc36a8..e561ef54fa 100644 --- a/doc/classes/StringName.xml +++ b/doc/classes/StringName.xml @@ -231,7 +231,7 @@ <param index="1" name="placeholder" type="String" default=""{_}"" /> <description> Formats the string by replacing all occurrences of [param placeholder] with the elements of [param values]. - [param values] can be a [Dictionary] or an [Array]. Any underscores in [param placeholder] will be replaced with the corresponding keys in advance. Array elements use their index as keys. + [param values] can be a [Dictionary], an [Array], or an [Object]. Any underscores in [param placeholder] will be replaced with the corresponding keys in advance. Array elements use their index as keys. [codeblock] # Prints "Waiting for Godot is a play by Samuel Beckett, and Godot Engine is named after it." var use_array_values = "Waiting for {0} is a play by {1}, and {0} Engine is named after it." @@ -246,6 +246,12 @@ print("User {} is {}.".format([42, "Godot"], "{}")) print("User {id} is {name}.".format([["id", 42], ["name", "Godot"]])) [/codeblock] + When passing an [Object], the property names from [method Object.get_property_list] are used as keys. + [codeblock] + # Prints "Visible true, position (0, 0)" + var node = Node2D.new() + print("Visible {visible}, position {position}".format(node)) + [/codeblock] See also the [url=$DOCS_URL/tutorials/scripting/gdscript/gdscript_format_string.html]GDScript format string[/url] tutorial. [b]Note:[/b] Each replacement is done sequentially for each element of [param values], [b]not[/b] all at once. This means that if any element is inserted and it contains another placeholder, it may be changed by the next replacement. While this can be very useful, it often causes unexpected results. If not necessary, make sure [param values]'s elements do not contain placeholders. [codeblock] diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml index 9c1525d8f8..9265e6b345 100644 --- a/doc/classes/SurfaceTool.xml +++ b/doc/classes/SurfaceTool.xml @@ -140,7 +140,7 @@ <param index="0" name="flip" type="bool" default="false" /> <description> Generates normals from vertices so you do not have to do it manually. If [param flip] is [code]true[/code], the resulting normals will be inverted. [method generate_normals] should be called [i]after[/i] generating geometry and [i]before[/i] committing the mesh using [method commit] or [method commit_to_arrays]. For correct display of normal-mapped surfaces, you will also have to generate tangents using [method generate_tangents]. - [b]Note:[/b] [method generate_normals] only works if the primitive type to be set to [constant Mesh.PRIMITIVE_TRIANGLES]. + [b]Note:[/b] [method generate_normals] only works if the primitive type is set to [constant Mesh.PRIMITIVE_TRIANGLES]. [b]Note:[/b] [method generate_normals] takes smooth groups into account. To generate smooth normals, set the smooth group to a value greater than or equal to [code]0[/code] using [method set_smooth_group] or leave the smooth group at the default of [code]0[/code]. To generate flat normals, set the smooth group to [code]-1[/code] using [method set_smooth_group] prior to adding vertices. </description> </method> diff --git a/doc/classes/TextureProgressBar.xml b/doc/classes/TextureProgressBar.xml index d3e334ef55..c68b521da9 100644 --- a/doc/classes/TextureProgressBar.xml +++ b/doc/classes/TextureProgressBar.xml @@ -42,6 +42,7 @@ </member> <member name="radial_initial_angle" type="float" setter="set_radial_initial_angle" getter="get_radial_initial_angle" default="0.0"> Starting angle for the fill of [member texture_progress] if [member fill_mode] is [constant FILL_CLOCKWISE], [constant FILL_COUNTER_CLOCKWISE], or [constant FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE]. When the node's [code]value[/code] is equal to its [code]min_value[/code], the texture doesn't show up at all. When the [code]value[/code] increases, the texture fills and tends towards [member radial_fill_degrees]. + [b]Note:[/b] [member radial_initial_angle] is wrapped between [code]0[/code] and [code]360[/code] degrees (inclusive). </member> <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" overrides="Control" enum="Control.SizeFlags" is_bitfield="true" default="1" /> <member name="step" type="float" setter="set_step" getter="get_step" overrides="Range" default="1.0" /> diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml index 3ad0a73b41..147d9fa4bd 100644 --- a/doc/classes/Tween.xml +++ b/doc/classes/Tween.xml @@ -218,8 +218,14 @@ <return type="Tween" /> <param index="0" name="ease" type="int" enum="Tween.EaseType" /> <description> - Sets the default ease type for [PropertyTweener]s and [MethodTweener]s animated by this [Tween]. - If not specified, the default value is [constant EASE_IN_OUT]. + Sets the default ease type for [PropertyTweener]s and [MethodTweener]s appended after this method. + Before this method is called, the default ease type is [constant EASE_IN_OUT]. + [codeblock] + var tween = create_tween() + tween.tween_property(self, "position", Vector2(300, 0), 0.5) # Uses EASE_IN_OUT. + tween.set_ease(Tween.EASE_IN) + tween.tween_property(self, "rotation_degrees", 45.0, 0.5) # Uses EASE_IN. + [/codeblock] </description> </method> <method name="set_loops"> @@ -271,8 +277,14 @@ <return type="Tween" /> <param index="0" name="trans" type="int" enum="Tween.TransitionType" /> <description> - Sets the default transition type for [PropertyTweener]s and [MethodTweener]s animated by this [Tween]. - If not specified, the default value is [constant TRANS_LINEAR]. + Sets the default transition type for [PropertyTweener]s and [MethodTweener]s appended after this method. + Before this method is called, the default transition type is [constant TRANS_LINEAR]. + [codeblock] + var tween = create_tween() + tween.tween_property(self, "position", Vector2(300, 0), 0.5) # Uses TRANS_LINEAR. + tween.set_trans(Tween.TRANS_SINE) + tween.tween_property(self, "rotation_degrees", 45.0, 0.5) # Uses TRANS_SINE. + [/codeblock] </description> </method> <method name="stop"> diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index c4319fd360..78b6d527ea 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -316,7 +316,7 @@ See also [member ProjectSettings.rendering/anti_aliasing/quality/msaa_2d] and [method RenderingServer.viewport_set_msaa_2d]. </member> <member name="msaa_3d" type="int" setter="set_msaa_3d" getter="get_msaa_3d" enum="Viewport.MSAA" default="0"> - The multisample antialiasing mode for 3D rendering. A higher number results in smoother edges at the cost of significantly worse performance. A value of [constant Viewport.MSAA_2X] or [constant Viewport.MSAA_4X] 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. + The multisample antialiasing mode for 3D rendering. A higher number results in smoother edges at the cost of significantly worse performance. A value of [constant Viewport.MSAA_2X] or [constant Viewport.MSAA_4X] 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. See also [member ProjectSettings.rendering/anti_aliasing/quality/msaa_3d] and [method RenderingServer.viewport_set_msaa_3d]. </member> <member name="own_world_3d" type="bool" setter="set_use_own_world_3d" getter="is_using_own_world_3d" default="false"> @@ -357,7 +357,7 @@ [b]Note:[/b] If this is set to [code]0[/code], no positional shadows will be visible at all. This can improve performance significantly on low-end systems by reducing both the CPU and GPU load (as fewer draw calls are needed to draw the scene without shadows). </member> <member name="scaling_3d_mode" type="int" setter="set_scaling_3d_mode" getter="get_scaling_3d_mode" enum="Viewport.Scaling3DMode" default="0"> - Sets 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. + Sets 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. 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"> diff --git a/doc/classes/XRCamera3D.xml b/doc/classes/XRCamera3D.xml index a7904b3ada..e49e884f33 100644 --- a/doc/classes/XRCamera3D.xml +++ b/doc/classes/XRCamera3D.xml @@ -4,7 +4,7 @@ A camera node with a few overrules for AR/VR applied, such as location tracking. </brief_description> <description> - This is a helper spatial node for our camera; note that, if stereoscopic rendering is applicable (VR-HMD), most of the camera properties are ignored, as the HMD information overrides them. The only properties that can be trusted are the near and far planes. + This is a helper 3D node for our camera. Note that, if stereoscopic rendering is applicable (VR-HMD), most of the camera properties are ignored, as the HMD information overrides them. The only properties that can be trusted are the near and far planes. The position and orientation of this node is automatically updated by the XR Server to represent the location of the HMD if such tracking is available and can thus be used by game logic. Note that, in contrast to the XR Controller, the render thread has access to the most up-to-date tracking data of the HMD and the location of the XRCamera3D can lag a few milliseconds behind what is used for rendering as a result. </description> <tutorials> diff --git a/doc/classes/XRController3D.xml b/doc/classes/XRController3D.xml index 8a068661c9..508752e0ae 100644 --- a/doc/classes/XRController3D.xml +++ b/doc/classes/XRController3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="XRController3D" inherits="XRNode3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> <brief_description> - A spatial node representing a spatially-tracked controller. + A 3D node representing a spatially-tracked controller. </brief_description> <description> - This is a helper spatial node that is linked to the tracking of controllers. It also offers several handy passthroughs to the state of buttons and such on the controllers. + This is a helper 3D node that is linked to the tracking of controllers. It also offers several handy passthroughs to the state of buttons and such on the controllers. Controllers are linked by their ID. You can create controller nodes before the controllers are available. If your game always uses two controllers (one for each hand), you can predefine the controllers with ID 1 and 2; they will become active as soon as the controllers are identified. If you expect additional controllers to be used, you should react to the signals and add XRController3D nodes to your scene. The position of the controller node is automatically updated by the [XRServer]. This makes this node ideal to add child nodes to visualize the controller. As many XR runtimes now use a configurable action map all inputs are named. diff --git a/doc/classes/XRNode3D.xml b/doc/classes/XRNode3D.xml index 82f4fa4ab9..fce3708d9a 100644 --- a/doc/classes/XRNode3D.xml +++ b/doc/classes/XRNode3D.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="XRNode3D" inherits="Node3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> <brief_description> - A spatial node that has its position automatically updated by the [XRServer]. + A 3D node that has its position automatically updated by the [XRServer]. </brief_description> <description> This node can be bound to a specific pose of a [XRPositionalTracker] and will automatically have its [member Node3D.transform] updated by the [XRServer]. Nodes of this type must be added as children of the [XROrigin3D] node. diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index 0c9635339b..6ee22b6eb5 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -80,7 +80,7 @@ Error AudioDriverALSA::init_output_device() { status = snd_pcm_open(&pcm_handle, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); } else { String device = output_device_name; - int pos = device.find(";"); + int pos = device.find_char(';'); if (pos != -1) { device = device.substr(0, pos); } diff --git a/drivers/d3d12/rendering_device_driver_d3d12.cpp b/drivers/d3d12/rendering_device_driver_d3d12.cpp index 0cc89dfaca..0b1b0651c8 100644 --- a/drivers/d3d12/rendering_device_driver_d3d12.cpp +++ b/drivers/d3d12/rendering_device_driver_d3d12.cpp @@ -2160,6 +2160,7 @@ RDD::FenceID RenderingDeviceDriverD3D12::fence_create() { Error RenderingDeviceDriverD3D12::fence_wait(FenceID p_fence) { FenceInfo *fence = (FenceInfo *)(p_fence.id); + fence->d3d_fence->SetEventOnCompletion(fence->fence_value, fence->event_handle); DWORD res = WaitForSingleObjectEx(fence->event_handle, INFINITE, FALSE); #ifdef PIX_ENABLED PIXNotifyWakeFromFenceSignal(fence->event_handle); @@ -2254,7 +2255,6 @@ Error RenderingDeviceDriverD3D12::command_queue_execute_and_present(CommandQueue FenceInfo *fence = (FenceInfo *)(p_cmd_fence.id); fence->fence_value++; command_queue->d3d_queue->Signal(fence->d3d_fence.Get(), fence->fence_value); - fence->d3d_fence->SetEventOnCompletion(fence->fence_value, fence->event_handle); } } diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 0138f99d50..2fd3f7d7e2 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -687,6 +687,8 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou state.current_tex = RID(); + const uint64_t base_specialization = GLES3::Config::get_singleton()->float_texture_supported ? 0 : CanvasShaderGLES3::USE_RGBA_SHADOWS; + for (uint32_t i = 0; i <= state.current_batch_index; i++) { // Skipping when there is no instances. if (state.canvas_instance_batches[i].instance_count == 0) { @@ -705,10 +707,9 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou } GLES3::CanvasMaterialData *material_data = state.canvas_instance_batches[i].material_data; - CanvasShaderGLES3::ShaderVariant variant = state.canvas_instance_batches[i].shader_variant; - uint64_t specialization = 0; - specialization |= uint64_t(state.canvas_instance_batches[i].lights_disabled); - specialization |= uint64_t(!GLES3::Config::get_singleton()->float_texture_supported) << 1; + CanvasShaderGLES3::ShaderVariant variant = CanvasShaderGLES3::MODE_DEFAULT; + uint64_t specialization = state.canvas_instance_batches[i].specialization; + specialization |= base_specialization; RID shader_version = data.canvas_shader_default_version; if (material_data) { @@ -810,6 +811,7 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_render_target, const Transform2D &p_canvas_transform_inverse, Item *¤t_clip, GLES3::CanvasShaderData::BlendMode p_blend_mode, Light *p_lights, uint32_t &r_index, bool &r_batch_broken, bool &r_sdf_used, const Point2 &p_repeat_offset) { RenderingServer::CanvasItemTextureFilter texture_filter = p_item->texture_filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT ? state.default_filter : p_item->texture_filter; + const uint64_t specialization_command_mask = ~(CanvasShaderGLES3::USE_NINEPATCH | CanvasShaderGLES3::USE_PRIMITIVE | CanvasShaderGLES3::USE_ATTRIBUTES | CanvasShaderGLES3::USE_INSTANCING); if (texture_filter != state.canvas_instance_batches[state.current_batch_index].filter) { _new_batch(r_batch_broken); @@ -868,9 +870,9 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend bool lights_disabled = light_count == 0 && !state.using_directional_lights; - if (lights_disabled != state.canvas_instance_batches[state.current_batch_index].lights_disabled) { + if (lights_disabled != bool(state.canvas_instance_batches[state.current_batch_index].specialization & CanvasShaderGLES3::DISABLE_LIGHTING)) { _new_batch(r_batch_broken); - state.canvas_instance_batches[state.current_batch_index].lights_disabled = lights_disabled; + state.canvas_instance_batches[state.current_batch_index].specialization ^= CanvasShaderGLES3::DISABLE_LIGHTING; } const Item::Command *c = p_item->commands; @@ -936,7 +938,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend state.canvas_instance_batches[state.current_batch_index].tex = rect->texture; state.canvas_instance_batches[state.current_batch_index].command_type = Item::Command::TYPE_RECT; state.canvas_instance_batches[state.current_batch_index].command = c; - state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_QUAD; + state.canvas_instance_batches[state.current_batch_index].specialization &= specialization_command_mask; } _prepare_canvas_texture(rect->texture, state.canvas_instance_batches[state.current_batch_index].filter, state.canvas_instance_batches[state.current_batch_index].repeat, r_index, texpixel_size); @@ -1026,7 +1028,8 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend state.canvas_instance_batches[state.current_batch_index].tex = np->texture; state.canvas_instance_batches[state.current_batch_index].command_type = Item::Command::TYPE_NINEPATCH; state.canvas_instance_batches[state.current_batch_index].command = c; - state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_NINEPATCH; + state.canvas_instance_batches[state.current_batch_index].specialization &= specialization_command_mask; + state.canvas_instance_batches[state.current_batch_index].specialization |= CanvasShaderGLES3::USE_NINEPATCH; } _prepare_canvas_texture(np->texture, state.canvas_instance_batches[state.current_batch_index].filter, state.canvas_instance_batches[state.current_batch_index].repeat, r_index, texpixel_size); @@ -1092,7 +1095,8 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend state.canvas_instance_batches[state.current_batch_index].tex = polygon->texture; state.canvas_instance_batches[state.current_batch_index].command_type = Item::Command::TYPE_POLYGON; state.canvas_instance_batches[state.current_batch_index].command = c; - state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_ATTRIBUTES; + state.canvas_instance_batches[state.current_batch_index].specialization &= specialization_command_mask; + state.canvas_instance_batches[state.current_batch_index].specialization |= CanvasShaderGLES3::USE_ATTRIBUTES; _prepare_canvas_texture(polygon->texture, state.canvas_instance_batches[state.current_batch_index].filter, state.canvas_instance_batches[state.current_batch_index].repeat, r_index, texpixel_size); @@ -1119,7 +1123,8 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend state.canvas_instance_batches[state.current_batch_index].primitive_points = primitive->point_count; state.canvas_instance_batches[state.current_batch_index].command_type = Item::Command::TYPE_PRIMITIVE; state.canvas_instance_batches[state.current_batch_index].command = c; - state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_PRIMITIVE; + state.canvas_instance_batches[state.current_batch_index].specialization &= specialization_command_mask; + state.canvas_instance_batches[state.current_batch_index].specialization |= CanvasShaderGLES3::USE_PRIMITIVE; } _prepare_canvas_texture(state.canvas_instance_batches[state.current_batch_index].tex, state.canvas_instance_batches[state.current_batch_index].filter, state.canvas_instance_batches[state.current_batch_index].repeat, r_index, texpixel_size); @@ -1164,7 +1169,8 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend _new_batch(r_batch_broken); Color modulate(1, 1, 1, 1); - state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_ATTRIBUTES; + state.canvas_instance_batches[state.current_batch_index].specialization &= specialization_command_mask; + state.canvas_instance_batches[state.current_batch_index].specialization |= CanvasShaderGLES3::USE_ATTRIBUTES; if (c->type == Item::Command::TYPE_MESH) { const Item::CommandMesh *m = static_cast<const Item::CommandMesh *>(c); state.canvas_instance_batches[state.current_batch_index].tex = m->texture; @@ -1174,7 +1180,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend } else if (c->type == Item::Command::TYPE_MULTIMESH) { const Item::CommandMultiMesh *mm = static_cast<const Item::CommandMultiMesh *>(c); state.canvas_instance_batches[state.current_batch_index].tex = mm->texture; - state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_INSTANCED; + state.canvas_instance_batches[state.current_batch_index].specialization |= CanvasShaderGLES3::USE_INSTANCING; if (GLES3::MeshStorage::get_singleton()->multimesh_uses_colors(mm->multimesh)) { state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_COLORS; @@ -1189,7 +1195,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend const Item::CommandParticles *pt = static_cast<const Item::CommandParticles *>(c); RID particles = pt->particles; state.canvas_instance_batches[state.current_batch_index].tex = pt->texture; - state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_INSTANCED; + state.canvas_instance_batches[state.current_batch_index].specialization |= CanvasShaderGLES3::USE_INSTANCING; state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_COLORS; state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_CUSTOM_DATA; diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h index a82e2713e0..b9d9a44e2a 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.h +++ b/drivers/gles3/rasterizer_canvas_gles3.h @@ -273,14 +273,12 @@ public: RID material; GLES3::CanvasMaterialData *material_data = nullptr; - CanvasShaderGLES3::ShaderVariant shader_variant = CanvasShaderGLES3::MODE_QUAD; uint64_t vertex_input_mask = RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_COLOR | RS::ARRAY_FORMAT_TEX_UV; + uint64_t specialization = 0; const Item::Command *command = nullptr; Item::Command::Type command_type = Item::Command::TYPE_ANIMATION_SLICE; // Can default to any type that doesn't form a batch. uint32_t primitive_points = 0; - - bool lights_disabled = false; }; // DataBuffer contains our per-frame data. I.e. the resources that are updated each frame. diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl index 5e7fb3b338..1ac289d5a2 100644 --- a/drivers/gles3/shaders/canvas.glsl +++ b/drivers/gles3/shaders/canvas.glsl @@ -1,17 +1,16 @@ /* clang-format off */ #[modes] -mode_quad = -mode_ninepatch = #define USE_NINEPATCH -mode_primitive = #define USE_PRIMITIVE -mode_attributes = #define USE_ATTRIBUTES -mode_instanced = #define USE_ATTRIBUTES \n#define USE_INSTANCING +mode_default = #[specializations] DISABLE_LIGHTING = true USE_RGBA_SHADOWS = false -SINGLE_INSTANCE = false +USE_NINEPATCH = false +USE_PRIMITIVE = false +USE_ATTRIBUTES = false +USE_INSTANCING = false #[vertex] diff --git a/drivers/gles3/shaders/sky.glsl b/drivers/gles3/shaders/sky.glsl index 186b630bc8..043023aee0 100644 --- a/drivers/gles3/shaders/sky.glsl +++ b/drivers/gles3/shaders/sky.glsl @@ -2,17 +2,15 @@ #[modes] mode_background = -mode_half_res = #define USE_HALF_RES_PASS -mode_quarter_res = #define USE_QUARTER_RES_PASS mode_cubemap = #define USE_CUBEMAP_PASS -mode_cubemap_half_res = #define USE_CUBEMAP_PASS \n#define USE_HALF_RES_PASS -mode_cubemap_quarter_res = #define USE_CUBEMAP_PASS \n#define USE_QUARTER_RES_PASS #[specializations] USE_MULTIVIEW = false USE_INVERTED_Y = true APPLY_TONEMAPPING = true +USE_QUARTER_RES_PASS = false +USE_HALF_RES_PASS = false #[vertex] diff --git a/drivers/metal/rendering_context_driver_metal.h b/drivers/metal/rendering_context_driver_metal.h index 7e0b09186d..1fdc255f93 100644 --- a/drivers/metal/rendering_context_driver_metal.h +++ b/drivers/metal/rendering_context_driver_metal.h @@ -107,6 +107,7 @@ public: uint32_t height = 0; DisplayServer::VSyncMode vsync_mode = DisplayServer::VSYNC_ENABLED; bool needs_resize = false; + double present_minimum_duration = 0.0; Surface( #ifdef __OBJC__ @@ -123,6 +124,7 @@ public: virtual Error resize(uint32_t p_desired_framebuffer_count) = 0; virtual RDD::FramebufferID acquire_next_frame_buffer() = 0; virtual void present(MDCommandBuffer *p_cmd_buffer) = 0; + void set_max_fps(int p_max_fps) { present_minimum_duration = p_max_fps ? 1.0 / p_max_fps : 0.0; } }; #ifdef __OBJC__ diff --git a/drivers/metal/rendering_context_driver_metal.mm b/drivers/metal/rendering_context_driver_metal.mm index cf8c7e1c83..199ec25d79 100644 --- a/drivers/metal/rendering_context_driver_metal.mm +++ b/drivers/metal/rendering_context_driver_metal.mm @@ -172,7 +172,7 @@ public: count--; front = (front + 1) % frame_buffers.size(); - [p_cmd_buffer->get_command_buffer() presentDrawable:drawable]; + [p_cmd_buffer->get_command_buffer() presentDrawable:drawable afterMinimumDuration:present_minimum_duration]; } }; diff --git a/drivers/metal/rendering_device_driver_metal.h b/drivers/metal/rendering_device_driver_metal.h index e238de958e..09ab7601e9 100644 --- a/drivers/metal/rendering_device_driver_metal.h +++ b/drivers/metal/rendering_device_driver_metal.h @@ -220,6 +220,7 @@ public: virtual FramebufferID swap_chain_acquire_framebuffer(CommandQueueID p_cmd_queue, SwapChainID p_swap_chain, bool &r_resize_required) override final; virtual RenderPassID swap_chain_get_render_pass(SwapChainID p_swap_chain) override final; virtual DataFormat swap_chain_get_format(SwapChainID p_swap_chain) override final; + virtual void swap_chain_set_max_fps(SwapChainID p_swap_chain, int p_max_fps) override final; virtual void swap_chain_free(SwapChainID p_swap_chain) override final; #pragma mark - Frame Buffer diff --git a/drivers/metal/rendering_device_driver_metal.mm b/drivers/metal/rendering_device_driver_metal.mm index d90f528a14..784c9d5ae8 100644 --- a/drivers/metal/rendering_device_driver_metal.mm +++ b/drivers/metal/rendering_device_driver_metal.mm @@ -982,6 +982,12 @@ RDD::DataFormat RenderingDeviceDriverMetal::swap_chain_get_format(SwapChainID p_ return swap_chain->data_format; } +void RenderingDeviceDriverMetal::swap_chain_set_max_fps(SwapChainID p_swap_chain, int p_max_fps) { + SwapChain *swap_chain = (SwapChain *)(p_swap_chain.id); + RenderingContextDriverMetal::Surface *metal_surface = (RenderingContextDriverMetal::Surface *)(swap_chain->surface); + metal_surface->set_max_fps(p_max_fps); +} + void RenderingDeviceDriverMetal::swap_chain_free(SwapChainID p_swap_chain) { SwapChain *swap_chain = (SwapChain *)(p_swap_chain.id); _swap_chain_release(swap_chain); @@ -1026,7 +1032,7 @@ void RenderingDeviceDriverMetal::framebuffer_free(FramebufferID p_framebuffer) { #pragma mark - Shader -const uint32_t SHADER_BINARY_VERSION = 2; +const uint32_t SHADER_BINARY_VERSION = 3; // region Serialization @@ -1330,23 +1336,32 @@ struct ComputeSize { struct ShaderStageData { RD::ShaderStage stage = RD::ShaderStage::SHADER_STAGE_MAX; + uint32_t is_position_invariant = UINT32_MAX; + uint32_t supports_fast_math = UINT32_MAX; CharString entry_point_name; CharString source; size_t serialize_size() const { int comp_size = Compression::get_max_compressed_buffer_size(source.length(), Compression::MODE_ZSTD); return sizeof(uint32_t) // Stage. - + sizeof(uint32_t) /* entry_point_name.utf8().length */ + entry_point_name.length() + sizeof(uint32_t) /* uncompressed size */ + sizeof(uint32_t) /* compressed size */ + comp_size; + + sizeof(uint32_t) // is_position_invariant + + sizeof(uint32_t) // supports_fast_math + + sizeof(uint32_t) /* entry_point_name.utf8().length */ + + entry_point_name.length() + sizeof(uint32_t) /* uncompressed size */ + sizeof(uint32_t) /* compressed size */ + comp_size; } void serialize(BufWriter &p_writer) const { p_writer.write((uint32_t)stage); + p_writer.write(is_position_invariant); + p_writer.write(supports_fast_math); p_writer.write(entry_point_name); p_writer.write_compressed(source); } void deserialize(BufReader &p_reader) { p_reader.read((uint32_t &)stage); + p_reader.read(is_position_invariant); + p_reader.read(supports_fast_math); p_reader.read(entry_point_name); p_reader.read_compressed(source); } @@ -2005,7 +2020,8 @@ Vector<uint8_t> RenderingDeviceDriverMetal::shader_compile_binary_from_spirv(Vec ERR_FAIL_COND_V_MSG(compiler.get_entry_points_and_stages().size() != 1, Result(), "Expected a single entry point and stage."); - EntryPoint &entry_point_stage = compiler.get_entry_points_and_stages().front(); + SmallVector<EntryPoint> entry_pts_stages = compiler.get_entry_points_and_stages(); + EntryPoint &entry_point_stage = entry_pts_stages.front(); SPIREntryPoint &entry_point = compiler.get_entry_point(entry_point_stage.name, entry_point_stage.execution_model); // Process specialization constants. @@ -2287,6 +2303,8 @@ Vector<uint8_t> RenderingDeviceDriverMetal::shader_compile_binary_from_spirv(Vec ShaderStageData stage_data; stage_data.stage = v.shader_stage; + stage_data.is_position_invariant = compiler.is_position_invariant(); + stage_data.supports_fast_math = !entry_point.flags.get(spv::ExecutionModeSignedZeroInfNanPreserve); stage_data.entry_point_name = entry_point.name.c_str(); stage_data.source = source.c_str(); bin_data.stages.push_back(stage_data); @@ -2359,7 +2377,8 @@ RDD::ShaderID RenderingDeviceDriverMetal::shader_create_from_bytecode(const Vect ShaderCacheEntry *cd = memnew(ShaderCacheEntry(*this, key)); cd->name = binary_data.shader_name; cd->stage = shader_data.stage; - + options.preserveInvariance = shader_data.is_position_invariant; + options.fastMathEnabled = YES; MDLibrary *library = [MDLibrary newLibraryWithCacheEntry:cd device:device source:source diff --git a/drivers/unix/net_socket_unix.cpp b/drivers/unix/net_socket_unix.cpp index 3be615d9ad..3eaf1b2885 100644 --- a/drivers/unix/net_socket_unix.cpp +++ b/drivers/unix/net_socket_unix.cpp @@ -60,7 +60,7 @@ #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP #endif -size_t NetSocketPosix::_set_addr_storage(struct sockaddr_storage *p_addr, const IPAddress &p_ip, uint16_t p_port, IP::Type p_ip_type) { +size_t NetSocketUnix::_set_addr_storage(struct sockaddr_storage *p_addr, const IPAddress &p_ip, uint16_t p_port, IP::Type p_ip_type) { memset(p_addr, 0, sizeof(struct sockaddr_storage)); if (p_ip_type == IP::TYPE_IPV6 || p_ip_type == IP::TYPE_ANY) { // IPv6 socket. @@ -95,7 +95,7 @@ size_t NetSocketPosix::_set_addr_storage(struct sockaddr_storage *p_addr, const } } -void NetSocketPosix::_set_ip_port(struct sockaddr_storage *p_addr, IPAddress *r_ip, uint16_t *r_port) { +void NetSocketUnix::_set_ip_port(struct sockaddr_storage *p_addr, IPAddress *r_ip, uint16_t *r_port) { if (p_addr->ss_family == AF_INET) { struct sockaddr_in *addr4 = (struct sockaddr_in *)p_addr; if (r_ip) { @@ -115,21 +115,21 @@ void NetSocketPosix::_set_ip_port(struct sockaddr_storage *p_addr, IPAddress *r_ } } -NetSocket *NetSocketPosix::_create_func() { - return memnew(NetSocketPosix); +NetSocket *NetSocketUnix::_create_func() { + return memnew(NetSocketUnix); } -void NetSocketPosix::make_default() { +void NetSocketUnix::make_default() { _create = _create_func; } -void NetSocketPosix::cleanup() { +void NetSocketUnix::cleanup() { } -NetSocketPosix::NetSocketPosix() { +NetSocketUnix::NetSocketUnix() { } -NetSocketPosix::~NetSocketPosix() { +NetSocketUnix::~NetSocketUnix() { close(); } @@ -140,7 +140,7 @@ NetSocketPosix::~NetSocketPosix() { #pragma GCC diagnostic ignored "-Wlogical-op" #endif -NetSocketPosix::NetError NetSocketPosix::_get_socket_error() const { +NetSocketUnix::NetError NetSocketUnix::_get_socket_error() const { if (errno == EISCONN) { return ERR_NET_IS_CONNECTED; } @@ -167,7 +167,7 @@ NetSocketPosix::NetError NetSocketPosix::_get_socket_error() const { #pragma GCC diagnostic pop #endif -bool NetSocketPosix::_can_use_ip(const IPAddress &p_ip, const bool p_for_bind) const { +bool NetSocketUnix::_can_use_ip(const IPAddress &p_ip, const bool p_for_bind) const { if (p_for_bind && !(p_ip.is_valid() || p_ip.is_wildcard())) { return false; } else if (!p_for_bind && !p_ip.is_valid()) { @@ -178,7 +178,7 @@ bool NetSocketPosix::_can_use_ip(const IPAddress &p_ip, const bool p_for_bind) c return !(_ip_type != IP::TYPE_ANY && !p_ip.is_wildcard() && _ip_type != type); } -_FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IPAddress p_ip, String p_if_name, bool p_add) { +_FORCE_INLINE_ Error NetSocketUnix::_change_multicast_group(IPAddress p_ip, String p_if_name, bool p_add) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); ERR_FAIL_COND_V(!_can_use_ip(p_ip, false), ERR_INVALID_PARAMETER); @@ -232,7 +232,7 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IPAddress p_ip, Str return OK; } -void NetSocketPosix::_set_socket(int p_sock, IP::Type p_ip_type, bool p_is_stream) { +void NetSocketUnix::_set_socket(int p_sock, IP::Type p_ip_type, bool p_is_stream) { _sock = p_sock; _ip_type = p_ip_type; _is_stream = p_is_stream; @@ -240,13 +240,13 @@ void NetSocketPosix::_set_socket(int p_sock, IP::Type p_ip_type, bool p_is_strea _set_close_exec_enabled(true); } -void NetSocketPosix::_set_close_exec_enabled(bool p_enabled) { +void NetSocketUnix::_set_close_exec_enabled(bool p_enabled) { // Enable close on exec to avoid sharing with subprocesses. Off by default on Windows. int opts = fcntl(_sock, F_GETFD); fcntl(_sock, F_SETFD, opts | FD_CLOEXEC); } -Error NetSocketPosix::open(Type p_sock_type, IP::Type &ip_type) { +Error NetSocketUnix::open(Type p_sock_type, IP::Type &ip_type) { ERR_FAIL_COND_V(is_open(), ERR_ALREADY_IN_USE); ERR_FAIL_COND_V(ip_type > IP::TYPE_ANY || ip_type < IP::TYPE_NONE, ERR_INVALID_PARAMETER); @@ -299,7 +299,7 @@ Error NetSocketPosix::open(Type p_sock_type, IP::Type &ip_type) { return OK; } -void NetSocketPosix::close() { +void NetSocketUnix::close() { if (_sock != -1) { ::close(_sock); } @@ -309,7 +309,7 @@ void NetSocketPosix::close() { _is_stream = false; } -Error NetSocketPosix::bind(IPAddress p_addr, uint16_t p_port) { +Error NetSocketUnix::bind(IPAddress p_addr, uint16_t p_port) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); ERR_FAIL_COND_V(!_can_use_ip(p_addr, true), ERR_INVALID_PARAMETER); @@ -326,7 +326,7 @@ Error NetSocketPosix::bind(IPAddress p_addr, uint16_t p_port) { return OK; } -Error NetSocketPosix::listen(int p_max_pending) { +Error NetSocketUnix::listen(int p_max_pending) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); if (::listen(_sock, p_max_pending) != 0) { @@ -339,7 +339,7 @@ Error NetSocketPosix::listen(int p_max_pending) { return OK; } -Error NetSocketPosix::connect_to_host(IPAddress p_host, uint16_t p_port) { +Error NetSocketUnix::connect_to_host(IPAddress p_host, uint16_t p_port) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); ERR_FAIL_COND_V(!_can_use_ip(p_host, false), ERR_INVALID_PARAMETER); @@ -367,7 +367,7 @@ Error NetSocketPosix::connect_to_host(IPAddress p_host, uint16_t p_port) { return OK; } -Error NetSocketPosix::poll(PollType p_type, int p_timeout) const { +Error NetSocketUnix::poll(PollType p_type, int p_timeout) const { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); struct pollfd pfd; @@ -401,7 +401,7 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const { return OK; } -Error NetSocketPosix::recv(uint8_t *p_buffer, int p_len, int &r_read) { +Error NetSocketUnix::recv(uint8_t *p_buffer, int p_len, int &r_read) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); r_read = ::recv(_sock, p_buffer, p_len, 0); @@ -422,7 +422,7 @@ Error NetSocketPosix::recv(uint8_t *p_buffer, int p_len, int &r_read) { return OK; } -Error NetSocketPosix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IPAddress &r_ip, uint16_t &r_port, bool p_peek) { +Error NetSocketUnix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IPAddress &r_ip, uint16_t &r_port, bool p_peek) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); struct sockaddr_storage from; @@ -460,7 +460,7 @@ Error NetSocketPosix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IPAddr return OK; } -Error NetSocketPosix::send(const uint8_t *p_buffer, int p_len, int &r_sent) { +Error NetSocketUnix::send(const uint8_t *p_buffer, int p_len, int &r_sent) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); int flags = 0; @@ -486,7 +486,7 @@ Error NetSocketPosix::send(const uint8_t *p_buffer, int p_len, int &r_sent) { return OK; } -Error NetSocketPosix::sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IPAddress p_ip, uint16_t p_port) { +Error NetSocketUnix::sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IPAddress p_ip, uint16_t p_port) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); struct sockaddr_storage addr; @@ -508,7 +508,7 @@ Error NetSocketPosix::sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP return OK; } -Error NetSocketPosix::set_broadcasting_enabled(bool p_enabled) { +Error NetSocketUnix::set_broadcasting_enabled(bool p_enabled) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); // IPv6 has no broadcast support. if (_ip_type == IP::TYPE_IPV6) { @@ -523,7 +523,7 @@ Error NetSocketPosix::set_broadcasting_enabled(bool p_enabled) { return OK; } -void NetSocketPosix::set_blocking_enabled(bool p_enabled) { +void NetSocketUnix::set_blocking_enabled(bool p_enabled) { ERR_FAIL_COND(!is_open()); int ret = 0; @@ -539,7 +539,7 @@ void NetSocketPosix::set_blocking_enabled(bool p_enabled) { } } -void NetSocketPosix::set_ipv6_only_enabled(bool p_enabled) { +void NetSocketUnix::set_ipv6_only_enabled(bool p_enabled) { ERR_FAIL_COND(!is_open()); // This option is only available in IPv6 sockets. ERR_FAIL_COND(_ip_type == IP::TYPE_IPV4); @@ -550,7 +550,7 @@ void NetSocketPosix::set_ipv6_only_enabled(bool p_enabled) { } } -void NetSocketPosix::set_tcp_no_delay_enabled(bool p_enabled) { +void NetSocketUnix::set_tcp_no_delay_enabled(bool p_enabled) { ERR_FAIL_COND(!is_open()); ERR_FAIL_COND(!_is_stream); // Not TCP. @@ -560,7 +560,7 @@ void NetSocketPosix::set_tcp_no_delay_enabled(bool p_enabled) { } } -void NetSocketPosix::set_reuse_address_enabled(bool p_enabled) { +void NetSocketUnix::set_reuse_address_enabled(bool p_enabled) { ERR_FAIL_COND(!is_open()); int par = p_enabled ? 1 : 0; @@ -569,11 +569,11 @@ void NetSocketPosix::set_reuse_address_enabled(bool p_enabled) { } } -bool NetSocketPosix::is_open() const { +bool NetSocketUnix::is_open() const { return _sock != -1; } -int NetSocketPosix::get_available_bytes() const { +int NetSocketUnix::get_available_bytes() const { ERR_FAIL_COND_V(!is_open(), -1); int len; @@ -586,7 +586,7 @@ int NetSocketPosix::get_available_bytes() const { return len; } -Error NetSocketPosix::get_socket_address(IPAddress *r_ip, uint16_t *r_port) const { +Error NetSocketUnix::get_socket_address(IPAddress *r_ip, uint16_t *r_port) const { ERR_FAIL_COND_V(!is_open(), FAILED); struct sockaddr_storage saddr; @@ -600,7 +600,7 @@ Error NetSocketPosix::get_socket_address(IPAddress *r_ip, uint16_t *r_port) cons return OK; } -Ref<NetSocket> NetSocketPosix::accept(IPAddress &r_ip, uint16_t &r_port) { +Ref<NetSocket> NetSocketUnix::accept(IPAddress &r_ip, uint16_t &r_port) { Ref<NetSocket> out; ERR_FAIL_COND_V(!is_open(), out); @@ -615,17 +615,17 @@ Ref<NetSocket> NetSocketPosix::accept(IPAddress &r_ip, uint16_t &r_port) { _set_ip_port(&their_addr, &r_ip, &r_port); - NetSocketPosix *ns = memnew(NetSocketPosix); + NetSocketUnix *ns = memnew(NetSocketUnix); ns->_set_socket(fd, _ip_type, _is_stream); ns->set_blocking_enabled(false); return Ref<NetSocket>(ns); } -Error NetSocketPosix::join_multicast_group(const IPAddress &p_multi_address, const String &p_if_name) { +Error NetSocketUnix::join_multicast_group(const IPAddress &p_multi_address, const String &p_if_name) { return _change_multicast_group(p_multi_address, p_if_name, true); } -Error NetSocketPosix::leave_multicast_group(const IPAddress &p_multi_address, const String &p_if_name) { +Error NetSocketUnix::leave_multicast_group(const IPAddress &p_multi_address, const String &p_if_name) { return _change_multicast_group(p_multi_address, p_if_name, false); } diff --git a/drivers/unix/net_socket_unix.h b/drivers/unix/net_socket_unix.h index 22f7bfdd91..08c45f2ac3 100644 --- a/drivers/unix/net_socket_unix.h +++ b/drivers/unix/net_socket_unix.h @@ -37,7 +37,7 @@ #include <sys/socket.h> -class NetSocketPosix : public NetSocket { +class NetSocketUnix : public NetSocket { private: int _sock = -1; IP::Type _ip_type = IP::TYPE_NONE; @@ -93,8 +93,8 @@ public: virtual Error join_multicast_group(const IPAddress &p_multi_address, const String &p_if_name) override; virtual Error leave_multicast_group(const IPAddress &p_multi_address, const String &p_if_name) override; - NetSocketPosix(); - ~NetSocketPosix() override; + NetSocketUnix(); + ~NetSocketUnix() override; }; #endif // UNIX_ENABLED && !UNIX_SOCKET_UNAVAILABLE diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index b23dba7a49..ffc270cd36 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -77,6 +77,7 @@ #include <stdlib.h> #include <string.h> #include <sys/resource.h> +#include <sys/stat.h> #include <sys/time.h> #include <sys/wait.h> #include <time.h> @@ -166,7 +167,9 @@ void OS_Unix::initialize_core() { DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA); DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM); - NetSocketPosix::make_default(); +#ifndef UNIX_SOCKET_UNAVAILABLE + NetSocketUnix::make_default(); +#endif IPUnix::make_default(); process_map = memnew((HashMap<ProcessID, ProcessInfo>)); @@ -175,16 +178,96 @@ void OS_Unix::initialize_core() { void OS_Unix::finalize_core() { memdelete(process_map); - NetSocketPosix::cleanup(); +#ifndef UNIX_SOCKET_UNAVAILABLE + NetSocketUnix::cleanup(); +#endif } Vector<String> OS_Unix::get_video_adapter_driver_info() const { return Vector<String>(); } -String OS_Unix::get_stdin_string() { - char buff[1024]; - return String::utf8(fgets(buff, 1024, stdin)); +String OS_Unix::get_stdin_string(int64_t p_buffer_size) { + Vector<uint8_t> data; + data.resize(p_buffer_size); + if (fgets((char *)data.ptrw(), data.size(), stdin)) { + return String::utf8((char *)data.ptr()); + } + return String(); +} + +PackedByteArray OS_Unix::get_stdin_buffer(int64_t p_buffer_size) { + Vector<uint8_t> data; + data.resize(p_buffer_size); + size_t sz = fread((void *)data.ptrw(), 1, data.size(), stdin); + if (sz > 0) { + data.resize(sz); + return data; + } + return PackedByteArray(); +} + +OS_Unix::StdHandleType OS_Unix::get_stdin_type() const { + int h = fileno(stdin); + if (h == -1) { + return STD_HANDLE_INVALID; + } + + if (isatty(h)) { + return STD_HANDLE_CONSOLE; + } + struct stat statbuf; + if (fstat(h, &statbuf) < 0) { + return STD_HANDLE_UNKNOWN; + } + if (S_ISFIFO(statbuf.st_mode)) { + return STD_HANDLE_PIPE; + } else if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) { + return STD_HANDLE_FILE; + } + return STD_HANDLE_UNKNOWN; +} + +OS_Unix::StdHandleType OS_Unix::get_stdout_type() const { + int h = fileno(stdout); + if (h == -1) { + return STD_HANDLE_INVALID; + } + + if (isatty(h)) { + return STD_HANDLE_CONSOLE; + } + struct stat statbuf; + if (fstat(h, &statbuf) < 0) { + return STD_HANDLE_UNKNOWN; + } + if (S_ISFIFO(statbuf.st_mode)) { + return STD_HANDLE_PIPE; + } else if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) { + return STD_HANDLE_FILE; + } + return STD_HANDLE_UNKNOWN; +} + +OS_Unix::StdHandleType OS_Unix::get_stderr_type() const { + int h = fileno(stderr); + if (h == -1) { + return STD_HANDLE_INVALID; + } + + if (isatty(h)) { + return STD_HANDLE_CONSOLE; + } + struct stat statbuf; + if (fstat(h, &statbuf) < 0) { + return STD_HANDLE_UNKNOWN; + } + if (S_ISFIFO(statbuf.st_mode)) { + return STD_HANDLE_PIPE; + } else if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) { + return STD_HANDLE_FILE; + } + return STD_HANDLE_UNKNOWN; } Error OS_Unix::get_entropy(uint8_t *r_buffer, int p_bytes) { @@ -777,7 +860,7 @@ String OS_Unix::get_locale() const { } String locale = get_environment("LANG"); - int tp = locale.find("."); + int tp = locale.find_char('.'); if (tp != -1) { locale = locale.substr(0, tp); } diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 3add5df055..2c7920c142 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -58,7 +58,11 @@ public: virtual Vector<String> get_video_adapter_driver_info() const override; - virtual String get_stdin_string() override; + virtual String get_stdin_string(int64_t p_buffer_size = 1024) override; + virtual PackedByteArray get_stdin_buffer(int64_t p_buffer_size = 1024) override; + virtual StdHandleType get_stdin_type() const override; + virtual StdHandleType get_stdout_type() const override; + virtual StdHandleType get_stderr_type() const override; virtual Error get_entropy(uint8_t *r_buffer, int p_bytes) override; diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp index 6eecd850f5..a86f72e0b9 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.cpp +++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp @@ -3032,13 +3032,10 @@ Error RenderingDeviceDriverVulkan::swap_chain_resize(CommandQueueID p_cmd_queue, #if defined(SWAPPY_FRAME_PACING_ENABLED) if (swappy_frame_pacer_enable) { - const double max_fps = Engine::get_singleton()->get_max_fps(); - const uint64_t max_time = max_fps > 0 ? uint64_t((1000.0 * 1000.0 * 1000.0) / max_fps) : 0; - SwappyVk_initAndGetRefreshCycleDuration(get_jni_env(), static_cast<OS_Android *>(OS::get_singleton())->get_godot_java()->get_activity(), physical_device, vk_device, swap_chain->vk_swapchain, &swap_chain->refresh_duration); SwappyVk_setWindow(vk_device, swap_chain->vk_swapchain, static_cast<OS_Android *>(OS::get_singleton())->get_native_window()); - SwappyVk_setSwapIntervalNS(vk_device, swap_chain->vk_swapchain, MAX(swap_chain->refresh_duration, max_time)); + SwappyVk_setSwapIntervalNS(vk_device, swap_chain->vk_swapchain, swap_chain->refresh_duration); enum SwappyModes { PIPELINE_FORCED_ON, diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 24a26b56ef..3ddbde72c4 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -230,7 +230,7 @@ String DirAccessWindows::get_current_dir(bool p_include_drive) const { return cdir; } else { if (_get_root_string().is_empty()) { - int pos = cdir.find(":"); + int pos = cdir.find_char(':'); if (pos != -1) { return cdir.substr(pos + 1); } @@ -344,7 +344,7 @@ String DirAccessWindows::get_filesystem_type() const { return "Network Share"; } - int unit_end = path.find(":"); + int unit_end = path.find_char(':'); ERR_FAIL_COND_V(unit_end == -1, String()); String unit = path.substr(0, unit_end + 1) + "\\"; diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 7d2247d41a..4a0e5e5f49 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -64,7 +64,7 @@ bool FileAccessWindows::is_path_invalid(const String &p_path) { // Check for invalid operating system file. String fname = p_path.get_file().to_lower(); - int dot = fname.find("."); + int dot = fname.find_char('.'); if (dot != -1) { fname = fname.substr(0, dot); } diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 8d7c6a1f16..36ca417638 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -275,7 +275,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { } String base_path = animation->track_get_path(i); - int end = base_path.find(":"); + int end = base_path.find_char(':'); if (end != -1) { base_path = base_path.substr(0, end + 1); } @@ -1650,7 +1650,7 @@ void AnimationBezierTrackEdit::_zoom_callback(float p_zoom_factor, Vector2 p_ori Ref<InputEventWithModifiers> iewm = p_event; if (iewm.is_valid() && iewm->is_alt_pressed()) { // Alternate zoom (doesn't affect timeline). - timeline_v_zoom = CLAMP(timeline_v_zoom * p_zoom_factor, 0.000001, 100000); + timeline_v_zoom = CLAMP(timeline_v_zoom / p_zoom_factor, 0.000001, 100000); } else { float zoom_factor = p_zoom_factor > 1.0 ? AnimationTimelineEdit::SCROLL_ZOOM_FACTOR_IN : AnimationTimelineEdit::SCROLL_ZOOM_FACTOR_OUT; timeline->_zoom_callback(zoom_factor, p_origin, p_event); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 076ba6d905..7a1296c411 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -4340,7 +4340,7 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p if (track_path == np) { actual_value = value; // All good. } else { - int sep = track_path.rfind(":"); + int sep = track_path.rfind_char(':'); if (sep != -1) { String base_path = track_path.substr(0, sep); if (base_path == np) { @@ -6495,7 +6495,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { path = NodePath(node->get_path().get_names(), path.get_subnames(), true); // Store full path instead for copying. } else { text = path; - int sep = text.find(":"); + int sep = text.find_char(':'); if (sep != -1) { text = text.substr(sep + 1, text.length()); } @@ -7383,16 +7383,17 @@ void AnimationTrackEditor::_update_snap_unit() { float AnimationTrackEditor::snap_time(float p_value, bool p_relative) { if (is_snap_keys_enabled()) { + double current_snap = snap_unit; if (Input::get_singleton()->is_key_pressed(Key::SHIFT)) { // Use more precise snapping when holding Shift. - snap_unit *= 0.25; + current_snap *= 0.25; } if (p_relative) { - double rel = Math::fmod(timeline->get_value(), snap_unit); - p_value = Math::snapped(p_value + rel, snap_unit) - rel; + double rel = Math::fmod(timeline->get_value(), current_snap); + p_value = Math::snapped(p_value + rel, current_snap) - rel; } else { - p_value = Math::snapped(p_value, snap_unit); + p_value = Math::snapped(p_value, current_snap); } } diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index b114977c3b..d76c324be0 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -524,7 +524,7 @@ void ConnectDialog::set_dst_node(Node *p_node) { StringName ConnectDialog::get_dst_method_name() const { String txt = dst_method->get_text(); if (txt.contains("(")) { - txt = txt.left(txt.find("(")).strip_edges(); + txt = txt.left(txt.find_char('(')).strip_edges(); } return txt; } diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 78dc772d9e..2273014f72 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -160,13 +160,13 @@ bool CreateDialog::_should_hide_type(const StringName &p_type) const { String script_path = ScriptServer::get_global_class_path(p_type); if (script_path.begins_with("res://addons/")) { - int i = script_path.find("/", 13); // 13 is length of "res://addons/". + int i = script_path.find_char('/', 13); // 13 is length of "res://addons/". while (i > -1) { const String plugin_path = script_path.substr(0, i).path_join("plugin.cfg"); if (FileAccess::exists(plugin_path)) { return !EditorNode::get_singleton()->is_addon_plugin_enabled(plugin_path); } - i = script_path.find("/", i + 1); + i = script_path.find_char('/', i + 1); } } } diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index 2af629676a..904085630b 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -147,7 +147,7 @@ Dictionary DebugAdapterParser::req_initialize(const Dictionary &p_params) const for (List<String>::Element *E = breakpoints.front(); E; E = E->next()) { String breakpoint = E->get(); - String path = breakpoint.left(breakpoint.find(":", 6)); // Skip initial part of path, aka "res://" + String path = breakpoint.left(breakpoint.find_char(':', 6)); // Skip initial part of path, aka "res://" int line = breakpoint.substr(path.size()).to_int(); DebugAdapterProtocol::get_singleton()->on_debug_breakpoint_toggled(path, line, true); diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 0f948b4ed5..909651da45 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -160,9 +160,9 @@ void EditorDebuggerNode::_text_editor_stack_goto(const ScriptEditorDebugger *p_d } else { // If the script is built-in, it can be opened only if the scene is loaded in memory. int i = file.find("::"); - int j = file.rfind("(", i); + int j = file.rfind_char('(', i); if (j > -1) { // If the script is named, the string is "name (file)", so we need to extract the path. - file = file.substr(j + 1, file.find(")", i) - j - 1); + file = file.substr(j + 1, file.find_char(')', i) - j - 1); } Ref<PackedScene> ps = ResourceLoader::load(file.get_slice("::", 0)); stack_script = ResourceLoader::load(file); @@ -183,9 +183,9 @@ void EditorDebuggerNode::_text_editor_stack_clear(const ScriptEditorDebugger *p_ } else { // If the script is built-in, it can be opened only if the scene is loaded in memory. int i = file.find("::"); - int j = file.rfind("(", i); + int j = file.rfind_char('(', i); if (j > -1) { // If the script is named, the string is "name (file)", so we need to extract the path. - file = file.substr(j + 1, file.find(")", i) - j - 1); + file = file.substr(j + 1, file.find_char(')', i) - j - 1); } Ref<PackedScene> ps = ResourceLoader::load(file.get_slice("::", 0)); stack_script = ResourceLoader::load(file); diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index 4d67800e6e..a9e4adf674 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -382,7 +382,7 @@ void EditorDebuggerTree::_item_menu_id_pressed(int p_option) { text = "."; } else { text = text.replace("/root/", ""); - int slash = text.find("/"); + int slash = text.find_char('/'); if (slash < 0) { text = "."; } else { diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 8ba5811ffa..9ca12070fe 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -471,7 +471,7 @@ void DependencyRemoveDialog::_find_localization_remaps_of_removed_files(Vector<R for (int j = 0; j < remap_keys.size(); j++) { PackedStringArray remapped_files = remaps[remap_keys[j]]; for (int k = 0; k < remapped_files.size(); k++) { - int splitter_pos = remapped_files[k].rfind(":"); + int splitter_pos = remapped_files[k].rfind_char(':'); String res_path = remapped_files[k].substr(0, splitter_pos); if (res_path == path) { String locale_name = remapped_files[k].substr(splitter_pos + 1); diff --git a/editor/directory_create_dialog.cpp b/editor/directory_create_dialog.cpp index ee03d5a7f6..d68af88fc8 100644 --- a/editor/directory_create_dialog.cpp +++ b/editor/directory_create_dialog.cpp @@ -142,7 +142,7 @@ void DirectoryCreateDialog::config(const String &p_base_dir, const Callable &p_a validation_panel->update(); if (p_mode == MODE_FILE) { - int extension_pos = p_default_name.rfind("."); + int extension_pos = p_default_name.rfind_char('.'); if (extension_pos > -1) { dir_path->select(0, extension_pos); return; diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index bce0c87452..72755e8943 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -130,14 +130,14 @@ void EditorAssetInstaller::open_asset(const String &p_path, bool p_autoskip_topl // Create intermediate directories if they aren't reported by unzip. // We are only interested in subfolders, so skip the root slash. - int separator = source_name.find("/", 1); + int separator = source_name.find_char('/', 1); while (separator != -1) { String dir_name = source_name.substr(0, separator + 1); if (!dir_name.is_empty() && !asset_files.has(dir_name)) { asset_files.insert(dir_name); } - separator = source_name.find("/", separator + 1); + separator = source_name.find_char('/', separator + 1); } if (!source_name.is_empty() && !asset_files.has(source_name)) { @@ -214,7 +214,7 @@ void EditorAssetInstaller::_rebuild_source_tree() { TreeItem *parent_item; - int separator = path.rfind("/"); + int separator = path.rfind_char('/'); if (separator == -1) { parent_item = root; } else { @@ -313,7 +313,7 @@ void EditorAssetInstaller::_rebuild_destination_tree() { TreeItem *parent_item; - int separator = path.rfind("/"); + int separator = path.rfind_char('/'); if (separator == -1) { parent_item = root; } else { diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index cc81001efb..b5306154ba 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1516,6 +1516,9 @@ void EditorFileSystem::_delete_internal_files(const String &p_file) { } da->remove(p_file + ".import"); } + if (FileAccess::exists(p_file + ".uid")) { + DirAccess::remove_absolute(p_file + ".uid"); + } } int EditorFileSystem::_insert_actions_delete_files_directory(EditorFileSystemDirectory *p_dir) { diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 18f5610655..5cb38fa875 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -249,7 +249,7 @@ void EditorFolding::_do_object_unfolds(Object *p_object, HashSet<Ref<Resource>> } } } else { //path - int last = E.name.rfind("/"); + int last = E.name.rfind_char('/'); if (last != -1) { bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E.name); if (can_revert) { diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 0ca1ed2d50..9aec9d6b15 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -148,7 +148,7 @@ static String _contextualize_class_specifier(const String &p_class_specifier, co // Here equal length + begins_with from above implies p_class_specifier == p_edited_class :) if (p_class_specifier.length() == p_edited_class.length()) { - int rfind = p_class_specifier.rfind("."); + int rfind = p_class_specifier.rfind_char('.'); if (rfind == -1) { // Single identifier return p_class_specifier; } @@ -234,7 +234,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { enum_class_name = "@GlobalScope"; enum_name = link; } else { - const int dot_pos = link.rfind("."); + const int dot_pos = link.rfind_char('.'); if (dot_pos >= 0) { enum_class_name = link.left(dot_pos); enum_name = link.substr(dot_pos + 1); @@ -3252,7 +3252,7 @@ EditorHelpBit::HelpData EditorHelpBit::_get_property_help_data(const StringName enum_class_name = "@GlobalScope"; enum_name = property.enumeration; } else { - const int dot_pos = property.enumeration.rfind("."); + const int dot_pos = property.enumeration.rfind_char('.'); if (dot_pos >= 0) { enum_class_name = property.enumeration.left(dot_pos); enum_name = property.enumeration.substr(dot_pos + 1); @@ -3619,7 +3619,7 @@ void EditorHelpBit::_meta_clicked(const String &p_select) { enum_class_name = "@GlobalScope"; enum_name = link; } else { - const int dot_pos = link.rfind("."); + const int dot_pos = link.rfind_char('.'); if (dot_pos >= 0) { enum_class_name = link.left(dot_pos); enum_name = link.substr(dot_pos + 1); diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index b0c06475f8..0fc7052a2b 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -1166,7 +1166,7 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const if (p_matching_keyword.is_empty()) { item->set_text(0, p_doc->name); } else { - item->set_text(0, p_doc->name + " - " + TTR(vformat("Matches the \"%s\" keyword.", p_matching_keyword))); + item->set_text(0, p_doc->name + " - " + vformat(TTR("Matches the \"%s\" keyword."), p_matching_keyword)); } if (!term.is_empty()) { @@ -1272,7 +1272,7 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons text = p_class_name + "." + p_text; } if (!p_matching_keyword.is_empty()) { - text += " - " + TTR(vformat("Matches the \"%s\" keyword.", p_matching_keyword)); + text += " - " + vformat(TTR("Matches the \"%s\" keyword."), p_matching_keyword); } item->set_text(0, text); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 1c23ce8ede..6b3c6b462d 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2724,7 +2724,7 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, EditorIn for (const EditorInspectorPlugin::AddedEditor &F : ped->added_editors) { EditorProperty *ep = Object::cast_to<EditorProperty>(F.property_editor); - if (ep && current_favorites.has(F.properties[0])) { + if (ep && !F.properties.is_empty() && current_favorites.has(F.properties[0])) { ep->favorited = true; favorites_vbox->add_child(F.property_editor); } else { @@ -3131,7 +3131,7 @@ void EditorInspector::update_tree() { if (!array_prefix.is_empty()) { path = path.trim_prefix(array_prefix); - int char_index = path.find("/"); + int char_index = path.find_char('/'); if (char_index >= 0) { path = path.right(-char_index - 1); } else { @@ -3171,10 +3171,10 @@ void EditorInspector::update_tree() { } // Get the property label's string. - String name_override = (path.contains("/")) ? path.substr(path.rfind("/") + 1) : path; + String name_override = (path.contains("/")) ? path.substr(path.rfind_char('/') + 1) : path; String feature_tag; { - const int dot = name_override.find("."); + const int dot = name_override.find_char('.'); if (dot != -1) { feature_tag = name_override.substr(dot); name_override = name_override.substr(0, dot); @@ -3189,7 +3189,7 @@ void EditorInspector::update_tree() { const String property_label_string = EditorPropertyNameProcessor::get_singleton()->process_name(name_override, name_style, p.name, doc_name) + feature_tag; // Remove the property from the path. - int idx = path.rfind("/"); + int idx = path.rfind_char('/'); if (idx > -1) { path = path.left(idx); } else { @@ -3320,7 +3320,7 @@ void EditorInspector::update_tree() { array_element_prefix = class_name_components[0]; editor_inspector_array = memnew(EditorInspectorArray(all_read_only)); - String array_label = path.contains("/") ? path.substr(path.rfind("/") + 1) : path; + String array_label = path.contains("/") ? path.substr(path.rfind_char('/') + 1) : path; array_label = EditorPropertyNameProcessor::get_singleton()->process_name(property_label_string, property_name_style, p.name, doc_name); int page = per_array_page.has(array_element_prefix) ? per_array_page[array_element_prefix] : 0; editor_inspector_array->setup_with_move_element_function(object, array_label, array_element_prefix, page, c, use_folding); diff --git a/editor/editor_interface.cpp b/editor/editor_interface.cpp index 304b9d4b8c..e85258df50 100644 --- a/editor/editor_interface.cpp +++ b/editor/editor_interface.cpp @@ -43,6 +43,7 @@ #include "editor/gui/editor_quick_open_dialog.h" #include "editor/gui/editor_run_bar.h" #include "editor/gui/editor_scene_tabs.h" +#include "editor/gui/editor_toaster.h" #include "editor/gui/scene_tree_editor.h" #include "editor/inspector_dock.h" #include "editor/plugins/node_3d_editor_plugin.h" @@ -89,6 +90,10 @@ Ref<EditorSettings> EditorInterface::get_editor_settings() const { return EditorSettings::get_singleton(); } +EditorToaster *EditorInterface::get_editor_toaster() const { + return EditorToaster::get_singleton(); +} + EditorUndoRedoManager *EditorInterface::get_editor_undo_redo() const { return EditorUndoRedoManager::get_singleton(); } @@ -280,14 +285,10 @@ void EditorInterface::set_current_feature_profile(const String &p_profile_name) // Editor dialogs. void EditorInterface::popup_node_selector(const Callable &p_callback, const TypedArray<StringName> &p_valid_types, Node *p_current_value) { - // TODO: Should reuse dialog instance instead of creating a fresh one, but need to rework set_valid_types first. - if (node_selector) { - node_selector->disconnect(SNAME("selected"), callable_mp(this, &EditorInterface::_node_selected).bind(p_callback)); - node_selector->disconnect(SNAME("canceled"), callable_mp(this, &EditorInterface::_node_selection_canceled).bind(p_callback)); - get_base_control()->remove_child(node_selector); - node_selector->queue_free(); + if (!node_selector) { + node_selector = memnew(SceneTreeDialog); + get_base_control()->add_child(node_selector); } - node_selector = memnew(SceneTreeDialog); Vector<StringName> valid_types; int length = p_valid_types.size(); @@ -296,27 +297,18 @@ void EditorInterface::popup_node_selector(const Callable &p_callback, const Type valid_types.write[i] = p_valid_types[i]; } node_selector->set_valid_types(valid_types); - - get_base_control()->add_child(node_selector); - node_selector->popup_scenetree_dialog(p_current_value); - const Callable selected_callback = callable_mp(this, &EditorInterface::_node_selected).bind(p_callback); - node_selector->connect(SNAME("selected"), selected_callback, CONNECT_DEFERRED); - - const Callable canceled_callback = callable_mp(this, &EditorInterface::_node_selection_canceled).bind(p_callback); - node_selector->connect(SNAME("canceled"), canceled_callback, CONNECT_DEFERRED); + const Callable callback = callable_mp(this, &EditorInterface::_node_selected); + node_selector->connect(SNAME("selected"), callback.bind(p_callback), CONNECT_DEFERRED); + node_selector->connect(SNAME("canceled"), callback.bind(NodePath(), p_callback), CONNECT_DEFERRED); } void EditorInterface::popup_property_selector(Object *p_object, const Callable &p_callback, const PackedInt32Array &p_type_filter, const String &p_current_value) { - // TODO: Should reuse dialog instance instead of creating a fresh one, but need to rework set_type_filter first. - if (property_selector) { - property_selector->disconnect(SNAME("selected"), callable_mp(this, &EditorInterface::_property_selected).bind(p_callback)); - property_selector->disconnect(SNAME("canceled"), callable_mp(this, &EditorInterface::_property_selection_canceled).bind(p_callback)); - get_base_control()->remove_child(property_selector); - property_selector->queue_free(); + if (!property_selector) { + property_selector = memnew(PropertySelector); + get_base_control()->add_child(property_selector); } - property_selector = memnew(PropertySelector); Vector<Variant::Type> type_filter; int length = p_type_filter.size(); @@ -325,16 +317,11 @@ void EditorInterface::popup_property_selector(Object *p_object, const Callable & type_filter.write[i] = (Variant::Type)p_type_filter[i]; } property_selector->set_type_filter(type_filter); - - get_base_control()->add_child(property_selector); - property_selector->select_property_from_instance(p_object, p_current_value); - const Callable selected_callback = callable_mp(this, &EditorInterface::_property_selected).bind(p_callback); - property_selector->connect(SNAME("selected"), selected_callback, CONNECT_DEFERRED); - - const Callable canceled_callback = callable_mp(this, &EditorInterface::_property_selection_canceled).bind(p_callback); - property_selector->connect(SNAME("canceled"), canceled_callback, CONNECT_DEFERRED); + const Callable callback = callable_mp(this, &EditorInterface::_property_selected); + property_selector->connect(SNAME("selected"), callback.bind(p_callback), CONNECT_DEFERRED); + property_selector->connect(SNAME("canceled"), callback.bind(String(), p_callback), CONNECT_DEFERRED); } void EditorInterface::popup_method_selector(Object *p_object, const Callable &p_callback, const String &p_current_value) { @@ -369,20 +356,28 @@ void EditorInterface::popup_quick_open(const Callable &p_callback, const TypedAr } void EditorInterface::_node_selected(const NodePath &p_node_path, const Callable &p_callback) { - const NodePath path = get_edited_scene_root()->get_path().rel_path_to(p_node_path); - _call_dialog_callback(p_callback, path, "node selected"); -} + const Callable callback = callable_mp(this, &EditorInterface::_node_selected); + node_selector->disconnect(SNAME("selected"), callback); + node_selector->disconnect(SNAME("canceled"), callback); -void EditorInterface::_node_selection_canceled(const Callable &p_callback) { - _call_dialog_callback(p_callback, NodePath(), "node selection canceled"); + if (p_node_path.is_empty()) { + _call_dialog_callback(p_callback, NodePath(), "node selection canceled"); + } else { + const NodePath path = get_edited_scene_root()->get_path().rel_path_to(p_node_path); + _call_dialog_callback(p_callback, path, "node selected"); + } } void EditorInterface::_property_selected(const String &p_property_name, const Callable &p_callback) { - _call_dialog_callback(p_callback, NodePath(p_property_name).get_as_property_path(), "property selected"); -} + const Callable callback = callable_mp(this, &EditorInterface::_property_selected); + property_selector->disconnect(SNAME("selected"), callback); + property_selector->disconnect(SNAME("canceled"), callback); -void EditorInterface::_property_selection_canceled(const Callable &p_callback) { - _call_dialog_callback(p_callback, NodePath(), "property selection canceled"); + if (p_property_name.is_empty()) { + _call_dialog_callback(p_callback, NodePath(p_property_name).get_as_property_path(), "property selection canceled"); + } else { + _call_dialog_callback(p_callback, NodePath(p_property_name).get_as_property_path(), "property selected"); + } } void EditorInterface::_method_selected(const String &p_method_name, const Callable &p_callback) { @@ -581,6 +576,7 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("get_resource_previewer"), &EditorInterface::get_resource_previewer); ClassDB::bind_method(D_METHOD("get_selection"), &EditorInterface::get_selection); ClassDB::bind_method(D_METHOD("get_editor_settings"), &EditorInterface::get_editor_settings); + ClassDB::bind_method(D_METHOD("get_editor_toaster"), &EditorInterface::get_editor_toaster); ClassDB::bind_method(D_METHOD("get_editor_undo_redo"), &EditorInterface::get_editor_undo_redo); ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews); diff --git a/editor/editor_interface.h b/editor/editor_interface.h index c1032bf9b6..2ae77331b1 100644 --- a/editor/editor_interface.h +++ b/editor/editor_interface.h @@ -45,6 +45,7 @@ class EditorPlugin; class EditorResourcePreview; class EditorSelection; class EditorSettings; +class EditorToaster; class EditorUndoRedoManager; class FileSystemDock; class Mesh; @@ -70,9 +71,7 @@ class EditorInterface : public Object { SceneTreeDialog *node_selector = nullptr; void _node_selected(const NodePath &p_node_paths, const Callable &p_callback); - void _node_selection_canceled(const Callable &p_callback); void _property_selected(const String &p_property_name, const Callable &p_callback); - void _property_selection_canceled(const Callable &p_callback); void _method_selected(const String &p_property_name, const Callable &p_callback); void _quick_open(const String &p_file_path, const Callable &p_callback); void _call_dialog_callback(const Callable &p_callback, const Variant &p_selected, const String &p_context); @@ -104,6 +103,7 @@ public: EditorResourcePreview *get_resource_previewer() const; EditorSelection *get_selection() const; Ref<EditorSettings> get_editor_settings() const; + EditorToaster *get_editor_toaster() const; EditorUndoRedoManager *get_editor_undo_redo() const; Vector<Ref<Texture2D>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f8e23ecc9d..f056a477c4 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -253,8 +253,8 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto // append that to yield "folder/foo.tscn". if (difference > 0) { String parent = full_path.substr(0, difference); - int slash_idx = parent.rfind("/"); - slash_idx = parent.rfind("/", slash_idx - 1); + int slash_idx = parent.rfind_char('/'); + slash_idx = parent.rfind_char('/', slash_idx - 1); parent = (slash_idx >= 0 && parent.length() > 1) ? parent.substr(slash_idx + 1) : parent; r_filenames.write[set_idx] = parent + r_filenames[set_idx]; } @@ -1454,6 +1454,16 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String file->popup_file_dialog(); } +void EditorNode::ensure_uid_file(const String &p_new_resource_path) { + if (ResourceLoader::exists(p_new_resource_path) && !ResourceLoader::has_custom_uid_support(p_new_resource_path) && !FileAccess::exists(p_new_resource_path + ".uid")) { + Ref<FileAccess> f = FileAccess::open(p_new_resource_path + ".uid", FileAccess::WRITE); + if (f.is_valid()) { + const ResourceUID::ID id = ResourceUID::get_singleton()->create_id(); + f->store_line(ResourceUID::get_singleton()->id_to_text(id)); + } + } +} + void EditorNode::_menu_option(int p_option) { _menu_option_confirm(p_option, false); } @@ -2173,6 +2183,12 @@ void EditorNode::_dialog_action(String p_file) { case RESOURCE_SAVE_AS: { ERR_FAIL_COND(saving_resource.is_null()); save_resource_in_path(saving_resource, p_file); + + if (current_menu_option == RESOURCE_SAVE_AS) { + // Create .uid file when making new Resource. + ensure_uid_file(p_file); + } + saving_resource = Ref<Resource>(); ObjectID current_id = editor_history.get_current(); Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr; @@ -7690,24 +7706,28 @@ EditorNode::EditorNode() { disk_changed = memnew(ConfirmationDialog); { - disk_changed->set_title(TTR("Files have been modified on disk")); + disk_changed->set_title(TTR("Files have been modified outside Godot")); VBoxContainer *vbc = memnew(VBoxContainer); disk_changed->add_child(vbc); Label *dl = memnew(Label); - dl->set_text(TTR("The following files are newer on disk.\nWhat action should be taken?")); + dl->set_text(TTR("The following files are newer on disk:")); vbc->add_child(dl); disk_changed_list = memnew(Tree); vbc->add_child(disk_changed_list); disk_changed_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + Label *what_action_label = memnew(Label); + what_action_label->set_text(TTR("What action should be taken?")); + vbc->add_child(what_action_label); + disk_changed->connect(SceneStringName(confirmed), callable_mp(this, &EditorNode::_reload_modified_scenes)); disk_changed->connect(SceneStringName(confirmed), callable_mp(this, &EditorNode::_reload_project_settings)); - disk_changed->set_ok_button_text(TTR("Discard local changes and reload")); + disk_changed->set_ok_button_text(TTR("Reload from disk")); - disk_changed->add_button(TTR("Keep local changes and overwrite"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave"); + disk_changed->add_button(TTR("Ignore external changes"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave"); disk_changed->connect("custom_action", callable_mp(this, &EditorNode::_resave_scenes)); } diff --git a/editor/editor_node.h b/editor/editor_node.h index 49c1699c28..4a283983c8 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -747,6 +747,7 @@ public: void save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path); void save_resource(const Ref<Resource> &p_resource); void save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path = String()); + void ensure_uid_file(const String &p_new_resource_path); void show_about() { _menu_option_confirm(HELP_ABOUT, false); } diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index bdb5ed2ed9..2b2b32eb22 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -463,10 +463,12 @@ void EditorPropertyPath::_set_read_only(bool p_read_only) { void EditorPropertyPath::_path_selected(const String &p_path) { String full_path = p_path; - ResourceUID::ID id = ResourceLoader::get_resource_uid(full_path); - if (id != ResourceUID::INVALID_ID) { - full_path = ResourceUID::get_singleton()->id_to_text(id); + if (!global) { + const ResourceUID::ID id = ResourceLoader::get_resource_uid(full_path); + if (id != ResourceUID::INVALID_ID) { + full_path = ResourceUID::get_singleton()->id_to_text(id); + } } emit_changed(get_edited_property(), full_path); @@ -476,7 +478,7 @@ void EditorPropertyPath::_path_selected(const String &p_path) { String EditorPropertyPath::_get_path_text() { String full_path = get_edited_property_value(); if (full_path.begins_with("uid://")) { - full_path = ResourceUID::get_singleton()->get_id_path(ResourceUID::get_singleton()->text_to_id(full_path)); + full_path = ResourceUID::uid_to_path(full_path); } return full_path; diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index ba6b42f8f5..3cc3a0f7c2 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -740,10 +740,10 @@ void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint // The format of p_hint_string is: // subType/subTypeHint:nextSubtype ... etc. if (!p_hint_string.is_empty()) { - int hint_subtype_separator = p_hint_string.find(":"); + int hint_subtype_separator = p_hint_string.find_char(':'); if (hint_subtype_separator >= 0) { String subtype_string = p_hint_string.substr(0, hint_subtype_separator); - int slash_pos = subtype_string.find("/"); + int slash_pos = subtype_string.find_char('/'); if (slash_pos >= 0) { subtype_hint = PropertyHint(subtype_string.substr(slash_pos + 1, subtype_string.size() - slash_pos - 1).to_int()); subtype_string = subtype_string.substr(0, slash_pos); @@ -1006,10 +1006,10 @@ void EditorPropertyDictionary::setup(PropertyHint p_hint, const String &p_hint_s PackedStringArray types = p_hint_string.split(";"); if (types.size() > 0 && !types[0].is_empty()) { String key = types[0]; - int hint_key_subtype_separator = key.find(":"); + int hint_key_subtype_separator = key.find_char(':'); if (hint_key_subtype_separator >= 0) { String key_subtype_string = key.substr(0, hint_key_subtype_separator); - int slash_pos = key_subtype_string.find("/"); + int slash_pos = key_subtype_string.find_char('/'); if (slash_pos >= 0) { key_subtype_hint = PropertyHint(key_subtype_string.substr(slash_pos + 1, key_subtype_string.size() - slash_pos - 1).to_int()); key_subtype_string = key_subtype_string.substr(0, slash_pos); @@ -1025,10 +1025,10 @@ void EditorPropertyDictionary::setup(PropertyHint p_hint, const String &p_hint_s } if (types.size() > 1 && !types[1].is_empty()) { String value = types[1]; - int hint_value_subtype_separator = value.find(":"); + int hint_value_subtype_separator = value.find_char(':'); if (hint_value_subtype_separator >= 0) { String value_subtype_string = value.substr(0, hint_value_subtype_separator); - int slash_pos = value_subtype_string.find("/"); + int slash_pos = value_subtype_string.find_char('/'); if (slash_pos >= 0) { value_subtype_hint = PropertyHint(value_subtype_string.substr(slash_pos + 1, value_subtype_string.size() - slash_pos - 1).to_int()); value_subtype_string = value_subtype_string.substr(0, slash_pos); @@ -1173,6 +1173,11 @@ void EditorPropertyDictionary::update_property() { new_prop->set_h_size_flags(SIZE_EXPAND_FILL); new_prop->set_read_only(is_read_only()); slot.set_prop(new_prop); + } else if (slot.index != EditorPropertyDictionaryObject::NEW_KEY_INDEX && slot.index != EditorPropertyDictionaryObject::NEW_VALUE_INDEX) { + Variant key = dict.get_key_at_index(slot.index); + String cs = key.get_construct_string(); + slot.prop->set_label(cs); + slot.prop->set_tooltip_text(cs); } // We need to grab the focus of the property that is being changed, even if the type didn't actually changed. @@ -1200,7 +1205,8 @@ void EditorPropertyDictionary::update_property() { void EditorPropertyDictionary::_remove_pressed(int p_slot_index) { Dictionary dict = object->get_dict().duplicate(); - dict.erase(dict.get_key_at_index(p_slot_index)); + int index = slots[p_slot_index].index; + dict.erase(dict.get_key_at_index(index)); emit_changed(get_edited_property(), dict); } diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 27cbb9810c..d88cc4d5fa 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -96,7 +96,7 @@ class SectionedInspectorFilter : public Object { List<PropertyInfo> pinfo; edited->get_property_list(&pinfo); for (PropertyInfo &pi : pinfo) { - int sp = pi.name.find("/"); + int sp = pi.name.find_char('/'); if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name == "resource_local_to_scene" || pi.name.begins_with("script/") || pi.name.begins_with("_global_script")) { //skip resource stuff continue; @@ -255,7 +255,7 @@ void SectionedInspector::update_category_list() { continue; } - int sp = pi.name.find("/"); + int sp = pi.name.find_char('/'); if (sp == -1) { pi.name = "global/" + pi.name; } diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index d6742c9b55..8989b9cf9b 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -106,8 +106,8 @@ void EditorSettingsDialog::update_navigation_preset() { orbit_mod_key_2 = InputEventKey::create_reference(Key::NONE); pan_mod_key_1 = InputEventKey::create_reference(Key::SHIFT); pan_mod_key_2 = InputEventKey::create_reference(Key::NONE); - zoom_mod_key_1 = InputEventKey::create_reference(Key::SHIFT); - zoom_mod_key_2 = InputEventKey::create_reference(Key::CTRL); + zoom_mod_key_1 = InputEventKey::create_reference(Key::CTRL); + zoom_mod_key_2 = InputEventKey::create_reference(Key::NONE); } else if (nav_scheme == Node3DEditorViewport::NAVIGATION_MAYA) { set_preset = true; set_orbit_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE; diff --git a/editor/editor_translation_parser.cpp b/editor/editor_translation_parser.cpp index 8a77ce4a82..d12bbc1af2 100644 --- a/editor/editor_translation_parser.cpp +++ b/editor/editor_translation_parser.cpp @@ -31,7 +31,6 @@ #include "editor_translation_parser.h" #include "core/error/error_macros.h" -#include "core/io/file_access.h" #include "core/object/script_language.h" #include "core/templates/hash_set.h" @@ -65,6 +64,21 @@ Error EditorTranslationParserPlugin::parse_file(const String &p_path, Vector<Str } } +void EditorTranslationParserPlugin::get_comments(Vector<String> *r_ids_comment, Vector<String> *r_ids_ctx_plural_comment) { + TypedArray<String> ids_comment; + TypedArray<String> ids_ctx_plural_comment; + + if (GDVIRTUAL_CALL(_get_comments, ids_comment, ids_ctx_plural_comment)) { + for (int i = 0; i < ids_comment.size(); i++) { + r_ids_comment->append(ids_comment[i]); + } + + for (int i = 0; i < ids_ctx_plural_comment.size(); i++) { + r_ids_ctx_plural_comment->append(ids_ctx_plural_comment[i]); + } + } +} + void EditorTranslationParserPlugin::get_recognized_extensions(List<String> *r_extensions) const { Vector<String> extensions; if (GDVIRTUAL_CALL(_get_recognized_extensions, extensions)) { @@ -78,6 +92,7 @@ void EditorTranslationParserPlugin::get_recognized_extensions(List<String> *r_ex void EditorTranslationParserPlugin::_bind_methods() { GDVIRTUAL_BIND(_parse_file, "path", "msgids", "msgids_context_plural"); + GDVIRTUAL_BIND(_get_comments, "msgids_comment", "msgids_context_plural_comment"); GDVIRTUAL_BIND(_get_recognized_extensions); } diff --git a/editor/editor_translation_parser.h b/editor/editor_translation_parser.h index 78dc726c52..20c8ed7939 100644 --- a/editor/editor_translation_parser.h +++ b/editor/editor_translation_parser.h @@ -43,10 +43,12 @@ protected: static void _bind_methods(); GDVIRTUAL3(_parse_file, String, TypedArray<String>, TypedArray<Array>) + GDVIRTUAL2(_get_comments, TypedArray<String>, TypedArray<String>) GDVIRTUAL0RC(Vector<String>, _get_recognized_extensions) public: virtual Error parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural); + virtual void get_comments(Vector<String> *r_ids_comment, Vector<String> *r_ids_ctx_plural_comment); virtual void get_recognized_extensions(List<String> *r_extensions) const; }; diff --git a/editor/engine_update_label.cpp b/editor/engine_update_label.cpp index facbfc7c6b..0d40181257 100644 --- a/editor/engine_update_label.cpp +++ b/editor/engine_update_label.cpp @@ -240,8 +240,8 @@ EngineUpdateLabel::VersionType EngineUpdateLabel::_get_version_type(const String } String EngineUpdateLabel::_extract_sub_string(const String &p_line) const { - int j = p_line.find("\"") + 1; - return p_line.substr(j, p_line.find("\"", j) - j); + int j = p_line.find_char('"') + 1; + return p_line.substr(j, p_line.find_char('"', j) - j); } void EngineUpdateLabel::_notification(int p_what) { diff --git a/editor/export/editor_export.cpp b/editor/export/editor_export.cpp index 6ca83c5e25..cddc8173cb 100644 --- a/editor/export/editor_export.cpp +++ b/editor/export/editor_export.cpp @@ -87,6 +87,8 @@ void EditorExport::_save() { config->set_value(section, "encryption_include_filters", preset->get_enc_in_filter()); config->set_value(section, "encryption_exclude_filters", preset->get_enc_ex_filter()); + config->set_value(section, "seed", preset->get_seed()); + config->set_value(section, "encrypt_pck", preset->get_enc_pck()); config->set_value(section, "encrypt_directory", preset->get_enc_directory()); config->set_value(section, "script_export_mode", preset->get_script_export_mode()); @@ -307,6 +309,9 @@ void EditorExport::load_config() { preset->set_script_export_mode(config->get_value(section, "script_export_mode", EditorExportPreset::MODE_SCRIPT_BINARY_TOKENS_COMPRESSED)); preset->set_patches(config->get_value(section, "patches", Vector<String>())); + if (config->has_section_key(section, "seed")) { + preset->set_seed(config->get_value(section, "seed")); + } if (config->has_section_key(section, "encrypt_pck")) { preset->set_enc_pck(config->get_value(section, "encrypt_pck")); } diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 8b8fafcd32..91c9ff9807 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -216,7 +216,7 @@ void EditorExportPlatform::_unload_patches() { PackedData::get_singleton()->clear(); } -Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) { +Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) { ERR_FAIL_COND_V_MSG(p_total < 1, ERR_PARAMETER_RANGE_ERROR, "Must select at least one file to export."); PackData *pd = (PackData *)p_userdata; @@ -247,10 +247,27 @@ Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_pa Ref<FileAccess> ftmp = pd->f; if (sd.encrypted) { + Vector<uint8_t> iv; + if (p_seed != 0) { + uint64_t seed = p_seed; + + const uint8_t *ptr = p_data.ptr(); + int64_t len = p_data.size(); + for (int64_t i = 0; i < len; i++) { + seed = ((seed << 5) + seed) ^ ptr[i]; + } + + RandomPCG rng = RandomPCG(seed, RandomPCG::DEFAULT_INC); + iv.resize(16); + for (int i = 0; i < 16; i++) { + iv.write[i] = rng.rand() % 256; + } + } + fae.instantiate(); ERR_FAIL_COND_V(fae.is_null(), ERR_SKIP); - Error err = fae->open_and_parse(ftmp, p_key, FileAccessEncrypted::MODE_WRITE_AES256, false); + Error err = fae->open_and_parse(ftmp, p_key, FileAccessEncrypted::MODE_WRITE_AES256, false, iv); ERR_FAIL_COND_V(err != OK, ERR_SKIP); ftmp = fae; } @@ -288,15 +305,15 @@ Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_pa return OK; } -Error EditorExportPlatform::_save_pack_patch_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) { +Error EditorExportPlatform::_save_pack_patch_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) { if (_check_hash(PackedData::get_singleton()->get_file_hash(p_path), p_data)) { return OK; } - return _save_pack_file(p_userdata, p_path, p_data, p_file, p_total, p_enc_in_filters, p_enc_ex_filters, p_key); + return _save_pack_file(p_userdata, p_path, p_data, p_file, p_total, p_enc_in_filters, p_enc_ex_filters, p_key, p_seed); } -Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) { +Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) { ERR_FAIL_COND_V_MSG(p_total < 1, ERR_PARAMETER_RANGE_ERROR, "Must select at least one file to export."); String path = p_path.replace_first("res://", ""); @@ -328,12 +345,12 @@ Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_pat return OK; } -Error EditorExportPlatform::_save_zip_patch_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) { +Error EditorExportPlatform::_save_zip_patch_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) { if (_check_hash(PackedData::get_singleton()->get_file_hash(p_path), p_data)) { return OK; } - return _save_zip_file(p_userdata, p_path, p_data, p_file, p_total, p_enc_in_filters, p_enc_ex_filters, p_key); + return _save_zip_file(p_userdata, p_path, p_data, p_file, p_total, p_enc_in_filters, p_enc_ex_filters, p_key, p_seed); } Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const { @@ -932,7 +949,7 @@ Vector<String> EditorExportPlatform::get_forced_export_files() { return files; } -Error EditorExportPlatform::_script_save_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) { +Error EditorExportPlatform::_script_save_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) { Callable cb = ((ScriptCallbackData *)p_userdata)->file_cb; ERR_FAIL_COND_V(!cb.is_valid(), FAILED); @@ -1043,8 +1060,10 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & Vector<String> enc_in_filters; Vector<String> enc_ex_filters; Vector<uint8_t> key; + uint64_t seed = 0; if (enc_pck) { + seed = p_preset->get_seed(); Vector<String> enc_in_split = p_preset->get_enc_in_filter().split(","); for (int i = 0; i < enc_in_split.size(); i++) { String f = enc_in_split[i].strip_edges(); @@ -1116,7 +1135,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } } for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) { - err = p_save_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, 0, paths.size(), enc_in_filters, enc_ex_filters, key); + err = p_save_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, 0, paths.size(), enc_in_filters, enc_ex_filters, key, seed); if (err != OK) { return err; } @@ -1234,7 +1253,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) { - err = p_save_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_save_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, idx, total, enc_in_filters, enc_ex_filters, key, seed); if (err != OK) { return err; } @@ -1266,7 +1285,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & if (importer_type == "keep") { // Just keep file as-is. Vector<uint8_t> array = FileAccess::get_file_as_bytes(path); - err = p_save_func(p_udata, path, array, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_save_func(p_udata, path, array, idx, total, enc_in_filters, enc_ex_filters, key, seed); if (err != OK) { return err; @@ -1309,13 +1328,13 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & sarr.resize(cs.size()); memcpy(sarr.ptrw(), cs.ptr(), sarr.size()); - err = p_save_func(p_udata, path + ".import", sarr, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_save_func(p_udata, path + ".import", sarr, idx, total, enc_in_filters, enc_ex_filters, key, seed); if (err != OK) { return err; } // Now actual remapped file: sarr = FileAccess::get_file_as_bytes(export_path); - err = p_save_func(p_udata, export_path, sarr, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_save_func(p_udata, export_path, sarr, idx, total, enc_in_filters, enc_ex_filters, key, seed); if (err != OK) { return err; } @@ -1345,14 +1364,14 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & if (remap == "path") { String remapped_path = config->get_value("remap", remap); Vector<uint8_t> array = FileAccess::get_file_as_bytes(remapped_path); - err = p_save_func(p_udata, remapped_path, array, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_save_func(p_udata, remapped_path, array, idx, total, enc_in_filters, enc_ex_filters, key, seed); } else if (remap.begins_with("path.")) { String feature = remap.get_slice(".", 1); if (remap_features.has(feature)) { String remapped_path = config->get_value("remap", remap); Vector<uint8_t> array = FileAccess::get_file_as_bytes(remapped_path); - err = p_save_func(p_udata, remapped_path, array, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_save_func(p_udata, remapped_path, array, idx, total, enc_in_filters, enc_ex_filters, key, seed); } else { // Remove paths if feature not enabled. config->erase_section_key("remap", remap); @@ -1378,7 +1397,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & sarr.resize(cs.size()); memcpy(sarr.ptrw(), cs.ptr(), sarr.size()); - err = p_save_func(p_udata, path + ".import", sarr, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_save_func(p_udata, path + ".import", sarr, idx, total, enc_in_filters, enc_ex_filters, key, seed); if (err != OK) { return err; @@ -1399,7 +1418,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } Vector<uint8_t> array = FileAccess::get_file_as_bytes(export_path); - err = p_save_func(p_udata, export_path, array, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_save_func(p_udata, export_path, array, idx, total, enc_in_filters, enc_ex_filters, key, seed); if (err != OK) { return err; } @@ -1463,7 +1482,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & new_file.write[j] = utf8[j]; } - err = p_save_func(p_udata, from + ".remap", new_file, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_save_func(p_udata, from + ".remap", new_file, idx, total, enc_in_filters, enc_ex_filters, key, seed); if (err != OK) { return err; } @@ -1477,7 +1496,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & Vector<String> forced_export = get_forced_export_files(); for (int i = 0; i < forced_export.size(); i++) { Vector<uint8_t> array = FileAccess::get_file_as_bytes(forced_export[i]); - err = p_save_func(p_udata, forced_export[i], array, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_save_func(p_udata, forced_export[i], array, idx, total, enc_in_filters, enc_ex_filters, key, seed); if (err != OK) { return err; } @@ -1489,7 +1508,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & Vector<uint8_t> data = FileAccess::get_file_as_bytes(engine_cfb); DirAccess::remove_file_or_error(engine_cfb); - err = p_save_func(p_udata, "res://" + config_file, data, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_save_func(p_udata, "res://" + config_file, data, idx, total, enc_in_filters, enc_ex_filters, key, seed); if (err != OK) { return err; } @@ -1872,6 +1891,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b Ref<FileAccess> fhead = f; if (enc_pck && enc_directory) { + uint64_t seed = p_preset->get_seed(); String script_key = _get_script_encryption_key(p_preset); Vector<uint8_t> key; key.resize(32); @@ -1906,7 +1926,27 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b return ERR_CANT_CREATE; } - err = fae->open_and_parse(f, key, FileAccessEncrypted::MODE_WRITE_AES256, false); + Vector<uint8_t> iv; + if (seed != 0) { + for (int i = 0; i < pd.file_ofs.size(); i++) { + for (int64_t j = 0; j < pd.file_ofs[i].path_utf8.length(); j++) { + seed = ((seed << 5) + seed) ^ pd.file_ofs[i].path_utf8.get_data()[j]; + } + for (int64_t j = 0; j < pd.file_ofs[i].md5.size(); j++) { + seed = ((seed << 5) + seed) ^ pd.file_ofs[i].md5[j]; + } + seed = ((seed << 5) + seed) ^ pd.file_ofs[i].ofs; + seed = ((seed << 5) + seed) ^ pd.file_ofs[i].size; + } + + RandomPCG rng = RandomPCG(seed, RandomPCG::DEFAULT_INC); + iv.resize(16); + for (int i = 0; i < 16; i++) { + iv.write[i] = rng.rand() % 256; + } + } + + err = fae->open_and_parse(f, key, FileAccessEncrypted::MODE_WRITE_AES256, false, iv); if (err != OK) { add_message(EXPORT_MESSAGE_ERROR, TTR("Save PCK"), TTR("Can't open encrypted file to write.")); return ERR_CANT_CREATE; diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h index 919fb2915a..c7378ffec7 100644 --- a/editor/export/editor_export_platform.h +++ b/editor/export/editor_export_platform.h @@ -53,7 +53,7 @@ protected: static void _bind_methods(); public: - typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); + typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed); typedef Error (*EditorExportRemoveFunction)(void *p_userdata, const String &p_path); typedef Error (*EditorExportSaveSharedObject)(void *p_userdata, const SharedObject &p_so); @@ -114,14 +114,14 @@ private: static bool _check_hash(const uint8_t *p_hash, const Vector<uint8_t> &p_data); - static Error _save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); - static Error _save_pack_patch_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); + static Error _save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed); + static Error _save_pack_patch_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed); static Error _pack_add_shared_object(void *p_userdata, const SharedObject &p_so); static Error _remove_pack_file(void *p_userdata, const String &p_path); - static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); - static Error _save_zip_patch_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); + static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed); + static Error _save_zip_patch_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed); static Error _zip_add_shared_object(void *p_userdata, const SharedObject &p_so); struct ScriptCallbackData { @@ -129,7 +129,7 @@ private: Callable so_cb; }; - static Error _script_save_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); + static Error _script_save_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed); static Error _script_add_shared_object(void *p_userdata, const SharedObject &p_so); void _edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, HashSet<String> &r_list, bool exclude); diff --git a/editor/export/editor_export_platform_pc.cpp b/editor/export/editor_export_platform_pc.cpp index 4eff096840..15d684cac5 100644 --- a/editor/export/editor_export_platform_pc.cpp +++ b/editor/export/editor_export_platform_pc.cpp @@ -223,13 +223,13 @@ Error EditorExportPlatformPC::export_project_data(const Ref<EditorExportPreset> if (err == OK) { err = da->copy_dir(src_path, target_path, -1, true); if (err != OK) { - add_message(EXPORT_MESSAGE_ERROR, TTR("GDExtension"), TTR(vformat("Failed to copy shared object \"%s\".", src_path))); + add_message(EXPORT_MESSAGE_ERROR, TTR("GDExtension"), vformat(TTR("Failed to copy shared object \"%s\"."), src_path)); } } } else { err = da->copy(src_path, target_path); if (err != OK) { - add_message(EXPORT_MESSAGE_ERROR, TTR("GDExtension"), TTR(vformat("Failed to copy shared object \"%s\".", src_path))); + add_message(EXPORT_MESSAGE_ERROR, TTR("GDExtension"), vformat(TTR("Failed to copy shared object \"%s\"."), src_path)); } if (err == OK) { err = sign_shared_object(p_preset, p_debug, target_path); diff --git a/editor/export/editor_export_preset.cpp b/editor/export/editor_export_preset.cpp index da7059b777..8ff5dd7551 100644 --- a/editor/export/editor_export_preset.cpp +++ b/editor/export/editor_export_preset.cpp @@ -451,6 +451,15 @@ String EditorExportPreset::get_enc_ex_filter() const { return enc_ex_filters; } +void EditorExportPreset::set_seed(uint64_t p_seed) { + seed = p_seed; + EditorExport::singleton->save_presets(); +} + +uint64_t EditorExportPreset::get_seed() const { + return seed; +} + void EditorExportPreset::set_enc_pck(bool p_enabled) { enc_pck = p_enabled; EditorExport::singleton->save_presets(); diff --git a/editor/export/editor_export_preset.h b/editor/export/editor_export_preset.h index af3a23fc50..4834a483eb 100644 --- a/editor/export/editor_export_preset.h +++ b/editor/export/editor_export_preset.h @@ -92,6 +92,7 @@ private: String enc_ex_filters; bool enc_pck = false; bool enc_directory = false; + uint64_t seed = 0; String script_key; int script_mode = MODE_SCRIPT_BINARY_TOKENS_COMPRESSED; @@ -165,6 +166,9 @@ public: void set_enc_ex_filter(const String &p_filter); String get_enc_ex_filter() const; + void set_seed(uint64_t p_seed); + uint64_t get_seed() const; + void set_enc_pck(bool p_enabled); bool get_enc_pck() const; diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp index a3cd6523e9..8ae4b856a0 100644 --- a/editor/export/project_export.cpp +++ b/editor/export/project_export.cpp @@ -382,10 +382,16 @@ void ProjectExportDialog::_edit_preset(int p_index) { bool enc_pck_mode = current->get_enc_pck(); enc_pck->set_pressed(enc_pck_mode); + uint64_t seed = current->get_seed(); + if (!updating_seed) { + seed_input->set_text(itos(seed)); + } + enc_directory->set_disabled(!enc_pck_mode); enc_in_filters->set_editable(enc_pck_mode); enc_ex_filters->set_editable(enc_pck_mode); script_key->set_editable(enc_pck_mode); + seed_input->set_editable(enc_pck_mode); bool enc_directory_mode = current->get_enc_directory(); enc_directory->set_pressed(enc_directory_mode); @@ -591,6 +597,21 @@ void ProjectExportDialog::_enc_pck_changed(bool p_pressed) { _update_current_preset(); } +void ProjectExportDialog::_seed_input_changed(const String &p_text) { + if (updating) { + return; + } + + Ref<EditorExportPreset> current = get_current_preset(); + ERR_FAIL_COND(current.is_null()); + + current->set_seed(seed_input->get_text().to_int()); + + updating_seed = true; + _update_current_preset(); + updating_seed = false; +} + void ProjectExportDialog::_enc_directory_changed(bool p_pressed) { if (updating) { return; @@ -1623,6 +1644,10 @@ ProjectExportDialog::ProjectExportDialog() { sec_vb->add_child(script_key_error); sections->add_child(sec_scroll_container); + seed_input = memnew(LineEdit); + seed_input->connect(SceneStringName(text_changed), callable_mp(this, &ProjectExportDialog::_seed_input_changed)); + sec_vb->add_margin_child(TTR("Initialization vector seed"), seed_input); + Label *sec_info = memnew(Label); sec_info->set_text(TTR("Note: Encryption key needs to be stored in the binary,\nyou need to build the export templates from source.")); sec_vb->add_child(sec_info); diff --git a/editor/export/project_export.h b/editor/export/project_export.h index bbf0d81228..68676bfc84 100644 --- a/editor/export/project_export.h +++ b/editor/export/project_export.h @@ -172,6 +172,7 @@ class ProjectExportDialog : public ConfirmationDialog { CheckButton *enc_directory = nullptr; LineEdit *enc_in_filters = nullptr; LineEdit *enc_ex_filters = nullptr; + LineEdit *seed_input = nullptr; OptionButton *script_mode = nullptr; @@ -192,9 +193,11 @@ class ProjectExportDialog : public ConfirmationDialog { bool updating_script_key = false; bool updating_enc_filters = false; + bool updating_seed = false; void _enc_pck_changed(bool p_pressed); void _enc_directory_changed(bool p_pressed); void _enc_filters_changed(const String &p_text); + void _seed_input_changed(const String &p_text); void _script_encryption_key_changed(const String &p_key); bool _validate_script_encryption_key(const String &p_key); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index fcd5a572b4..c7e12d1f3b 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -137,7 +137,7 @@ bool FileSystemList::edit_selected() { String name = get_item_text(s); line_editor->set_text(name); - line_editor->select(0, name.rfind(".")); + line_editor->select(0, name.rfind_char('.')); popup_edit_commited = false; // Start edit popup processing. popup_editor->popup(); @@ -203,9 +203,7 @@ Ref<Texture2D> FileSystemDock::_get_tree_item_icon(bool p_is_valid, const String } } -bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path) { - bool parent_should_expand = false; - +void FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path) { // Create a tree item for the subdirectory. TreeItem *subdirectory_item = tree->create_item(p_parent); String dname = p_dir->get_name(); @@ -213,6 +211,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory if (dname.is_empty()) { dname = "res://"; + resources_item = subdirectory_item; } // Set custom folder color (if applicable). @@ -258,16 +257,13 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory } else { subdirectory_item->set_collapsed(!uncollapsed_paths.has(lpath)); } - if (!searched_tokens.is_empty() && _matches_all_search_tokens(dname)) { - parent_should_expand = true; - } // Create items for all subdirectories. bool reversed = file_sort == FileSortOption::FILE_SORT_NAME_REVERSE; for (int i = reversed ? p_dir->get_subdir_count() - 1 : 0; reversed ? i >= 0 : i < p_dir->get_subdir_count(); reversed ? i-- : i++) { - parent_should_expand = (_create_tree(subdirectory_item, p_dir->get_subdir(i), uncollapsed_paths, p_select_in_favorites, p_unfold_path) || parent_should_expand); + _create_tree(subdirectory_item, p_dir->get_subdir(i), uncollapsed_paths, p_select_in_favorites, p_unfold_path); } // Create all items for the files in the subdirectory. @@ -283,17 +279,6 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory continue; } - String file_name = p_dir->get_file(i); - if (!searched_tokens.is_empty()) { - if (!_matches_all_search_tokens(file_name)) { - // The searched string is not in the file name, we skip it. - continue; - } else { - // We expand all parents. - parent_should_expand = true; - } - } - FileInfo file_info; file_info.name = p_dir->get_file(i); file_info.type = p_dir->get_file_type(i); @@ -346,24 +331,12 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory subdirectory_item->set_as_cursor(0); } } - - if (!searched_tokens.is_empty()) { - if (parent_should_expand) { - subdirectory_item->set_collapsed(false); - } else if (dname != "res://") { - subdirectory_item->get_parent()->remove_child(subdirectory_item); - memdelete(subdirectory_item); - } - } - - return parent_should_expand; } Vector<String> FileSystemDock::get_uncollapsed_paths() const { Vector<String> uncollapsed_paths; TreeItem *root = tree->get_root(); if (root) { - TreeItem *favorites_item = root->get_first_child(); if (!favorites_item->is_collapsed()) { uncollapsed_paths.push_back(favorites_item->get_metadata(0)); } @@ -400,7 +373,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo TreeItem *root = tree->create_item(); // Handles the favorites. - TreeItem *favorites_item = tree->create_item(root); + favorites_item = tree->create_item(root); favorites_item->set_icon(0, get_editor_theme_icon(SNAME("Favorites"))); favorites_item->set_text(0, TTR("Favorites:")); favorites_item->set_metadata(0, "Favorites"); @@ -453,24 +426,22 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo color = Color(1, 1, 1); } - if (searched_tokens.is_empty() || _matches_all_search_tokens(text)) { - TreeItem *ti = tree->create_item(favorites_item); - ti->set_text(0, text); - ti->set_icon(0, icon); - ti->set_icon_modulate(0, color); - ti->set_tooltip_text(0, favorite); - ti->set_selectable(0, true); - ti->set_metadata(0, favorite); - if (p_select_in_favorites && favorite == current_path) { - ti->select(0); - ti->set_as_cursor(0); - } - if (!favorite.ends_with("/")) { - Array udata; - udata.push_back(tree_update_id); - udata.push_back(ti); - EditorResourcePreview::get_singleton()->queue_resource_preview(favorite, this, "_tree_thumbnail_done", udata); - } + TreeItem *ti = tree->create_item(favorites_item); + ti->set_text(0, text); + ti->set_icon(0, icon); + ti->set_icon_modulate(0, color); + ti->set_tooltip_text(0, favorite); + ti->set_selectable(0, true); + ti->set_metadata(0, favorite); + if (p_select_in_favorites && favorite == current_path) { + ti->select(0); + ti->set_as_cursor(0); + } + if (!favorite.ends_with("/")) { + Array udata; + udata.push_back(tree_update_id); + udata.push_back(ti); + EditorResourcePreview::get_singleton()->queue_resource_preview(favorite, this, "_tree_thumbnail_done", udata); } } @@ -676,7 +647,6 @@ void FileSystemDock::_tree_multi_selected(Object *p_item, int p_column, bool p_s return; } - TreeItem *favorites_item = tree->get_root()->get_first_child(); if (selected->get_parent() == favorites_item && !String(selected->get_metadata(0)).ends_with("/")) { // Go to the favorites if we click in the favorites and the path has changed. current_path = "Favorites"; @@ -771,6 +741,36 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa } } +bool FileSystemDock::_update_filtered_items(TreeItem *p_tree_item) { + TreeItem *item = p_tree_item; + if (!item) { + item = tree->get_root(); + } + ERR_FAIL_NULL_V(item, false); + + bool keep_visible = false; + for (TreeItem *child = item->get_first_child(); child; child = child->get_next()) { + keep_visible = _update_filtered_items(child) || keep_visible; + } + + if (searched_tokens.is_empty()) { + item->set_visible(true); + // Always uncollapse root (the hidden item above res:// and favorites). + item->set_collapsed(item != tree->get_root() && !uncollapsed_paths_before_search.has(item->get_metadata(0))); + return true; + } + + if (keep_visible) { + item->set_collapsed(false); + } else { + // res:// and favorites are always visible. + keep_visible = item == resources_item || item == favorites_item; + keep_visible = keep_visible || _matches_all_search_tokens(item->get_text(0)); + } + item->set_visible(keep_visible); + return keep_visible; +} + void FileSystemDock::navigate_to_path(const String &p_path) { file_list_search_box->clear(); _navigate_to_path(p_path); @@ -2028,7 +2028,6 @@ Vector<String> FileSystemDock::_tree_get_selected(bool remove_self_inclusion, bo // Build a list of selected items with the active one at the first position. Vector<String> selected_strings; - TreeItem *favorites_item = tree->get_root()->get_first_child(); TreeItem *cursor_item = tree->get_selected(); if (cursor_item && (p_include_unselected_cursor || cursor_item->is_selected(0)) && cursor_item != favorites_item) { selected_strings.push_back(cursor_item->get_metadata(0)); @@ -2433,7 +2432,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected if (to_rename.is_file) { String name = to_rename.path.get_file(); - tree->set_editor_selection(0, name.rfind(".")); + tree->set_editor_selection(0, name.rfind_char('.')); } else { String name = to_rename.path.left(-1).get_file(); // Removes the "/" suffix for folders. tree->set_editor_selection(0, name.length()); @@ -2637,16 +2636,12 @@ void FileSystemDock::_search_changed(const String &p_text, const Control *p_from tree_search_box->set_text(searched_string); } - bool unfold_path = (p_text.is_empty() && !current_path.is_empty()); - switch (display_mode) { - case DISPLAY_MODE_TREE_ONLY: { - _update_tree(searched_tokens.is_empty() ? uncollapsed_paths_before_search : Vector<String>(), false, false, unfold_path); - } break; - case DISPLAY_MODE_HSPLIT: - case DISPLAY_MODE_VSPLIT: { - _update_file_list(false); - _update_tree(searched_tokens.is_empty() ? uncollapsed_paths_before_search : Vector<String>(), false, false, unfold_path); - } break; + _update_filtered_items(); + if (display_mode == DISPLAY_MODE_HSPLIT || display_mode == DISPLAY_MODE_VSPLIT) { + _update_file_list(false); + } + if (searched_tokens.is_empty()) { + _navigate_to_path(current_path); } } @@ -2786,7 +2781,6 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from) // Check if the first selected is in favorite. TreeItem *selected = tree->get_next_selected(tree->get_root()); while (selected) { - TreeItem *favorites_item = tree->get_root()->get_first_child(); if (selected == favorites_item) { // The "Favorites" item is not draggable. return Variant(); @@ -2838,10 +2832,6 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da } int drop_section = tree->get_drop_section_at_position(p_point); - TreeItem *favorites_item = tree->get_root()->get_first_child(); - - TreeItem *resources_item = favorites_item->get_next(); - if (ti == favorites_item) { return (drop_section == 1); // The parent, first fav. } @@ -2922,9 +2912,6 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, int drop_position; Vector<String> drag_files = drag_data["files"]; - TreeItem *favorites_item = tree->get_root()->get_first_child(); - TreeItem *resources_item = favorites_item->get_next(); - if (ti == favorites_item) { // Drop on the favorite folder. drop_position = 0; @@ -3352,7 +3339,6 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect [[maybe_unused]] bool added_separator = false; if (favorites_list.has(fpath)) { - TreeItem *favorites_item = tree->get_root()->get_first_child(); TreeItem *cursor_item = tree->get_selected(); bool is_item_in_favorites = false; while (cursor_item != nullptr) { @@ -3672,10 +3658,10 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) { tree_item->select(0); } else { // Find parent folder. - fpath = fpath.substr(0, fpath.rfind("/") + 1); + fpath = fpath.substr(0, fpath.rfind_char('/') + 1); if (fpath.size() > String("res://").size()) { fpath = fpath.left(fpath.size() - 2); // Remove last '/'. - const int slash_idx = fpath.rfind("/"); + const int slash_idx = fpath.rfind_char('/'); fpath = fpath.substr(slash_idx + 1, fpath.size() - slash_idx - 1); } diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index fe83129c07..d2e403a8af 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -232,6 +232,8 @@ private: FileSystemTree *tree = nullptr; FileSystemList *files = nullptr; bool import_dock_needs_update = false; + TreeItem *resources_item = nullptr; + TreeItem *favorites_item = nullptr; bool holding_branch = false; Vector<TreeItem *> tree_items_selected_on_drag_begin; @@ -245,9 +247,10 @@ private: void _reselect_items_selected_on_drag_begin(bool reset = false); Ref<Texture2D> _get_tree_item_icon(bool p_is_valid, const String &p_file_type, const String &p_icon_path); - bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false); + void _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false); void _update_tree(const Vector<String> &p_uncollapsed_paths = Vector<String>(), bool p_uncollapse_root = false, bool p_select_in_favorites = false, bool p_unfold_path = false); void _navigate_to_path(const String &p_path, bool p_select_in_favorites = false); + bool _update_filtered_items(TreeItem *p_tree_item = nullptr); void _file_list_gui_input(Ref<InputEvent> p_event); void _tree_gui_input(Ref<InputEvent> p_event); diff --git a/editor/gui/editor_file_dialog.cpp b/editor/gui/editor_file_dialog.cpp index ceff62723f..0381609804 100644 --- a/editor/gui/editor_file_dialog.cpp +++ b/editor/gui/editor_file_dialog.cpp @@ -65,7 +65,7 @@ void EditorFileDialog::_native_popup() { } else if (access == ACCESS_USERDATA) { root = OS::get_singleton()->get_user_data_dir(); } - DisplayServer::get_singleton()->file_dialog_with_options_show(get_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, _get_options(), callable_mp(this, &EditorFileDialog::_native_dialog_cb)); + DisplayServer::get_singleton()->file_dialog_with_options_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), processed_filters, _get_options(), callable_mp(this, &EditorFileDialog::_native_dialog_cb)); } void EditorFileDialog::popup(const Rect2i &p_rect) { @@ -156,7 +156,7 @@ void EditorFileDialog::popup_file_dialog() { } void EditorFileDialog::_focus_file_text() { - int lp = file->get_text().rfind("."); + int lp = file->get_text().rfind_char('.'); if (lp != -1) { file->select(0, lp); file->grab_focus(); @@ -1148,37 +1148,54 @@ void EditorFileDialog::_filter_selected(int) { void EditorFileDialog::update_filters() { filter->clear(); + processed_filters.clear(); if (filters.size() > 1) { String all_filters; + String all_filters_full; const int max_filters = 5; for (int i = 0; i < MIN(max_filters, filters.size()); i++) { - String flt = filters[i].get_slice(";", 0).strip_edges(); + String flt = filters[i].get_slicec(';', 0).strip_edges(); if (i > 0) { all_filters += ", "; } all_filters += flt; } + for (int i = 0; i < filters.size(); i++) { + String flt = filters[i].get_slicec(';', 0).strip_edges(); + if (i > 0) { + all_filters_full += ","; + } + all_filters_full += flt; + } if (max_filters < filters.size()) { all_filters += ", ..."; } - filter->add_item(TTR("All Recognized") + " (" + all_filters + ")"); + String f = TTR("All Recognized") + " (" + all_filters + ")"; + filter->add_item(f); + processed_filters.push_back(all_filters_full + ";" + f); } for (int i = 0; i < filters.size(); i++) { - String flt = filters[i].get_slice(";", 0).strip_edges(); + String flt = filters[i].get_slicec(';', 0).strip_edges(); String desc = filters[i].get_slice(";", 1).strip_edges(); if (desc.length()) { - filter->add_item(desc + " (" + flt + ")"); + String f = desc + " (" + flt + ")"; + filter->add_item(f); + processed_filters.push_back(flt + ";" + f); } else { - filter->add_item("(" + flt + ")"); + String f = "(" + flt + ")"; + filter->add_item(f); + processed_filters.push_back(flt + ";" + f); } } - filter->add_item(TTR("All Files (*)")); + String f = TTR("All Files (*)"); + filter->add_item(f); + processed_filters.push_back("*.*;" + f); } void EditorFileDialog::clear_filters() { @@ -1246,7 +1263,7 @@ void EditorFileDialog::set_current_path(const String &p_path) { if (!p_path.size()) { return; } - int pos = MAX(p_path.rfind("/"), p_path.rfind("\\")); + int pos = MAX(p_path.rfind_char('/'), p_path.rfind_char('\\')); if (pos == -1) { set_current_file(p_path); } else { diff --git a/editor/gui/editor_file_dialog.h b/editor/gui/editor_file_dialog.h index 1922155133..7a928a6188 100644 --- a/editor/gui/editor_file_dialog.h +++ b/editor/gui/editor_file_dialog.h @@ -145,6 +145,7 @@ private: void _push_history(); Vector<String> filters; + Vector<String> processed_filters; bool previews_enabled = true; bool preview_waiting = false; diff --git a/editor/gui/editor_toaster.cpp b/editor/gui/editor_toaster.cpp index ffea1736a3..ff425ba65e 100644 --- a/editor/gui/editor_toaster.cpp +++ b/editor/gui/editor_toaster.cpp @@ -506,6 +506,14 @@ void EditorToaster::instant_close(Control *p_control) { p_control->set_modulate(Color(1, 1, 1, 0)); } +void EditorToaster::_bind_methods() { + ClassDB::bind_method(D_METHOD("push_toast", "message", "severity", "tooltip"), &EditorToaster::_popup_str, DEFVAL(EditorToaster::SEVERITY_INFO), DEFVAL(String())); + + BIND_ENUM_CONSTANT(SEVERITY_INFO); + BIND_ENUM_CONSTANT(SEVERITY_WARNING); + BIND_ENUM_CONSTANT(SEVERITY_ERROR); +} + EditorToaster *EditorToaster::get_singleton() { return singleton; } diff --git a/editor/gui/editor_toaster.h b/editor/gui/editor_toaster.h index 6fcc2ce3e9..0d0080945e 100644 --- a/editor/gui/editor_toaster.h +++ b/editor/gui/editor_toaster.h @@ -105,6 +105,7 @@ private: void _toast_theme_changed(Control *p_control); protected: + static void _bind_methods(); static EditorToaster *singleton; void _notification(int p_what); diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp index c11da5dfdb..e89912d5bc 100644 --- a/editor/gui/scene_tree_editor.cpp +++ b/editor/gui/scene_tree_editor.cpp @@ -1098,8 +1098,19 @@ void SceneTreeEditor::rename_node(Node *p_node, const String &p_name, TreeItem * // Trim leading/trailing whitespace to prevent node names from containing accidental whitespace, which would make it more difficult to get the node via `get_node()`. new_name = new_name.strip_edges(); + if (new_name.is_empty() && p_node->get_owner() != nullptr && !p_node->get_scene_file_path().is_empty()) { + // If name is empty and node is root of an instance, revert to the original name. + const Ref<PackedScene> node_scene = ResourceLoader::load(p_node->get_scene_file_path()); + if (node_scene.is_valid()) { + const Ref<SceneState> &state = node_scene->get_state(); + if (state->get_node_count() > 0) { + new_name = state->get_node_name(0); // Root's name. + } + } + } + if (new_name.is_empty()) { - // If name is empty, fallback to class name. + // If name is still empty, fallback to class name. if (GLOBAL_GET("editor/naming/node_name_casing").operator int() != NAME_CASING_PASCAL_CASE) { new_name = Node::adjust_name_casing(p_node->get_class()); } else { diff --git a/editor/import/resource_importer_imagefont.cpp b/editor/import/resource_importer_imagefont.cpp index 44ae2b5ff1..950058e88e 100644 --- a/editor/import/resource_importer_imagefont.cpp +++ b/editor/import/resource_importer_imagefont.cpp @@ -199,7 +199,7 @@ Error ResourceImporterImageFont::import(ResourceUID::ID p_source_id, const Strin case STEP_OFF_Y_BEGIN: { // Read advance and offset. if (range[c] == ' ') { - int next = range.find(" ", c + 1); + int next = range.find_char(' ', c + 1); if (next < c) { next = range.length(); } diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 71ccef4752..d72c15bc2a 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -241,7 +241,10 @@ void ResourceImporterTexture::get_import_options(const String &p_path, List<Impo r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/normal_map_invert_y"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/hdr_as_srgb"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/hdr_clamp_exposure"), false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "process/size_limit", PROPERTY_HINT_RANGE, "0,4096,1"), 0)); + + // Maximum bound is the highest allowed value for lossy compression (the lowest common denominator). + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "process/size_limit", PROPERTY_HINT_RANGE, "0,16383,1"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "detect_3d/compress_to", PROPERTY_HINT_ENUM, "Disabled,VRAM Compressed,Basis Universal"), (p_preset == PRESET_DETECT) ? 1 : 0)); // Do path based customization only if a path was passed. @@ -454,7 +457,28 @@ Error ResourceImporterTexture::import(ResourceUID::ID p_source_id, const String const bool normal_map_invert_y = p_options["process/normal_map_invert_y"]; // Support for texture streaming is not implemented yet. const bool stream = false; - const int size_limit = p_options["process/size_limit"]; + + int size_limit = p_options["process/size_limit"]; + bool using_fallback_size_limit = false; + if (size_limit == 0) { + using_fallback_size_limit = true; + // If no size limit is defined, use a fallback size limit to prevent textures from looking incorrect or failing to import. + switch (compress_mode) { + case COMPRESS_LOSSY: + // Maximum WebP size on either axis. + size_limit = 16383; + break; + case COMPRESS_BASIS_UNIVERSAL: + // Maximum Basis Universal size on either axis. + size_limit = 16384; + break; + default: + // As of June 2024, no GPU can correctly display a texture larger than 32768 pixels on either axis. + size_limit = 32768; + break; + } + } + const bool hdr_as_srgb = p_options["process/hdr_as_srgb"]; if (hdr_as_srgb) { loader_flags |= ImageFormatLoader::FLAG_FORCE_LINEAR; @@ -523,11 +547,19 @@ Error ResourceImporterTexture::import(ResourceUID::ID p_source_id, const String int new_width = size_limit; int new_height = target_image->get_height() * new_width / target_image->get_width(); + if (using_fallback_size_limit) { + // Only warn if downsizing occurred when the user did not explicitly request it. + WARN_PRINT(vformat("%s: Texture was downsized on import as its width (%d pixels) exceeded the importable size limit (%d pixels).", p_source_file, target_image->get_width(), size_limit)); + } target_image->resize(new_width, new_height, Image::INTERPOLATE_CUBIC); } else { int new_height = size_limit; int new_width = target_image->get_width() * new_height / target_image->get_height(); + if (using_fallback_size_limit) { + // Only warn if downsizing occurred when the user did not explicitly request it. + WARN_PRINT(vformat("%s: Texture was downsized on import as its height (%d pixels) exceeded the importable size limit (%d pixels).", p_source_file, target_image->get_height(), size_limit)); + } target_image->resize(new_width, new_height, Image::INTERPOLATE_CUBIC); } @@ -558,7 +590,7 @@ Error ResourceImporterTexture::import(ResourceUID::ID p_source_id, const String for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { const Color color = target_image->get_pixel(i, j); - target_image->set_pixel(i, j, Color(color.r, 1 - color.g, color.b)); + target_image->set_pixel(i, j, Color(color.r, 1 - color.g, color.b, color.a)); } } } diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index 921467ccbc..7b2e6e81ee 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -441,7 +441,7 @@ void LocalizationEditor::_filesystem_files_moved(const String &p_old_file, const bool remapped_files_updated = false; for (int j = 0; j < remapped_files.size(); j++) { - int splitter_pos = remapped_files[j].rfind(":"); + int splitter_pos = remapped_files[j].rfind_char(':'); String res_path = remapped_files[j].substr(0, splitter_pos); if (res_path == p_old_file) { @@ -482,7 +482,7 @@ void LocalizationEditor::_filesystem_file_removed(const String &p_file) { for (int i = 0; i < remap_keys.size() && !remaps_changed; i++) { PackedStringArray remapped_files = remaps[remap_keys[i]]; for (int j = 0; j < remapped_files.size() && !remaps_changed; j++) { - int splitter_pos = remapped_files[j].rfind(":"); + int splitter_pos = remapped_files[j].rfind_char(':'); String res_path = remapped_files[j].substr(0, splitter_pos); remaps_changed = p_file == res_path; if (remaps_changed) { @@ -567,7 +567,7 @@ void LocalizationEditor::update_translations() { PackedStringArray selected = remaps[keys[i]]; for (int j = 0; j < selected.size(); j++) { const String &s2 = selected[j]; - int qp = s2.rfind(":"); + int qp = s2.rfind_char(':'); String path = s2.substr(0, qp); String locale = s2.substr(qp + 1, s2.length()); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 8db106da07..7c9c003ea1 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -907,7 +907,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons 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().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(); + String new_etag = headers[i].substr(headers[i].find_char(':') + 1, headers[i].length()).strip_edges(); Ref<FileAccess> file = FileAccess::open(cache_filename_base + ".etag", FileAccess::WRITE); if (file.is_valid()) { file->store_line(new_etag); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 62793fbcb5..f91a052a24 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1930,37 +1930,50 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { // Drag resize handles if (drag_type == DRAG_NONE) { - if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && ((b->is_alt_pressed() && b->is_command_or_control_pressed()) || tool == TOOL_SCALE)) { + if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && + ((tool == TOOL_SELECT && b->is_alt_pressed() && b->is_command_or_control_pressed()) || tool == TOOL_SCALE)) { bool has_locked_items = false; List<CanvasItem *> selection = _get_edited_canvas_items(false, true, &has_locked_items); - if (selection.size() == 1) { + + // Remove non-movable nodes. + for (CanvasItem *ci : selection) { + if (!_is_node_movable(ci, true)) { + selection.erase(ci); + } + } + + if (!selection.is_empty()) { CanvasItem *ci = selection.front()->get(); - if (_is_node_movable(ci)) { - Transform2D xform = transform * ci->get_global_transform_with_canvas(); - Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); - Transform2D simple_xform = viewport->get_transform() * unscaled_transform; + Transform2D edit_transform; + if (!Math::is_inf(temp_pivot.x) || !Math::is_inf(temp_pivot.y)) { + edit_transform = Transform2D(ci->_edit_get_rotation(), temp_pivot); + } else { + edit_transform = ci->_edit_get_transform(); + } - drag_type = DRAG_SCALE_BOTH; + Transform2D xform = transform * ci->get_global_transform_with_canvas(); + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * edit_transform).orthonormalized(); + Transform2D simple_xform = viewport->get_transform() * unscaled_transform; - if (show_transformation_gizmos) { - Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE); - Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); - if (x_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) { - drag_type = DRAG_SCALE_X; - } - Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); - if (y_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) { - drag_type = DRAG_SCALE_Y; - } - } + drag_type = DRAG_SCALE_BOTH; - drag_from = transform.affine_inverse().xform(b->get_position()); - drag_selection = List<CanvasItem *>(); - drag_selection.push_back(ci); - _save_canvas_item_state(drag_selection); - return true; + if (show_transformation_gizmos) { + Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE); + Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + if (x_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) { + drag_type = DRAG_SCALE_X; + } + Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + if (y_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) { + drag_type = DRAG_SCALE_Y; + } } + + drag_from = transform.affine_inverse().xform(b->get_position()); + drag_selection = selection; + _save_canvas_item_state(drag_selection); + return true; } else { if (has_locked_items) { EditorToaster::get_singleton()->popup_str(TTR(locked_transform_warning), EditorToaster::SEVERITY_WARNING); @@ -1968,66 +1981,87 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { return has_locked_items; } } - } - - if (drag_type == DRAG_SCALE_BOTH || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y) { + } else if (drag_type == DRAG_SCALE_BOTH || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y) { // Resize the node if (m.is_valid()) { _restore_canvas_item_state(drag_selection); - CanvasItem *ci = drag_selection.front()->get(); drag_to = transform.affine_inverse().xform(m->get_position()); - Transform2D parent_xform = ci->get_global_transform_with_canvas() * ci->get_transform().affine_inverse(); - Transform2D unscaled_transform = (transform * parent_xform * ci->_edit_get_transform()).orthonormalized(); - Transform2D simple_xform = (viewport->get_transform() * unscaled_transform).affine_inverse() * transform; - - bool uniform = m->is_shift_pressed(); - bool is_ctrl = m->is_command_or_control_pressed(); - - Point2 drag_from_local = simple_xform.xform(drag_from); - Point2 drag_to_local = simple_xform.xform(drag_to); - Point2 offset = drag_to_local - drag_from_local; + Size2 scale_max; + if (drag_type != DRAG_SCALE_BOTH) { + for (CanvasItem *ci : drag_selection) { + scale_max = scale_max.max(ci->_edit_get_scale()); + } + } - Size2 scale = ci->_edit_get_scale(); - Size2 original_scale = scale; - real_t ratio = scale.y / scale.x; - if (drag_type == DRAG_SCALE_BOTH) { - Size2 scale_factor = drag_to_local / drag_from_local; - if (uniform) { - scale *= (scale_factor.x + scale_factor.y) / 2.0; + for (CanvasItem *ci : drag_selection) { + Transform2D edit_transform; + bool using_temp_pivot = !Math::is_inf(temp_pivot.x) || !Math::is_inf(temp_pivot.y); + if (using_temp_pivot) { + edit_transform = Transform2D(ci->_edit_get_rotation(), temp_pivot); } else { - scale *= scale_factor; + edit_transform = ci->_edit_get_transform(); } - } else { - Size2 scale_factor = Vector2(offset.x, -offset.y) / SCALE_HANDLE_DISTANCE; - Size2 parent_scale = parent_xform.get_scale(); - scale_factor *= Vector2(1.0 / parent_scale.x, 1.0 / parent_scale.y); - if (drag_type == DRAG_SCALE_X) { - scale.x += scale_factor.x; + Transform2D parent_xform = ci->get_global_transform_with_canvas() * ci->get_transform().affine_inverse(); + Transform2D unscaled_transform = (transform * parent_xform * edit_transform).orthonormalized(); + Transform2D simple_xform = (viewport->get_transform() * unscaled_transform).affine_inverse() * transform; + + bool uniform = m->is_shift_pressed(); + bool is_ctrl = m->is_command_or_control_pressed(); + + Point2 drag_from_local = simple_xform.xform(drag_from); + Point2 drag_to_local = simple_xform.xform(drag_to); + Point2 offset = drag_to_local - drag_from_local; + + Size2 scale = ci->_edit_get_scale(); + Size2 original_scale = scale; + real_t ratio = scale.y / scale.x; + if (drag_type == DRAG_SCALE_BOTH) { + Size2 scale_factor = drag_to_local / drag_from_local; if (uniform) { - scale.y = scale.x * ratio; + scale *= (scale_factor.x + scale_factor.y) / 2.0; + } else { + scale *= scale_factor; } - } else if (drag_type == DRAG_SCALE_Y) { - scale.y -= scale_factor.y; - if (uniform) { - scale.x = scale.y / ratio; + } else { + Size2 scale_factor = Vector2(offset.x, -offset.y) / SCALE_HANDLE_DISTANCE; + Size2 parent_scale = parent_xform.get_scale(); + // Take into account the biggest scale, so all nodes are scaled uniformly. + scale_factor *= Vector2(1.0 / parent_scale.x, 1.0 / parent_scale.y) / (scale_max / original_scale); + + if (drag_type == DRAG_SCALE_X) { + scale.x += scale_factor.x; + if (uniform) { + scale.y = scale.x * ratio; + } + } else if (drag_type == DRAG_SCALE_Y) { + scale.y -= scale_factor.y; + if (uniform) { + scale.x = scale.y / ratio; + } } } - } - if (snap_scale && !is_ctrl) { - if (snap_relative) { - scale.x = original_scale.x * (roundf((scale.x / original_scale.x) / snap_scale_step) * snap_scale_step); - scale.y = original_scale.y * (roundf((scale.y / original_scale.y) / snap_scale_step) * snap_scale_step); - } else { - scale.x = roundf(scale.x / snap_scale_step) * snap_scale_step; - scale.y = roundf(scale.y / snap_scale_step) * snap_scale_step; + if (snap_scale && !is_ctrl) { + if (snap_relative) { + scale.x = original_scale.x * (Math::round((scale.x / original_scale.x) / snap_scale_step) * snap_scale_step); + scale.y = original_scale.y * (Math::round((scale.y / original_scale.y) / snap_scale_step) * snap_scale_step); + } else { + scale.x = Math::round(scale.x / snap_scale_step) * snap_scale_step; + scale.y = Math::round(scale.y / snap_scale_step) * snap_scale_step; + } + } + + ci->_edit_set_scale(scale); + + if (using_temp_pivot) { + Point2 ci_origin = ci->_edit_get_transform().get_origin(); + ci->_edit_set_position(ci_origin + (ci_origin - temp_pivot) * ((scale - original_scale) / original_scale)); } } - ci->_edit_set_scale(scale); return true; } @@ -2075,7 +2109,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { if (drag_type == DRAG_NONE) { //Start moving the nodes if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed()) { - if ((b->is_alt_pressed() && !b->is_command_or_control_pressed()) || tool == TOOL_MOVE) { + if ((tool == TOOL_SELECT && b->is_alt_pressed() && !b->is_command_or_control_pressed()) || tool == TOOL_MOVE) { bool has_locked_items = false; List<CanvasItem *> selection = _get_edited_canvas_items(false, true, &has_locked_items); @@ -2135,7 +2169,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } Point2 drag_delta = drag_to - drag_from; - if (drag_selection.size() == 1 && (drag_type == DRAG_MOVE_X || drag_type == DRAG_MOVE_Y)) { + if (drag_type == DRAG_MOVE_X || drag_type == DRAG_MOVE_Y) { const CanvasItem *selected = drag_selection.front()->get(); Transform2D parent_xform = selected->get_global_transform_with_canvas() * selected->get_transform().affine_inverse(); Transform2D unscaled_transform = (transform * parent_xform * selected->_edit_get_transform()).orthonormalized(); @@ -3468,16 +3502,14 @@ void CanvasItemEditor::_draw_selection() { Ref<Texture2D> previous_position_icon = get_editor_theme_icon(SNAME("EditorPositionPrevious")); RID vp_ci = viewport->get_canvas_item(); - List<CanvasItem *> selection = _get_edited_canvas_items(true, false); - bool single = selection.size() == 1; + bool transform_tool = tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_SCALE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT; + for (CanvasItem *E : selection) { CanvasItem *ci = Object::cast_to<CanvasItem>(E); CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); - bool item_locked = ci->has_meta("_edit_lock_"); - // Draw the previous position if we are dragging the node if (show_helpers && (drag_type == DRAG_MOVE || drag_type == DRAG_ROTATE || @@ -3502,6 +3534,7 @@ void CanvasItemEditor::_draw_selection() { } } + bool item_locked = ci->has_meta("_edit_lock_"); Transform2D xform = transform * ci->get_global_transform_with_canvas(); // Draw the selected items position / surrounding boxes @@ -3531,7 +3564,7 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_set_transform_matrix(viewport->get_transform()); } - if (single && !item_locked && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_SCALE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks + if (single && !item_locked && transform_tool) { // Draw the pivot if (ci->_edit_use_pivot()) { // Draw the node's pivot @@ -3574,73 +3607,88 @@ void CanvasItemEditor::_draw_selection() { select_handle->draw(vp_ci, (ofs - (select_handle->get_size() / 2)).floor()); } } + } + } - // Draw the move handles - bool is_ctrl = Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL); - bool is_alt = Input::get_singleton()->is_key_pressed(Key::ALT); - if (tool == TOOL_MOVE && show_transformation_gizmos) { - if (_is_node_movable(ci)) { - Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); - Transform2D simple_xform = viewport->get_transform() * unscaled_transform; + // Remove non-movable nodes. + for (CanvasItem *ci : selection) { + if (!_is_node_movable(ci, true)) { + selection.erase(ci); + } + } - Size2 move_factor = Size2(MOVE_HANDLE_DISTANCE, MOVE_HANDLE_DISTANCE); - viewport->draw_set_transform_matrix(simple_xform); + if (!selection.is_empty() && transform_tool && show_transformation_gizmos) { + CanvasItem *ci = selection.front()->get(); - Vector<Point2> points = { - Vector2(move_factor.x * EDSCALE, 5 * EDSCALE), - Vector2(move_factor.x * EDSCALE, -5 * EDSCALE), - Vector2((move_factor.x + 10) * EDSCALE, 0) - }; + Transform2D xform = transform * ci->get_global_transform_with_canvas(); + bool is_ctrl = Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL); + bool is_alt = Input::get_singleton()->is_key_pressed(Key::ALT); - viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor))); - viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)), Math::round(EDSCALE)); + // Draw the move handles. + if ((tool == TOOL_SELECT && is_alt && !is_ctrl) || tool == TOOL_MOVE) { + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); + Transform2D simple_xform = viewport->get_transform() * unscaled_transform; - points.clear(); - points.push_back(Vector2(5 * EDSCALE, move_factor.y * EDSCALE)); - points.push_back(Vector2(-5 * EDSCALE, move_factor.y * EDSCALE)); - points.push_back(Vector2(0, (move_factor.y + 10) * EDSCALE)); + Size2 move_factor = Size2(MOVE_HANDLE_DISTANCE, MOVE_HANDLE_DISTANCE); + viewport->draw_set_transform_matrix(simple_xform); - viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor))); - viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)), Math::round(EDSCALE)); + Vector<Point2> points = { + Vector2(move_factor.x * EDSCALE, 5 * EDSCALE), + Vector2(move_factor.x * EDSCALE, -5 * EDSCALE), + Vector2((move_factor.x + 10) * EDSCALE, 0) + }; - viewport->draw_set_transform_matrix(viewport->get_transform()); - } - } + viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor))); + viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)), Math::round(EDSCALE)); - // Draw the rescale handles - if (show_transformation_gizmos && ((is_alt && is_ctrl) || tool == TOOL_SCALE || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y)) { - if (_is_node_movable(ci)) { - Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); - Transform2D simple_xform = viewport->get_transform() * unscaled_transform; + points.clear(); + points.push_back(Vector2(5 * EDSCALE, move_factor.y * EDSCALE)); + points.push_back(Vector2(-5 * EDSCALE, move_factor.y * EDSCALE)); + points.push_back(Vector2(0, (move_factor.y + 10) * EDSCALE)); - Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE); - bool uniform = Input::get_singleton()->is_key_pressed(Key::SHIFT); - Point2 offset = (simple_xform.affine_inverse().xform(drag_to) - simple_xform.affine_inverse().xform(drag_from)) * zoom; + viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor))); + viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)), Math::round(EDSCALE)); - if (drag_type == DRAG_SCALE_X) { - scale_factor.x += offset.x; - if (uniform) { - scale_factor.y += offset.x; - } - } else if (drag_type == DRAG_SCALE_Y) { - scale_factor.y += offset.y; - if (uniform) { - scale_factor.x += offset.y; - } - } + viewport->draw_set_transform_matrix(viewport->get_transform()); + } - viewport->draw_set_transform_matrix(simple_xform); - Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); - viewport->draw_rect(x_handle_rect, get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor))); - viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)), Math::round(EDSCALE)); + // Draw the rescale handles. + if ((tool == TOOL_SELECT && is_alt && is_ctrl) || tool == TOOL_SCALE || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y) { + Transform2D edit_transform; + if (!Math::is_inf(temp_pivot.x) || !Math::is_inf(temp_pivot.y)) { + edit_transform = Transform2D(ci->_edit_get_rotation(), temp_pivot); + } else { + edit_transform = ci->_edit_get_transform(); + } + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * edit_transform).orthonormalized(); + Transform2D simple_xform = viewport->get_transform() * unscaled_transform; - Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); - viewport->draw_rect(y_handle_rect, get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor))); - viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)), Math::round(EDSCALE)); + Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE); + bool uniform = Input::get_singleton()->is_key_pressed(Key::SHIFT); + Point2 offset = (simple_xform.affine_inverse().xform(drag_to) - simple_xform.affine_inverse().xform(drag_from)) * zoom; - viewport->draw_set_transform_matrix(viewport->get_transform()); + if (drag_type == DRAG_SCALE_X) { + scale_factor.x += offset.x; + if (uniform) { + scale_factor.y += offset.x; + } + } else if (drag_type == DRAG_SCALE_Y) { + scale_factor.y += offset.y; + if (uniform) { + scale_factor.x += offset.y; } } + + viewport->draw_set_transform_matrix(simple_xform); + Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + viewport->draw_rect(x_handle_rect, get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor))); + viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)), Math::round(EDSCALE)); + + Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + viewport->draw_rect(y_handle_rect, get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor))); + viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)), Math::round(EDSCALE)); + + viewport->draw_set_transform_matrix(viewport->get_transform()); } } @@ -5356,7 +5404,7 @@ CanvasItemEditor::CanvasItemEditor() { main_menu_hbox->add_child(pivot_button); pivot_button->set_toggle_mode(true); pivot_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_EDIT_PIVOT)); - pivot_button->set_tooltip_text(TTR("Click to change object's rotation pivot.") + "\n" + TTR("Shift: Set temporary rotation pivot.") + "\n" + TTR("Click this button while holding Shift to put the temporary rotation pivot in the center of the selected nodes.")); + pivot_button->set_tooltip_text(TTR("Click to change object's pivot.") + "\n" + TTR("Shift: Set temporary pivot.") + "\n" + TTR("Click this button while holding Shift to put the temporary pivot in the center of the selected nodes.")); pan_button = memnew(Button); pan_button->set_theme_type_variation("FlatButton"); diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index 3a4b3a0ea2..de4ab828bc 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -277,8 +277,15 @@ void Path3DGizmo::redraw() { Ref<StandardMaterial3D> path_tilt_material = gizmo_plugin->get_material("path_tilt_material", this); Ref<StandardMaterial3D> path_tilt_muted_material = gizmo_plugin->get_material("path_tilt_muted_material", this); Ref<StandardMaterial3D> handles_material = gizmo_plugin->get_material("handles"); + Ref<StandardMaterial3D> first_pt_handle_material = gizmo_plugin->get_material("first_pt_handle"); + Ref<StandardMaterial3D> last_pt_handle_material = gizmo_plugin->get_material("last_pt_handle"); + Ref<StandardMaterial3D> closed_pt_handle_material = gizmo_plugin->get_material("closed_pt_handle"); Ref<StandardMaterial3D> sec_handles_material = gizmo_plugin->get_material("sec_handles"); + first_pt_handle_material->set_albedo(Color(0.2, 1.0, 0.0)); + last_pt_handle_material->set_albedo(Color(1.0, 0.2, 0.0)); + closed_pt_handle_material->set_albedo(Color(1.0, 0.8, 0.0)); + Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return; @@ -369,7 +376,7 @@ void Path3DGizmo::redraw() { info.point_idx = idx; // Collect in-handles except for the first point. - if (idx > 0 && Path3DEditorPlugin::singleton->curve_edit_curve->is_pressed()) { + if (idx > (c->is_closed() ? -1 : 0) && Path3DEditorPlugin::singleton->curve_edit_curve->is_pressed()) { const Vector3 in = c->get_point_in(idx); info.type = HandleType::HANDLE_TYPE_IN; @@ -383,7 +390,7 @@ void Path3DGizmo::redraw() { } // Collect out-handles except for the last point. - if (idx < c->get_point_count() - 1 && Path3DEditorPlugin::singleton->curve_edit_curve->is_pressed()) { + if (idx < (c->is_closed() ? c->get_point_count() : c->get_point_count() - 1) && Path3DEditorPlugin::singleton->curve_edit_curve->is_pressed()) { const Vector3 out = c->get_point_out(idx); info.type = HandleType::HANDLE_TYPE_OUT; @@ -441,7 +448,42 @@ void Path3DGizmo::redraw() { } if (!Path3DEditorPlugin::singleton->curve_edit->is_pressed() && primary_handle_points.size()) { - add_handles(primary_handle_points, handles_material); + // Need to define indices separately. + // Point count. + const int pc = primary_handle_points.size(); + Vector<int> idx; + idx.resize(pc); + int *idx_ptr = idx.ptrw(); + for (int j = 0; j < pc; j++) { + idx_ptr[j] = j; + } + + // Initialize arrays for first point. + PackedVector3Array first_pt_handle_point; + Vector<int> first_pt_id; + first_pt_handle_point.append(primary_handle_points[0]); + first_pt_id.append(idx[0]); + + // Initialize arrays and add handle for last point if needed. + if (pc > 1) { + PackedVector3Array last_pt_handle_point; + Vector<int> last_pt_id; + last_pt_handle_point.append(primary_handle_points[pc - 1]); + last_pt_id.append(idx[pc - 1]); + primary_handle_points.remove_at(pc - 1); + idx.remove_at(pc - 1); + add_handles(last_pt_handle_point, c->is_closed() ? handles_material : last_pt_handle_material, last_pt_id); + } + + // Add handle for first point. + primary_handle_points.remove_at(0); + idx.remove_at(0); + add_handles(first_pt_handle_point, c->is_closed() ? closed_pt_handle_material : first_pt_handle_material, first_pt_id); + + // Add handles for remaining intermediate points. + if (!primary_handle_points.is_empty()) { + add_handles(primary_handle_points, handles_material, idx); + } } if (secondary_handle_points.size()) { add_handles(secondary_handle_points, sec_handles_material, collected_secondary_handle_ids, false, true); @@ -469,7 +511,7 @@ Path3DGizmo::Path3DGizmo(Path3D *p_path, float p_disk_size) { Path3DEditorPlugin::singleton->curve_edit_curve->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw)); Path3DEditorPlugin::singleton->curve_create->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw)); Path3DEditorPlugin::singleton->curve_del->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw)); - Path3DEditorPlugin::singleton->curve_close->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw)); + Path3DEditorPlugin::singleton->curve_closed->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw)); } EditorPlugin::AfterGUIInput Path3DEditorPlugin::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) { @@ -696,7 +738,7 @@ void Path3DEditorPlugin::_mode_changed(int p_mode) { Node3DEditor::get_singleton()->clear_subgizmo_selection(); } -void Path3DEditorPlugin::_close_curve() { +void Path3DEditorPlugin::_toggle_closed_curve() { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return; @@ -704,13 +746,10 @@ void Path3DEditorPlugin::_close_curve() { if (c->get_point_count() < 2) { return; } - if (c->get_point_position(0) == c->get_point_position(c->get_point_count() - 1)) { - return; - } EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton(); - ur->create_action(TTR("Close Curve")); - ur->add_do_method(c.ptr(), "add_point", c->get_point_position(0), c->get_point_in(0), c->get_point_out(0), -1); - ur->add_undo_method(c.ptr(), "remove_point", c->get_point_count()); + ur->create_action(TTR("Toggle Open/Closed Curve")); + ur->add_do_method(c.ptr(), "set_closed", !c.ptr()->is_closed()); + ur->add_undo_method(c.ptr(), "set_closed", c.ptr()->is_closed()); ur->commit_action(); } @@ -771,6 +810,7 @@ void Path3DEditorPlugin::_clear_curve_points() { return; } Ref<Curve3D> curve = path->get_curve(); + curve->set_closed(false); curve->clear_points(); } @@ -795,7 +835,7 @@ void Path3DEditorPlugin::_update_theme() { curve_edit_tilt->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("CurveTilt"))); curve_create->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("CurveCreate"))); curve_del->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("CurveDelete"))); - curve_close->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("CurveClose"))); + curve_closed->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("CurveClose"))); curve_clear_points->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("Clear"))); create_curve_button->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("Curve3D"))); } @@ -872,12 +912,12 @@ Path3DEditorPlugin::Path3DEditorPlugin() { toolbar->add_child(curve_del); curve_del->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_DELETE)); - curve_close = memnew(Button); - curve_close->set_theme_type_variation("FlatButton"); - curve_close->set_focus_mode(Control::FOCUS_NONE); - curve_close->set_tooltip_text(TTR("Close Curve")); - toolbar->add_child(curve_close); - curve_close->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_close_curve)); + curve_closed = memnew(Button); + curve_closed->set_theme_type_variation("FlatButton"); + curve_closed->set_focus_mode(Control::FOCUS_NONE); + curve_closed->set_tooltip_text(TTR("Close Curve")); + toolbar->add_child(curve_closed); + curve_closed->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_toggle_closed_curve)); curve_clear_points = memnew(Button); curve_clear_points->set_theme_type_variation("FlatButton"); @@ -943,6 +983,14 @@ void Path3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref<Curve3D> curve = path->get_curve(); Ref<StandardMaterial3D> handle_material = get_material("handles", p_gizmo); + Ref<StandardMaterial3D> first_pt_handle_material = get_material("first_pt_handle", p_gizmo); + Ref<StandardMaterial3D> last_pt_handle_material = get_material("last_pt_handle", p_gizmo); + Ref<StandardMaterial3D> closed_pt_handle_material = get_material("closed_pt_handle", p_gizmo); + + first_pt_handle_material->set_albedo(Color(0.2, 1.0, 0.0)); + last_pt_handle_material->set_albedo(Color(1.0, 0.2, 0.0)); + closed_pt_handle_material->set_albedo(Color(1.0, 0.8, 0.0)); + PackedVector3Array handles; if (Path3DEditorPlugin::singleton->curve_edit->is_pressed()) { @@ -955,7 +1003,37 @@ void Path3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } if (handles.size()) { - p_gizmo->add_vertices(handles, handle_material, Mesh::PRIMITIVE_POINTS); + // Point count. + const int pc = handles.size(); + + // Initialize arrays for first point. + PackedVector3Array first_pt; + first_pt.append(handles[0]); + + // Initialize arrays and add handle for last point if needed. + if (pc > 1) { + PackedVector3Array last_pt; + last_pt.append(handles[handles.size() - 1]); + handles.remove_at(handles.size() - 1); + if (curve->is_closed()) { + p_gizmo->add_vertices(last_pt, handle_material, Mesh::PRIMITIVE_POINTS); + } else { + p_gizmo->add_vertices(last_pt, last_pt_handle_material, Mesh::PRIMITIVE_POINTS); + } + } + + // Add handle for first point. + handles.remove_at(0); + if (curve->is_closed()) { + p_gizmo->add_vertices(first_pt, closed_pt_handle_material, Mesh::PRIMITIVE_POINTS); + } else { + p_gizmo->add_vertices(first_pt, first_pt_handle_material, Mesh::PRIMITIVE_POINTS); + } + + // Add handles for remaining intermediate points. + if (!handles.is_empty()) { + p_gizmo->add_vertices(handles, handle_material, Mesh::PRIMITIVE_POINTS); + } } } @@ -1072,5 +1150,8 @@ Path3DGizmoPlugin::Path3DGizmoPlugin(float p_disk_size) { create_material("path_tilt_material", path_tilt_color); create_material("path_tilt_muted_material", path_tilt_color * 0.7); create_handle_material("handles", false, EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("EditorPathSmoothHandle"), EditorStringName(EditorIcons))); + create_handle_material("first_pt_handle", false, EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("EditorPathSmoothHandle"), EditorStringName(EditorIcons))); + create_handle_material("last_pt_handle", false, EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("EditorPathSmoothHandle"), EditorStringName(EditorIcons))); + create_handle_material("closed_pt_handle", false, EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("EditorPathSmoothHandle"), EditorStringName(EditorIcons))); create_handle_material("sec_handles", false, EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("EditorCurveHandle"), EditorStringName(EditorIcons))); } diff --git a/editor/plugins/path_3d_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h index 60cb7f940f..3e45c2718f 100644 --- a/editor/plugins/path_3d_editor_plugin.h +++ b/editor/plugins/path_3d_editor_plugin.h @@ -120,7 +120,7 @@ class Path3DEditorPlugin : public EditorPlugin { Button *curve_edit_curve = nullptr; Button *curve_edit_tilt = nullptr; Button *curve_del = nullptr; - Button *curve_close = nullptr; + Button *curve_closed = nullptr; Button *curve_clear_points = nullptr; MenuButton *handle_menu = nullptr; @@ -144,7 +144,7 @@ class Path3DEditorPlugin : public EditorPlugin { void _update_toolbar(); void _mode_changed(int p_mode); - void _close_curve(); + void _toggle_closed_curve(); void _handle_option_pressed(int p_option); bool handle_clicked = false; bool mirror_handle_angle = true; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 8c3979918d..49ecbac751 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -4391,28 +4391,28 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { disk_changed = memnew(ConfirmationDialog); { - disk_changed->set_title(TTR("Files have been modified on disk")); + disk_changed->set_title(TTR("Files have been modified outside Godot")); VBoxContainer *vbc = memnew(VBoxContainer); disk_changed->add_child(vbc); Label *files_are_newer_label = memnew(Label); - files_are_newer_label->set_text(TTR("The following files are newer on disk.")); + files_are_newer_label->set_text(TTR("The following files are newer on disk:")); vbc->add_child(files_are_newer_label); - Label *what_action_label = memnew(Label); - what_action_label->set_text(TTR("What action should be taken?:")); - vbc->add_child(what_action_label); - disk_changed_list = memnew(Tree); vbc->add_child(disk_changed_list); disk_changed_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); disk_changed_list->set_v_size_flags(SIZE_EXPAND_FILL); + Label *what_action_label = memnew(Label); + what_action_label->set_text(TTR("What action should be taken?")); + vbc->add_child(what_action_label); + disk_changed->connect(SceneStringName(confirmed), callable_mp(this, &ScriptEditor::reload_scripts).bind(false)); - disk_changed->set_ok_button_text(TTR("Discard local changes and reload")); + disk_changed->set_ok_button_text(TTR("Reload from disk")); - disk_changed->add_button(TTR("Keep local changes and overwrite"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave"); + disk_changed->add_button(TTR("Ignore external changes"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave"); disk_changed->connect("custom_action", callable_mp(this, &ScriptEditor::_resave_scripts)); } diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index b45b30b52e..cf586c792e 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -282,7 +282,7 @@ void ScriptTextEditor::_warning_clicked(const Variant &p_line) { CodeEdit *text_editor = code_editor->get_text_editor(); String prev_line = line > 0 ? text_editor->get_line(line - 1) : ""; if (prev_line.contains("@warning_ignore")) { - const int closing_bracket_idx = prev_line.find(")"); + const int closing_bracket_idx = prev_line.find_char(')'); const String text_to_insert = ", " + code.quote(quote_style); text_editor->insert_text(text_to_insert, line - 1, closing_bracket_idx); } else { @@ -951,7 +951,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c } else if (p_symbol.is_resource_file() || p_symbol.begins_with("uid://")) { String symbol = p_symbol; if (symbol.begins_with("uid://")) { - symbol = ResourceUID::get_singleton()->get_id_path(ResourceUID::get_singleton()->text_to_id(symbol)); + symbol = ResourceUID::uid_to_path(symbol); } List<String> scene_extensions; @@ -1205,7 +1205,7 @@ void ScriptTextEditor::_update_connected_methods() { // Account for inner classes by stripping the class names from the method, // starting from the right since our inner class might be inside of another inner class. - int pos = raw_name.rfind("."); + int pos = raw_name.rfind_char('.'); if (pos != -1) { name = raw_name.substr(pos + 1); } diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 9c1befa144..8249596045 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1985,6 +1985,67 @@ bool VisualShaderEditor::_update_preview_parameter_tree() { return found; } +void VisualShaderEditor::_preview_tools_menu_option(int p_idx) { + ShaderMaterial *src_mat = nullptr; + + if (p_idx == COPY_PARAMS_FROM_MATERIAL || p_idx == PASTE_PARAMS_TO_MATERIAL) { + for (int i = EditorNode::get_singleton()->get_editor_selection_history()->get_path_size() - 1; i >= 0; i--) { + Object *object = ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_selection_history()->get_path_object(i)); + ShaderMaterial *src_mat2; + if (!object) { + continue; + } + if (object->has_method("get_material_override")) { // Trying to get material from MeshInstance. + src_mat2 = Object::cast_to<ShaderMaterial>(object->call("get_material_override")); + } else if (object->has_method("get_material")) { // From CanvasItem/Node2D. + src_mat2 = Object::cast_to<ShaderMaterial>(object->call("get_material")); + } else { + src_mat2 = Object::cast_to<ShaderMaterial>(object); + } + + if (src_mat2 && src_mat2->get_shader().is_valid() && src_mat2->get_shader() == visual_shader) { + src_mat = src_mat2; + break; + } + } + } + + switch (p_idx) { + case COPY_PARAMS_FROM_MATERIAL: + if (src_mat) { + EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); + undo_redo->create_action(TTR("Copy Preview Shader Parameters From Material")); + + List<PropertyInfo> params; + preview_material->get_shader()->get_shader_uniform_list(¶ms); + for (const PropertyInfo &E : params) { + undo_redo->add_do_method(visual_shader.ptr(), "_set_preview_shader_parameter", E.name, src_mat->get_shader_parameter(E.name)); + undo_redo->add_undo_method(visual_shader.ptr(), "_set_preview_shader_parameter", E.name, preview_material->get_shader_parameter(E.name)); + } + + undo_redo->commit_action(); + } + break; + case PASTE_PARAMS_TO_MATERIAL: + if (src_mat) { + EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); + undo_redo->create_action(TTR("Paste Preview Shader Parameters To Material")); + + List<PropertyInfo> params; + preview_material->get_shader()->get_shader_uniform_list(¶ms); + for (const PropertyInfo &E : params) { + undo_redo->add_do_method(src_mat, "set_shader_parameter", E.name, preview_material->get_shader_parameter(E.name)); + undo_redo->add_undo_method(src_mat, "set_shader_parameter", E.name, src_mat->get_shader_parameter(E.name)); + } + + undo_redo->commit_action(); + } + break; + default: + break; + } +} + void VisualShaderEditor::_clear_preview_param() { selected_param_id = ""; current_prop = nullptr; @@ -4064,6 +4125,7 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in int from = p_from.to_int(); int to = p_to.to_int(); + bool swap = last_to_node != -1 && Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL); if (!visual_shader->can_connect_nodes(type, from, p_from_index, to, p_to_index)) { return; @@ -4081,6 +4143,14 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + + if (swap) { + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, last_to_node, last_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, last_to_node, last_to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, last_to_node, last_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, last_to_node, last_to_port); + } + break; } } @@ -4094,6 +4164,9 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in undo_redo->add_do_method(graph_plugin.ptr(), "update_node", (int)type, to); undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", (int)type, to); undo_redo->commit_action(); + + last_to_node = -1; + last_to_port = -1; } void VisualShaderEditor::_disconnection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) { @@ -4104,6 +4177,11 @@ void VisualShaderEditor::_disconnection_request(const String &p_from, int p_from int from = p_from.to_int(); int to = p_to.to_int(); + last_to_node = to; + last_to_port = p_to_index; + + info_label->show(); + EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); undo_redo->create_action(TTR("Nodes Disconnected")); undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from, p_from_index, to, p_to_index); @@ -4115,6 +4193,10 @@ void VisualShaderEditor::_disconnection_request(const String &p_from, int p_from undo_redo->commit_action(); } +void VisualShaderEditor::_connection_drag_ended() { + info_label->hide(); +} + void VisualShaderEditor::_connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position) { from_node = p_from.to_int(); from_slot = p_from_slot; @@ -5019,8 +5101,11 @@ void VisualShaderEditor::_param_property_changed(const String &p_property, const void VisualShaderEditor::_update_current_param() { if (current_prop != nullptr) { String name = current_prop->get_meta("id"); - preview_material->set("shader_parameter/" + name, visual_shader->_get_preview_shader_parameter(name)); - + if (visual_shader->_has_preview_shader_parameter(name)) { + preview_material->set("shader_parameter/" + name, visual_shader->_get_preview_shader_parameter(name)); + } else { + preview_material->set("shader_parameter/" + name, Variant()); + } current_prop->update_property(); current_prop->update_editor_property_status(); current_prop->update_cache(); @@ -5159,6 +5244,7 @@ void VisualShaderEditor::_notification(int p_what) { } tools->set_button_icon(get_editor_theme_icon(SNAME("Tools"))); + preview_tools->set_button_icon(get_editor_theme_icon(SNAME("Tools"))); if (is_visible_in_tree()) { _update_graph(); @@ -6305,6 +6391,7 @@ VisualShaderEditor::VisualShaderEditor() { graph->connect(SceneStringName(gui_input), callable_mp(this, &VisualShaderEditor::_graph_gui_input)); graph->connect("connection_to_empty", callable_mp(this, &VisualShaderEditor::_connection_to_empty)); graph->connect("connection_from_empty", callable_mp(this, &VisualShaderEditor::_connection_from_empty)); + graph->connect("connection_drag_ended", callable_mp(this, &VisualShaderEditor::_connection_drag_ended)); graph->connect(SceneStringName(visibility_changed), callable_mp(this, &VisualShaderEditor::_visibility_changed)); graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR); graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR_INT); @@ -6365,6 +6452,13 @@ VisualShaderEditor::VisualShaderEditor() { graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShaderNode::PORT_TYPE_TRANSFORM); graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SAMPLER, VisualShaderNode::PORT_TYPE_SAMPLER); + info_label = memnew(Label); + info_label->set_text(vformat(TTR("Hold %s Key To Swap Connections"), keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL))); + info_label->set_anchors_and_offsets_preset(Control::PRESET_BOTTOM_WIDE, PRESET_MODE_MINSIZE, 20); + info_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); + info_label->hide(); + graph->get_top_layer()->add_child(info_label); + PanelContainer *toolbar_panel = static_cast<PanelContainer *>(graph->get_menu_hbox()->get_parent()); toolbar_panel->set_anchors_and_offsets_preset(Control::PRESET_TOP_WIDE, PRESET_MODE_MINSIZE, 10); toolbar_panel->set_mouse_filter(Control::MOUSE_FILTER_IGNORE); @@ -6555,11 +6649,21 @@ VisualShaderEditor::VisualShaderEditor() { VBoxContainer *params_vbox = memnew(VBoxContainer); preview_split->add_child(params_vbox); + HBoxContainer *filter_hbox = memnew(HBoxContainer); + params_vbox->add_child(filter_hbox); + param_filter = memnew(LineEdit); + filter_hbox->add_child(param_filter); param_filter->connect(SceneStringName(text_changed), callable_mp(this, &VisualShaderEditor::_param_filter_changed)); param_filter->set_h_size_flags(SIZE_EXPAND_FILL); param_filter->set_placeholder(TTR("Filter Parameters")); - params_vbox->add_child(param_filter); + + preview_tools = memnew(MenuButton); + filter_hbox->add_child(preview_tools); + preview_tools->set_tooltip_text(TTR("Options")); + preview_tools->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &VisualShaderEditor::_preview_tools_menu_option)); + preview_tools->get_popup()->add_item(TTR("Copy Parameters From Material"), COPY_PARAMS_FROM_MATERIAL); + preview_tools->get_popup()->add_item(TTR("Paste Parameters To Material"), PASTE_PARAMS_TO_MATERIAL); ScrollContainer *sc = memnew(ScrollContainer); sc->set_v_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index d3dc2e7564..6b7c07e5a7 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -221,6 +221,10 @@ class VisualShaderEditor : public ShaderEditor { Button *code_preview_button = nullptr; Button *shader_preview_button = nullptr; + int last_to_node = -1; + int last_to_port = -1; + Label *info_label = nullptr; + OptionButton *edit_type = nullptr; OptionButton *edit_type_standard = nullptr; OptionButton *edit_type_particles = nullptr; @@ -276,6 +280,7 @@ class VisualShaderEditor : public ShaderEditor { bool shader_preview_showed = true; LineEdit *param_filter = nullptr; + MenuButton *preview_tools = nullptr; String selected_param_id; Tree *parameters = nullptr; HashMap<String, PropertyInfo> parameter_props; @@ -318,6 +323,11 @@ class VisualShaderEditor : public ShaderEditor { COLLAPSE_ALL }; + enum PreviewToolsMenuOptions { + COPY_PARAMS_FROM_MATERIAL, + PASTE_PARAMS_TO_MATERIAL, + }; + #ifdef MINGW_ENABLED #undef DELETE #endif @@ -367,6 +377,7 @@ class VisualShaderEditor : public ShaderEditor { void _show_add_varying_dialog(); void _show_remove_varying_dialog(); + void _preview_tools_menu_option(int p_idx); void _clear_preview_param(); void _update_preview_parameter_list(); bool _update_preview_parameter_tree(); @@ -495,6 +506,7 @@ class VisualShaderEditor : public ShaderEditor { void _unlink_node_from_parent_frame(int p_node_id); + void _connection_drag_ended(); void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position); void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position); bool _check_node_drop_on_connection(const Vector2 &p_position, Ref<GraphEdit::Connection> *r_closest_connection, int *r_node_id = nullptr, int *r_to_port = nullptr); diff --git a/editor/pot_generator.cpp b/editor/pot_generator.cpp index 76b6593f1d..3598a29fec 100644 --- a/editor/pot_generator.cpp +++ b/editor/pot_generator.cpp @@ -69,11 +69,16 @@ void POTGenerator::generate_pot(const String &p_file) { for (int i = 0; i < files.size(); i++) { Vector<String> msgids; Vector<Vector<String>> msgids_context_plural; + + Vector<String> msgids_comment; + Vector<String> msgids_context_plural_comment; + const String &file_path = files[i]; String file_extension = file_path.get_extension(); if (EditorTranslationParser::get_singleton()->can_parse(file_extension)) { EditorTranslationParser::get_singleton()->get_parser(file_extension)->parse_file(file_path, &msgids, &msgids_context_plural); + EditorTranslationParser::get_singleton()->get_parser(file_extension)->get_comments(&msgids_comment, &msgids_context_plural_comment); } else { ERR_PRINT("Unrecognized file extension " + file_extension + " in generate_pot()"); return; @@ -81,16 +86,18 @@ void POTGenerator::generate_pot(const String &p_file) { for (int j = 0; j < msgids_context_plural.size(); j++) { const Vector<String> &entry = msgids_context_plural[j]; - _add_new_msgid(entry[0], entry[1], entry[2], file_path); + const String &comment = (j < msgids_context_plural_comment.size()) ? msgids_context_plural_comment[j] : String(); + _add_new_msgid(entry[0], entry[1], entry[2], file_path, comment); } for (int j = 0; j < msgids.size(); j++) { - _add_new_msgid(msgids[j], "", "", file_path); + const String &comment = (j < msgids_comment.size()) ? msgids_comment[j] : String(); + _add_new_msgid(msgids[j], "", "", file_path, comment); } } if (GLOBAL_GET("internationalization/locale/translation_add_builtin_strings_to_pot")) { for (const Vector<String> &extractable_msgids : get_extractable_message_list()) { - _add_new_msgid(extractable_msgids[0], extractable_msgids[1], extractable_msgids[2], ""); + _add_new_msgid(extractable_msgids[0], extractable_msgids[1], extractable_msgids[2], "", ""); } } @@ -136,15 +143,25 @@ void POTGenerator::_write_to_pot(const String &p_file) { String context = v_msgid_data[i].ctx; String plural = v_msgid_data[i].plural; const HashSet<String> &locations = v_msgid_data[i].locations; + const HashSet<String> &comments = v_msgid_data[i].comments; // Put the blank line at the start, to avoid a double at the end when closing the file. file->store_line(""); + // Write comments. + bool is_first_comment = true; + for (const String &E : comments) { + if (is_first_comment) { + file->store_line("#. TRANSLATORS: " + E.replace("\n", "\n#. ")); + } else { + file->store_line("#. " + E.replace("\n", "\n#. ")); + } + is_first_comment = false; + } + // Write file locations. for (const String &E : locations) { - if (!E.is_empty()) { - file->store_line("#: " + E.trim_prefix("res://").replace("\n", "\\n")); - } + file->store_line("#: " + E.trim_prefix("res://").replace("\n", "\\n")); } // Write context. @@ -199,7 +216,7 @@ void POTGenerator::_write_msgid(Ref<FileAccess> r_file, const String &p_id, bool } } -void POTGenerator::_add_new_msgid(const String &p_msgid, const String &p_context, const String &p_plural, const String &p_location) { +void POTGenerator::_add_new_msgid(const String &p_msgid, const String &p_context, const String &p_plural, const String &p_location, const String &p_comment) { // Insert new location if msgid under same context exists already. if (all_translation_strings.has(p_msgid)) { Vector<MsgidData> &v_mdata = all_translation_strings[p_msgid]; @@ -208,18 +225,27 @@ void POTGenerator::_add_new_msgid(const String &p_msgid, const String &p_context if (!v_mdata[i].plural.is_empty() && !p_plural.is_empty() && v_mdata[i].plural != p_plural) { WARN_PRINT("Redefinition of plural message (msgid_plural), under the same message (msgid) and context (msgctxt)"); } - v_mdata.write[i].locations.insert(p_location); + if (!p_location.is_empty()) { + v_mdata.write[i].locations.insert(p_location); + } + if (!p_comment.is_empty()) { + v_mdata.write[i].comments.insert(p_comment); + } return; } } } - // Add a new entry of msgid, context, plural and location - context and plural might be empty if the inserted msgid doesn't associated - // context or plurals. + // Add a new entry. MsgidData mdata; mdata.ctx = p_context; mdata.plural = p_plural; - mdata.locations.insert(p_location); + if (!p_location.is_empty()) { + mdata.locations.insert(p_location); + } + if (!p_comment.is_empty()) { + mdata.comments.insert(p_comment); + } all_translation_strings[p_msgid].push_back(mdata); } diff --git a/editor/pot_generator.h b/editor/pot_generator.h index 8bcb2e5cac..54f4aa0652 100644 --- a/editor/pot_generator.h +++ b/editor/pot_generator.h @@ -44,13 +44,14 @@ class POTGenerator { String ctx; String plural; HashSet<String> locations; + HashSet<String> comments; }; // Store msgid as key and the additional data around the msgid - if it's under a context, has plurals and its file locations. HashMap<String, Vector<MsgidData>> all_translation_strings; void _write_to_pot(const String &p_file); void _write_msgid(Ref<FileAccess> r_file, const String &p_id, bool p_plural); - void _add_new_msgid(const String &p_msgid, const String &p_context, const String &p_plural, const String &p_location); + void _add_new_msgid(const String &p_msgid, const String &p_context, const String &p_plural, const String &p_location, const String &p_comment); #ifdef DEBUG_POT void _print_all_translation_strings(); diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index d08610c93f..edf3ff7296 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -1970,7 +1970,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai // -- func c(var a, var b) -> func c(a, b) if (line.contains("func ") && line.contains("var ")) { int start = line.find("func "); - start = line.substr(start).find("(") + start; + start = line.substr(start).find_char('(') + start; int end = get_end_parenthesis(line.substr(start)) + 1; if (end > -1) { Vector<String> parts = parse_arguments(line.substr(start, end)); @@ -2120,12 +2120,12 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // -- func _init(p_x:int).(p_x): -> func _init(p_x:int):\n\tsuper(p_x) Object # https://github.com/godotengine/godot/issues/70542 - if (line.contains(" _init(") && line.rfind(":") > 0) { + if (line.contains(" _init(") && line.rfind_char(':') > 0) { // func _init(p_arg1).(super4, super5, super6)->void: // ^--^indent ^super_start super_end^ int indent = line.count("\t", 0, line.find("func")); int super_start = line.find(".("); - int super_end = line.rfind(")"); + int super_end = line.rfind_char(')'); if (super_start > 0 && super_end > super_start) { line = line.substr(0, super_start) + line.substr(super_end + 1) + "\n" + String("\t").repeat(indent + 1) + "super" + line.substr(super_start + 1, super_end - super_start); } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 30cf2030bc..eb5e8d2a72 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -34,8 +34,6 @@ #include "core/io/config_file.h" #include "core/io/dir_access.h" #include "core/io/file_access.h" -#include "core/io/resource_saver.h" -#include "core/io/stream_peer_tls.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/version.h" @@ -51,12 +49,9 @@ #include "editor/project_manager/project_list.h" #include "editor/project_manager/project_tag.h" #include "editor/project_manager/quick_settings_dialog.h" -#include "editor/themes/editor_icons.h" #include "editor/themes/editor_scale.h" #include "editor/themes/editor_theme_manager.h" #include "main/main.h" -#include "scene/gui/check_box.h" -#include "scene/gui/color_rect.h" #include "scene/gui/flow_container.h" #include "scene/gui/line_edit.h" #include "scene/gui/margin_container.h" @@ -64,7 +59,6 @@ #include "scene/gui/panel_container.h" #include "scene/gui/rich_text_label.h" #include "scene/gui/separator.h" -#include "scene/gui/texture_rect.h" #include "scene/main/window.h" #include "scene/theme/theme_db.h" #include "servers/display_server.h" @@ -1300,15 +1294,10 @@ ProjectManager::ProjectManager() { filter_option->connect(SceneStringName(item_selected), callable_mp(this, &ProjectManager::_on_order_option_changed)); hb->add_child(filter_option); - Vector<String> sort_filter_titles; - sort_filter_titles.push_back(TTR("Last Edited")); - sort_filter_titles.push_back(TTR("Name")); - sort_filter_titles.push_back(TTR("Path")); - sort_filter_titles.push_back(TTR("Tags")); - - for (int i = 0; i < sort_filter_titles.size(); i++) { - filter_option->add_item(sort_filter_titles[i]); - } + filter_option->add_item(TTR("Last Edited")); + filter_option->add_item(TTR("Name")); + filter_option->add_item(TTR("Path")); + filter_option->add_item(TTR("Tags")); } // Project list and its sidebar. diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 89c18143dc..97f1d5d641 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -31,6 +31,7 @@ #include "project_settings_editor.h" #include "core/config/project_settings.h" +#include "core/input/input_map.h" #include "editor/editor_inspector.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" @@ -390,7 +391,7 @@ void ProjectSettingsEditor::_action_added(const String &p_name) { Dictionary action; action["events"] = Array(); - action["deadzone"] = 0.2f; + action["deadzone"] = InputMap::DEFAULT_DEADZONE; EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); undo_redo->create_action(TTR("Add Input Action")); diff --git a/editor/register_editor_types.cpp b/editor/register_editor_types.cpp index c4ebca7308..2d3cbfb1e3 100644 --- a/editor/register_editor_types.cpp +++ b/editor/register_editor_types.cpp @@ -52,6 +52,7 @@ #include "editor/filesystem_dock.h" #include "editor/gui/editor_file_dialog.h" #include "editor/gui/editor_spin_slider.h" +#include "editor/gui/editor_toaster.h" #include "editor/import/3d/resource_importer_obj.h" #include "editor/import/3d/resource_importer_scene.h" #include "editor/import/editor_import_plugin.h" @@ -146,6 +147,7 @@ void register_editor_types() { GDREGISTER_CLASS(EditorSelection); GDREGISTER_CLASS(EditorFileDialog); GDREGISTER_CLASS(EditorSettings); + GDREGISTER_ABSTRACT_CLASS(EditorToaster); GDREGISTER_CLASS(EditorNode3DGizmo); GDREGISTER_CLASS(EditorNode3DGizmoPlugin); GDREGISTER_ABSTRACT_CLASS(EditorResourcePreview); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 8dd2fe8e4e..8615836ddd 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -144,7 +144,7 @@ void ScriptCreateDialog::_notification(int p_what) { void ScriptCreateDialog::_path_hbox_sorted() { if (is_visible()) { - int filename_start_pos = file_path->get_text().rfind("/") + 1; + int filename_start_pos = file_path->get_text().rfind_char('/') + 1; int filename_end_pos = file_path->get_text().get_basename().length(); if (!is_built_in) { @@ -359,6 +359,7 @@ void ScriptCreateDialog::_create_new() { alert->popup_centered(); return; } + EditorNode::get_singleton()->ensure_uid_file(lpath); } emit_signal(SNAME("script_created"), scr); diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index 2bfe088e7f..33da3dd10c 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -31,6 +31,7 @@ #include "shader_create_dialog.h" #include "core/config/project_settings.h" +#include "editor/editor_node.h" #include "editor/gui/editor_file_dialog.h" #include "editor/gui/editor_validation_panel.h" #include "editor/themes/editor_scale.h" @@ -102,7 +103,7 @@ void ShaderCreateDialog::_update_language_info() { void ShaderCreateDialog::_path_hbox_sorted() { if (is_visible()) { - int filename_start_pos = initial_base_path.rfind("/") + 1; + int filename_start_pos = initial_base_path.rfind_char('/') + 1; int filename_end_pos = initial_base_path.length(); if (!is_built_in) { @@ -240,6 +241,7 @@ void fog() { alert->popup_centered(); return; } + EditorNode::get_singleton()->ensure_uid_file(lpath); emit_signal(SNAME("shader_include_created"), shader_inc); } else { @@ -258,6 +260,7 @@ void fog() { alert->popup_centered(); return; } + EditorNode::get_singleton()->ensure_uid_file(lpath); } emit_signal(SNAME("shader_created"), shader); diff --git a/main/main.cpp b/main/main.cpp index bdadd24d35..340167fe00 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1598,7 +1598,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } else if (arg.ends_with("project.godot")) { String path; String file = arg; - int sep = MAX(file.rfind("/"), file.rfind("\\")); + int sep = MAX(file.rfind_char('/'), file.rfind_char('\\')); if (sep == -1) { path = "."; } else { @@ -1801,13 +1801,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } else if (arg == "--" || arg == "++") { adding_user_args = true; } else { - if (!FileAccess::exists(arg) && !DirAccess::exists(arg)) { - // Warn if the argument isn't recognized by Godot *and* the file/folder - // specified by a positional argument doesn't exist. - // This allows projects to read file or folder paths as a positional argument - // without printing a warning, as this scenario can't make use of user command line arguments. - WARN_PRINT(vformat("Unknown command line argument \"%s\". User arguments should be passed after a -- or ++ separator, e.g. \"-- %s\".", arg, arg)); - } main_args.push_back(arg); } @@ -2554,7 +2547,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph Engine::get_singleton()->set_physics_ticks_per_second(GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "physics/common/physics_ticks_per_second", PROPERTY_HINT_RANGE, "1,1000,1"), 60)); Engine::get_singleton()->set_max_physics_steps_per_frame(GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "physics/common/max_physics_steps_per_frame", PROPERTY_HINT_RANGE, "1,100,1"), 8)); Engine::get_singleton()->set_physics_jitter_fix(GLOBAL_DEF("physics/common/physics_jitter_fix", 0.5)); - Engine::get_singleton()->set_max_fps(GLOBAL_DEF(PropertyInfo(Variant::INT, "application/run/max_fps", PROPERTY_HINT_RANGE, "0,1000,1"), 0)); GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "audio/driver/output_latency", PROPERTY_HINT_RANGE, "1,100,1"), 15); // Use a safer default output_latency for web to avoid audio cracking on low-end devices, especially mobile. @@ -2575,10 +2567,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->set_environment("MVK_CONFIG_LOG_LEVEL", OS::get_singleton()->_verbose_stdout ? "3" : "1"); // 1 = Errors only, 3 = Info #endif - if (max_fps >= 0) { - Engine::get_singleton()->set_max_fps(max_fps); - } - if (frame_delay == 0) { frame_delay = GLOBAL_DEF(PropertyInfo(Variant::INT, "application/run/frame_delay_msec", PROPERTY_HINT_RANGE, "0,100,1,or_greater"), 0); if (Engine::get_singleton()->is_editor_hint()) { @@ -3024,6 +3012,13 @@ Error Main::setup2(bool p_show_boot_logo) { OS::get_singleton()->benchmark_end_measure("Servers", "Display"); } + // Max FPS needs to be set after the DisplayServer is created. + Engine::get_singleton()->set_max_fps(GLOBAL_DEF(PropertyInfo(Variant::INT, "application/run/max_fps", PROPERTY_HINT_RANGE, "0,1000,1"), 0)); + + if (max_fps >= 0) { + Engine::get_singleton()->set_max_fps(max_fps); + } + #ifdef TOOLS_ENABLED // If the editor is running in windowed mode, ensure the window rect fits // the screen in case screen count or position has changed. @@ -4040,12 +4035,12 @@ int Main::start() { EditorNode *editor_node = nullptr; if (editor) { OS::get_singleton()->benchmark_begin_measure("Startup", "Editor"); - editor_node = memnew(EditorNode); if (editor_pseudolocalization) { translation_server->get_editor_domain()->set_pseudolocalization_enabled(true); } + editor_node = memnew(EditorNode); sml->get_root()->add_child(editor_node); if (!_export_preset.is_empty()) { @@ -4150,7 +4145,7 @@ int Main::start() { local_game_path = "res://" + local_game_path; } else { - int sep = local_game_path.rfind("/"); + int sep = local_game_path.rfind_char('/'); if (sep == -1) { Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); @@ -4237,14 +4232,15 @@ int Main::start() { if (project_manager) { OS::get_singleton()->benchmark_begin_measure("Startup", "Project Manager"); Engine::get_singleton()->set_editor_hint(true); - ProjectManager *pmanager = memnew(ProjectManager); - ProgressDialog *progress_dialog = memnew(ProgressDialog); - pmanager->add_child(progress_dialog); if (editor_pseudolocalization) { translation_server->get_editor_domain()->set_pseudolocalization_enabled(true); } + ProjectManager *pmanager = memnew(ProjectManager); + ProgressDialog *progress_dialog = memnew(ProgressDialog); + pmanager->add_child(progress_dialog); + sml->get_root()->add_child(pmanager); OS::get_singleton()->benchmark_end_measure("Startup", "Project Manager"); } diff --git a/methods.py b/methods.py index 64c3839718..1c33b00051 100644 --- a/methods.py +++ b/methods.py @@ -1,5 +1,7 @@ +import atexit import contextlib import glob +import math import os import re import subprocess @@ -8,7 +10,7 @@ from collections import OrderedDict from enum import Enum from io import StringIO, TextIOWrapper from pathlib import Path -from typing import Generator, List, Optional, Union +from typing import Generator, List, Optional, Union, cast # Get the "Godot" folder name ahead of time base_folder_path = str(os.path.abspath(Path(__file__).parent)) + "/" @@ -409,8 +411,7 @@ def use_windows_spawn_fix(self, platform=None): "shell": False, "env": env, } - if sys.version_info >= (3, 7, 0): - popen_args["text"] = True + popen_args["text"] = True proc = subprocess.Popen(cmdline, **popen_args) _, err = proc.communicate() rv = proc.wait() @@ -593,23 +594,6 @@ def glob_recursive(pattern, node="."): return results -def add_to_vs_project(env, sources): - for x in sources: - fname = env.File(x).path if isinstance(x, str) else env.File(x)[0].path - pieces = fname.split(".") - if len(pieces) > 0: - basename = pieces[0] - basename = basename.replace("\\\\", "/") - if os.path.isfile(basename + ".h"): - env.vs_incs += [basename + ".h"] - elif os.path.isfile(basename + ".hpp"): - env.vs_incs += [basename + ".hpp"] - if os.path.isfile(basename + ".c"): - env.vs_srcs += [basename + ".c"] - elif os.path.isfile(basename + ".cpp"): - env.vs_srcs += [basename + ".cpp"] - - def precious_program(env, program, sources, **args): program = env.ProgramOriginal(program, sources, **args) env.Precious(program) @@ -670,7 +654,9 @@ def detect_darwin_sdk_path(platform, env): raise -def is_vanilla_clang(env): +def is_apple_clang(env): + if env["platform"] not in ["macos", "ios"]: + return False if not using_clang(env): return False try: @@ -678,7 +664,7 @@ def is_vanilla_clang(env): except (subprocess.CalledProcessError, OSError): print_warning("Couldn't parse CXX environment variable to infer compiler version.") return False - return not version.startswith("Apple") + return version.startswith("Apple") def get_compiler_version(env): @@ -802,159 +788,160 @@ def using_emcc(env): def show_progress(env): - if env["ninja"]: - # Has its own progress/tracking tool that clashes with ours + # Progress reporting is not available in non-TTY environments since it messes with the output + # (for example, when writing to a file). Ninja has its own progress/tracking tool that clashes + # with ours. + if not env["progress"] or not sys.stdout.isatty() or env["ninja"]: return - import sys - - from SCons.Script import AlwaysBuild, Command, Progress - - screen = sys.stdout - # Progress reporting is not available in non-TTY environments since it - # messes with the output (for example, when writing to a file) - show_progress = env["progress"] and sys.stdout.isatty() - node_count = 0 - node_count_max = 0 - node_count_interval = 1 - node_count_fname = str(env.Dir("#")) + "/.scons_node_count" - - import math - - class cache_progress: - # The default is 1 GB cache - def __init__(self, path=None, limit=pow(1024, 3)): - self.path = path - self.limit = limit - if env["verbose"] and path is not None: - screen.write( - "Current cache limit is {} (used: {})\n".format( - self.convert_size(limit), self.convert_size(self.get_size(path)) - ) - ) + NODE_COUNT_FILENAME = f"{base_folder_path}.scons_node_count" + + class ShowProgress: + def __init__(self): + self.count = 0 + self.max = 0 + try: + with open(NODE_COUNT_FILENAME, "r", encoding="utf-8") as f: + self.max = int(f.readline()) + except OSError: + pass + if self.max == 0: + print("NOTE: Performing initial build, progress percentage unavailable!") def __call__(self, node, *args, **kw): - nonlocal node_count, node_count_max, node_count_interval, node_count_fname, show_progress - if show_progress: - # Print the progress percentage - node_count += node_count_interval - if node_count_max > 0 and node_count <= node_count_max: - screen.write("\r[%3d%%] " % (node_count * 100 / node_count_max)) - screen.flush() - elif node_count_max > 0 and node_count > node_count_max: - screen.write("\r[100%] ") - screen.flush() - else: - screen.write("\r[Initial build] ") - screen.flush() - - def convert_size(self, size_bytes): - if size_bytes == 0: - return "0 bytes" - size_name = ("bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB") - i = int(math.floor(math.log(size_bytes, 1024))) - p = math.pow(1024, i) - s = round(size_bytes / p, 2) - return "%s %s" % (int(s) if i == 0 else s, size_name[i]) - - def get_size(self, start_path="."): - total_size = 0 - for dirpath, dirnames, filenames in os.walk(start_path): - for f in filenames: - fp = os.path.join(dirpath, f) - total_size += os.path.getsize(fp) - return total_size + self.count += 1 + if self.max != 0: + percent = int(min(self.count * 100 / self.max, 100)) + sys.stdout.write(f"\r[{percent:3d}%] ") + sys.stdout.flush() + + from SCons.Script import Progress + + progressor = ShowProgress() + Progress(progressor) def progress_finish(target, source, env): - nonlocal node_count, progressor try: - with open(node_count_fname, "w", encoding="utf-8", newline="\n") as f: - f.write("%d\n" % node_count) - except Exception: + with open(NODE_COUNT_FILENAME, "w", encoding="utf-8", newline="\n") as f: + f.write(f"{progressor.count}\n") + except OSError: pass - try: - with open(node_count_fname, "r", encoding="utf-8") as f: - node_count_max = int(f.readline()) - except Exception: - pass + env.AlwaysBuild( + env.CommandNoCache( + "progress_finish", [], env.Action(progress_finish, "Building node count database .scons_node_count") + ) + ) + + +def convert_size(size_bytes: int) -> str: + if size_bytes == 0: + return "0 bytes" + SIZE_NAMES = ["bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] + index = math.floor(math.log(size_bytes, 1024)) + power = math.pow(1024, index) + size = round(size_bytes / power, 2) + return f"{size} {SIZE_NAMES[index]}" + + +def get_size(start_path: str = ".") -> int: + total_size = 0 + for dirpath, _, filenames in os.walk(start_path): + for file in filenames: + path = os.path.join(dirpath, file) + total_size += os.path.getsize(path) + return total_size - cache_directory = os.environ.get("SCONS_CACHE") - # Simple cache pruning, attached to SCons' progress callback. Trim the - # cache directory to a size not larger than cache_limit. - cache_limit = float(os.getenv("SCONS_CACHE_LIMIT", 1024)) * 1024 * 1024 - progressor = cache_progress(cache_directory, cache_limit) - Progress(progressor, interval=node_count_interval) - - progress_finish_command = Command("progress_finish", [], progress_finish) - AlwaysBuild(progress_finish_command) - - -def clean_cache(env): - import atexit - import time - - class cache_clean: - def __init__(self, path=None, limit=pow(1024, 3)): - self.path = path - self.limit = limit - - def clean(self): - self.delete(self.file_list()) - - def delete(self, files): - if len(files) == 0: - return - if env["verbose"]: - # Utter something - print("Purging %d %s from cache..." % (len(files), "files" if len(files) > 1 else "file")) - [os.remove(f) for f in files] - - def file_list(self): - if self.path is None: - # Nothing to do - return [] - # Gather a list of (filename, (size, atime)) within the - # cache directory - file_stat = [(x, os.stat(x)[6:8]) for x in glob.glob(os.path.join(self.path, "*", "*"))] - if file_stat == []: - # Nothing to do - return [] - # Weight the cache files by size (assumed to be roughly - # proportional to the recompilation time) times an exponential - # decay since the ctime, and return a list with the entries - # (filename, size, weight). - current_time = time.time() - file_stat = [(x[0], x[1][0], (current_time - x[1][1])) for x in file_stat] - # Sort by the most recently accessed files (most sensible to keep) first - file_stat.sort(key=lambda x: x[2]) - # Search for the first entry where the storage limit is - # reached - sum, mark = 0, None - for i, x in enumerate(file_stat): - sum += x[1] - if sum > self.limit: - mark = i - break - if mark is None: - return [] - else: - return [x[0] for x in file_stat[mark:]] - def cache_finally(): - nonlocal cleaner +def clean_cache(cache_path: str, cache_limit: int, verbose: bool): + files = glob.glob(os.path.join(cache_path, "*", "*")) + if not files: + return + + # Remove all text files, store binary files in list of (filename, size, atime). + purge = [] + texts = [] + stats = [] + for file in files: + # Failing a utf-8 decode is the easiest way to determine if a file is binary. try: - cleaner.clean() - except Exception: - pass + with open(file, encoding="utf-8") as out: + out.read(1024) + except UnicodeDecodeError: + stats.append((file, *os.stat(file)[6:8])) + except OSError: + print_error(f'Failed to access cache file "{file}"; skipping.') + else: + texts.append(file) + + if texts: + count = len(texts) + for file in texts: + try: + os.remove(file) + except OSError: + print_error(f'Failed to remove cache file "{file}"; skipping.') + count -= 1 + if verbose: + print("Purging %d text %s from cache..." % (count, "files" if count > 1 else "file")) + + if cache_limit: + # Sort by most recent access (most sensible to keep) first. Search for the first entry where + # the cache limit is reached. + stats.sort(key=lambda x: x[2], reverse=True) + sum = 0 + for index, stat in enumerate(stats): + sum += stat[1] + if sum > cache_limit: + purge.extend([x[0] for x in stats[index:]]) + break + + if purge: + count = len(purge) + for file in purge: + try: + os.remove(file) + except OSError: + print_error(f'Failed to remove cache file "{file}"; skipping.') + count -= 1 + if verbose: + print("Purging %d %s from cache..." % (count, "files" if count > 1 else "file")) + + +def prepare_cache(env) -> None: + if env.GetOption("clean"): + return + + cache_path = "" + if env["cache_path"]: + cache_path = cast(str, env["cache_path"]) + elif os.environ.get("SCONS_CACHE"): + print_warning("Environment variable `SCONS_CACHE` is deprecated; use `cache_path` argument instead.") + cache_path = cast(str, os.environ.get("SCONS_CACHE")) - cache_directory = os.environ.get("SCONS_CACHE") - # Simple cache pruning, attached to SCons' progress callback. Trim the - # cache directory to a size not larger than cache_limit. - cache_limit = float(os.getenv("SCONS_CACHE_LIMIT", 1024)) * 1024 * 1024 - cleaner = cache_clean(cache_directory, cache_limit) + if not cache_path: + return - atexit.register(cache_finally) + env.CacheDir(cache_path) + print(f'SCons cache enabled... (path: "{cache_path}")') + + if env["cache_limit"]: + cache_limit = float(env["cache_limit"]) + elif os.environ.get("SCONS_CACHE_LIMIT"): + print_warning("Environment variable `SCONS_CACHE_LIMIT` is deprecated; use `cache_limit` argument instead.") + cache_limit = float(os.getenv("SCONS_CACHE_LIMIT", "0")) / 1024 # Old method used MiB, convert to GiB + + # Convert GiB to bytes; treat negative numbers as 0 (unlimited). + cache_limit = max(0, int(cache_limit * 1024 * 1024 * 1024)) + if env["verbose"]: + print( + "Current cache limit is {} (used: {})".format( + convert_size(cache_limit) if cache_limit else "∞", + convert_size(get_size(cache_path)), + ) + ) + + atexit.register(clean_cache, cache_path, cache_limit, env["verbose"]) def dump(env): @@ -1112,9 +1099,7 @@ def generate_vs_project(env, original_args, project_name="godot"): import json md5 = hashlib.md5( - json.dumps(headers + headers_dirs + sources + sources_dirs + others + others_dirs, sort_keys=True).encode( - "utf-8" - ) + json.dumps(sorted(headers + headers_dirs + sources + sources_dirs + others + others_dirs)).encode("utf-8") ).hexdigest() if os.path.exists(f"{project_name}.vcxproj.filters"): diff --git a/misc/extension_api_validation/4.3-stable.expected b/misc/extension_api_validation/4.3-stable.expected index 3770664115..75e81b5ff4 100644 --- a/misc/extension_api_validation/4.3-stable.expected +++ b/misc/extension_api_validation/4.3-stable.expected @@ -108,3 +108,17 @@ GH-97257 Validate extension JSON: Error: Field 'classes/EditorFeatureProfile/enums/Feature/values/FEATURE_MAX': value changed value in new API, from 8.0 to 9. New entry to the `EditorFeatureProfile.Feature` enum added. Those need to go before `FEATURE_MAX`, which will always cause a compatibility break. + + +GH-91201 +-------- +Validate extension JSON: JSON file: Field was added in a way that breaks compatibility 'classes/OS/methods/read_string_from_stdin': arguments + +Added optional argument. Compatibility method registered. + + +GH-98918 +-------- +Validate extension JSON: Error: Field 'classes/FileAccess/methods/open_encrypted/arguments': size changed value in new API, from 3 to 4. + +Optional argument added to allow setting initialization vector. Compatibility method registered. diff --git a/modules/basis_universal/image_compress_basisu.cpp b/modules/basis_universal/image_compress_basisu.cpp index 8ca5dba225..be28d89508 100644 --- a/modules/basis_universal/image_compress_basisu.cpp +++ b/modules/basis_universal/image_compress_basisu.cpp @@ -38,13 +38,12 @@ #include <transcoder/basisu_transcoder.h> #ifdef TOOLS_ENABLED #include <encoder/basisu_comp.h> -#endif -void basis_universal_init() { -#ifdef TOOLS_ENABLED - basisu::basisu_encoder_init(); +static Mutex init_mutex; +static bool initialized = false; #endif +void basis_universal_init() { basist::basisu_transcoder_init(); } @@ -80,6 +79,13 @@ inline void _basisu_pad_mipmap(const uint8_t *p_image_mip_data, Vector<uint8_t> } Vector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Image::UsedChannels p_channels) { + init_mutex.lock(); + if (!initialized) { + basisu::basisu_encoder_init(); + initialized = true; + } + init_mutex.unlock(); + uint64_t start_time = OS::get_singleton()->get_ticks_msec(); Ref<Image> image = p_image->duplicate(); diff --git a/modules/gdscript/editor/gdscript_docgen.cpp b/modules/gdscript/editor/gdscript_docgen.cpp index 758887a723..3a5a88d356 100644 --- a/modules/gdscript/editor/gdscript_docgen.cpp +++ b/modules/gdscript/editor/gdscript_docgen.cpp @@ -140,7 +140,7 @@ void GDScriptDocGen::_doctype_from_gdtype(const GDType &p_gdtype, String &r_type r_enum = String(p_gdtype.native_type).replace("::", "."); if (r_enum.begins_with("res://")) { r_enum = r_enum.trim_prefix("res://"); - int dot_pos = r_enum.rfind("."); + int dot_pos = r_enum.rfind_char('.'); if (dot_pos >= 0) { r_enum = r_enum.left(dot_pos).quote() + r_enum.substr(dot_pos); } diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 0b12f2ff76..629581bd6c 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -163,7 +163,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l } if (from + end_key_length > line_length) { // If it's key length and there is a '\', dont skip to highlight esc chars. - if (str.find("\\", from) >= 0) { + if (str.find_char('\\', from) >= 0) { break; } } @@ -236,7 +236,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l for (; from < line_length; from++) { if (line_length - from < end_key_length) { // Don't break if '\' to highlight esc chars. - if (str.find("\\", from) < 0) { + if (str.find_char('\\', from) < 0) { break; } } diff --git a/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp b/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp index b31ae878ce..172ad6be9f 100644 --- a/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp +++ b/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp @@ -51,6 +51,10 @@ Error GDScriptEditorTranslationParserPlugin::parse_file(const String &p_path, Ve ids = r_ids; ids_ctx_plural = r_ids_ctx_plural; + + ids_comment.clear(); + ids_ctx_plural_comment.clear(); + Ref<GDScript> gdscript = loaded_res; String source_code = gdscript->get_source_code(); @@ -62,18 +66,90 @@ Error GDScriptEditorTranslationParserPlugin::parse_file(const String &p_path, Ve err = analyzer.analyze(); ERR_FAIL_COND_V_MSG(err, err, "Failed to analyze GDScript with GDScriptAnalyzer."); + comment_data = &parser.comment_data; + // Traverse through the parsed tree from GDScriptParser. GDScriptParser::ClassNode *c = parser.get_tree(); _traverse_class(c); + comment_data = nullptr; + return OK; } +void GDScriptEditorTranslationParserPlugin::get_comments(Vector<String> *r_ids_comment, Vector<String> *r_ids_ctx_plural_comment) { + r_ids_comment->append_array(ids_comment); + r_ids_ctx_plural_comment->append_array(ids_ctx_plural_comment); +} + bool GDScriptEditorTranslationParserPlugin::_is_constant_string(const GDScriptParser::ExpressionNode *p_expression) { ERR_FAIL_NULL_V(p_expression, false); return p_expression->is_constant && p_expression->reduced_value.is_string(); } +String GDScriptEditorTranslationParserPlugin::_parse_comment(int p_line, bool &r_skip) const { + // Parse inline comment. + if (comment_data->has(p_line)) { + const String stripped_comment = comment_data->get(p_line).comment.trim_prefix("#").strip_edges(); + + if (stripped_comment.begins_with("TRANSLATORS:")) { + return stripped_comment.trim_prefix("TRANSLATORS:").strip_edges(true, false); + } + if (stripped_comment == "NO_TRANSLATE" || stripped_comment.begins_with("NO_TRANSLATE:")) { + r_skip = true; + return String(); + } + } + + // Parse multiline comment. + String multiline_comment; + for (int line = p_line - 1; comment_data->has(line) && comment_data->get(line).new_line; line--) { + const String stripped_comment = comment_data->get(line).comment.trim_prefix("#").strip_edges(); + + if (stripped_comment.is_empty()) { + continue; + } + + if (multiline_comment.is_empty()) { + multiline_comment = stripped_comment; + } else { + multiline_comment = stripped_comment + "\n" + multiline_comment; + } + + if (stripped_comment.begins_with("TRANSLATORS:")) { + return multiline_comment.trim_prefix("TRANSLATORS:").strip_edges(true, false); + } + if (stripped_comment == "NO_TRANSLATE" || stripped_comment.begins_with("NO_TRANSLATE:")) { + r_skip = true; + return String(); + } + } + + return String(); +} + +void GDScriptEditorTranslationParserPlugin::_add_id(const String &p_id, int p_line) { + bool skip = false; + const String comment = _parse_comment(p_line, skip); + if (skip) { + return; + } + + ids->push_back(p_id); + ids_comment.push_back(comment); +} + +void GDScriptEditorTranslationParserPlugin::_add_id_ctx_plural(const Vector<String> &p_id_ctx_plural, int p_line) { + bool skip = false; + const String comment = _parse_comment(p_line, skip); + if (skip) { + return; + } + + ids_ctx_plural->push_back(p_id_ctx_plural); + ids_ctx_plural_comment.push_back(comment); +} + void GDScriptEditorTranslationParserPlugin::_traverse_class(const GDScriptParser::ClassNode *p_class) { for (int i = 0; i < p_class->members.size(); i++) { const GDScriptParser::ClassNode::Member &m = p_class->members[i]; @@ -253,7 +329,7 @@ void GDScriptEditorTranslationParserPlugin::_assess_assignment(const GDScriptPar if (assignee_name != StringName() && assignment_patterns.has(assignee_name) && _is_constant_string(p_assignment->assigned_value)) { // If the assignment is towards one of the extract patterns (text, tooltip_text etc.), and the value is a constant string, we collect the string. - ids->push_back(p_assignment->assigned_value->reduced_value); + _add_id(p_assignment->assigned_value->reduced_value, p_assignment->assigned_value->start_line); } else if (assignee_name == fd_filters) { // Extract from `get_node("FileDialog").filters = <filter array>`. _extract_fd_filter_array(p_assignment->assigned_value); @@ -287,7 +363,7 @@ void GDScriptEditorTranslationParserPlugin::_assess_call(const GDScriptParser::C } } if (extract_id_ctx_plural) { - ids_ctx_plural->push_back(id_ctx_plural); + _add_id_ctx_plural(id_ctx_plural, p_call->start_line); } } else if (function_name == trn_func || function_name == atrn_func) { // Extract from `tr_n(id, plural, n, ctx)` or `atr_n(id, plural, n, ctx)`. @@ -307,20 +383,20 @@ void GDScriptEditorTranslationParserPlugin::_assess_call(const GDScriptParser::C } } if (extract_id_ctx_plural) { - ids_ctx_plural->push_back(id_ctx_plural); + _add_id_ctx_plural(id_ctx_plural, p_call->start_line); } } else if (first_arg_patterns.has(function_name)) { if (!p_call->arguments.is_empty() && _is_constant_string(p_call->arguments[0])) { - ids->push_back(p_call->arguments[0]->reduced_value); + _add_id(p_call->arguments[0]->reduced_value, p_call->arguments[0]->start_line); } } else if (second_arg_patterns.has(function_name)) { if (p_call->arguments.size() > 1 && _is_constant_string(p_call->arguments[1])) { - ids->push_back(p_call->arguments[1]->reduced_value); + _add_id(p_call->arguments[1]->reduced_value, p_call->arguments[1]->start_line); } } else if (function_name == fd_add_filter) { // Extract the 'JPE Images' in this example - get_node("FileDialog").add_filter("*.jpg; JPE Images"). if (!p_call->arguments.is_empty()) { - _extract_fd_filter_string(p_call->arguments[0]); + _extract_fd_filter_string(p_call->arguments[0], p_call->arguments[0]->start_line); } } else if (function_name == fd_set_filter) { // Extract from `get_node("FileDialog").set_filters(<filter array>)`. @@ -330,12 +406,12 @@ void GDScriptEditorTranslationParserPlugin::_assess_call(const GDScriptParser::C } } -void GDScriptEditorTranslationParserPlugin::_extract_fd_filter_string(const GDScriptParser::ExpressionNode *p_expression) { +void GDScriptEditorTranslationParserPlugin::_extract_fd_filter_string(const GDScriptParser::ExpressionNode *p_expression, int p_line) { // Extract the name in "extension ; name". if (_is_constant_string(p_expression)) { PackedStringArray arr = p_expression->reduced_value.operator String().split(";", true); ERR_FAIL_COND_MSG(arr.size() != 2, "Argument for setting FileDialog has bad format."); - ids->push_back(arr[1].strip_edges()); + _add_id(arr[1].strip_edges(), p_line); } } @@ -355,7 +431,7 @@ void GDScriptEditorTranslationParserPlugin::_extract_fd_filter_array(const GDScr if (array_node) { for (int i = 0; i < array_node->elements.size(); i++) { - _extract_fd_filter_string(array_node->elements[i]); + _extract_fd_filter_string(array_node->elements[i], array_node->elements[i]->start_line); } } } diff --git a/modules/gdscript/editor/gdscript_translation_parser_plugin.h b/modules/gdscript/editor/gdscript_translation_parser_plugin.h index 61ff81ed66..73e8f53110 100644 --- a/modules/gdscript/editor/gdscript_translation_parser_plugin.h +++ b/modules/gdscript/editor/gdscript_translation_parser_plugin.h @@ -32,16 +32,23 @@ #define GDSCRIPT_TRANSLATION_PARSER_PLUGIN_H #include "../gdscript_parser.h" +#include "../gdscript_tokenizer.h" +#include "core/templates/hash_map.h" #include "core/templates/hash_set.h" #include "editor/editor_translation_parser.h" class GDScriptEditorTranslationParserPlugin : public EditorTranslationParserPlugin { GDCLASS(GDScriptEditorTranslationParserPlugin, EditorTranslationParserPlugin); + const HashMap<int, GDScriptTokenizer::CommentData> *comment_data = nullptr; + Vector<String> *ids = nullptr; Vector<Vector<String>> *ids_ctx_plural = nullptr; + Vector<String> ids_comment; + Vector<String> ids_ctx_plural_comment; + // List of patterns used for extracting translation strings. StringName tr_func = "tr"; StringName trn_func = "tr_n"; @@ -57,6 +64,11 @@ class GDScriptEditorTranslationParserPlugin : public EditorTranslationParserPlug static bool _is_constant_string(const GDScriptParser::ExpressionNode *p_expression); + String _parse_comment(int p_line, bool &r_skip) const; + + void _add_id(const String &p_id, int p_line); + void _add_id_ctx_plural(const Vector<String> &p_id_ctx_plural, int p_line); + void _traverse_class(const GDScriptParser::ClassNode *p_class); void _traverse_function(const GDScriptParser::FunctionNode *p_func); void _traverse_block(const GDScriptParser::SuiteNode *p_suite); @@ -65,11 +77,12 @@ class GDScriptEditorTranslationParserPlugin : public EditorTranslationParserPlug void _assess_assignment(const GDScriptParser::AssignmentNode *p_assignment); void _assess_call(const GDScriptParser::CallNode *p_call); - void _extract_fd_filter_string(const GDScriptParser::ExpressionNode *p_expression); + void _extract_fd_filter_string(const GDScriptParser::ExpressionNode *p_expression, int p_line); void _extract_fd_filter_array(const GDScriptParser::ExpressionNode *p_expression); public: virtual Error parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural) override; + virtual void get_comments(Vector<String> *r_ids_comment, Vector<String> *r_ids_ctx_plural_comment) override; virtual void get_recognized_extensions(List<String> *r_extensions) const override; GDScriptEditorTranslationParserPlugin(); diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 951ae6ce99..d58cd2c3f7 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -43,6 +43,7 @@ #include "core/config/engine.h" #include "core/core_constants.h" #include "core/io/file_access.h" +#include "core/math/expression.h" #ifdef TOOLS_ENABLED #include "core/config/project_settings.h" @@ -427,7 +428,30 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant> } String GDScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) { - return ""; + List<String> names; + List<Variant> values; + debug_get_stack_level_locals(p_level, &names, &values, p_max_subitems, p_max_depth); + + Vector<String> name_vector; + for (const String &name : names) { + name_vector.push_back(name); + } + + Array value_array; + for (const Variant &value : values) { + value_array.push_back(value); + } + + Expression expression; + if (expression.parse(p_expression, name_vector) == OK) { + ScriptInstance *instance = debug_get_stack_level_instance(p_level); + if (instance) { + Variant return_val = expression.execute(value_array, instance->get_owner()); + return return_val.get_construct_string(); + } + } + + return String(); } void GDScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const { @@ -3448,7 +3472,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c } String arg = arg_itr->name; if (arg.contains(":")) { - arg = arg.substr(0, arg.find(":")); + arg = arg.substr(0, arg.find_char(':')); } method_hint += arg; if (use_type_hint) { diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index ee8d53639c..12e71004db 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -409,6 +409,10 @@ Error GDScriptParser::parse(const String &p_source_code, const String &p_script_ parse_program(); pop_multiline(); +#ifdef TOOLS_ENABLED + comment_data = tokenizer->get_comments(); +#endif + memdelete(text_tokenizer); tokenizer = nullptr; diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 2ec33831a2..d40ba217c1 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -1601,6 +1601,8 @@ public: #ifdef TOOLS_ENABLED static HashMap<String, String> theme_color_names; + + HashMap<int, GDScriptTokenizer::CommentData> comment_data; #endif // TOOLS_ENABLED GDScriptParser(); diff --git a/modules/gdscript/tests/scripts/completion/argument_options/argument_options.tscn b/modules/gdscript/tests/scripts/completion/argument_options/argument_options.tscn index d3dea6b12b..082c87e708 100644 --- a/modules/gdscript/tests/scripts/completion/argument_options/argument_options.tscn +++ b/modules/gdscript/tests/scripts/completion/argument_options/argument_options.tscn @@ -1,3 +1,16 @@ [gd_scene load_steps=1 format=3 uid="uid://dl28pdkxcjvym"] +[sub_resource type="Animation" id="Animation_d1pub"] +resource_name = "bounce" + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_gs7mj"] +_data = { +"bounce": SubResource("Animation_d1pub") +} + [node name="GetNode" type="Node"] + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_gs7mj") +} diff --git a/modules/gdscript/tests/scripts/completion/argument_options/play_inferred.cfg b/modules/gdscript/tests/scripts/completion/argument_options/play_inferred.cfg new file mode 100644 index 0000000000..ca108a18c2 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/argument_options/play_inferred.cfg @@ -0,0 +1,6 @@ +[input] +scene="res://completion/argument_options/argument_options.tscn" +[output] +include=[ + {"display": "\"bounce\""}, +] diff --git a/modules/gdscript/tests/scripts/completion/argument_options/play_inferred.gd b/modules/gdscript/tests/scripts/completion/argument_options/play_inferred.gd new file mode 100644 index 0000000000..abeadbe5ee --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/argument_options/play_inferred.gd @@ -0,0 +1,5 @@ +@onready var anim := $AnimationPlayer + +func test(): + anim.play(➡) + pass diff --git a/modules/gdscript/tests/scripts/completion/argument_options/play_typed.cfg b/modules/gdscript/tests/scripts/completion/argument_options/play_typed.cfg new file mode 100644 index 0000000000..ca108a18c2 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/argument_options/play_typed.cfg @@ -0,0 +1,6 @@ +[input] +scene="res://completion/argument_options/argument_options.tscn" +[output] +include=[ + {"display": "\"bounce\""}, +] diff --git a/modules/gdscript/tests/scripts/completion/argument_options/play_typed.gd b/modules/gdscript/tests/scripts/completion/argument_options/play_typed.gd new file mode 100644 index 0000000000..d11f81e985 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/argument_options/play_typed.gd @@ -0,0 +1,5 @@ +@onready var anim: AnimationPlayer = $AnimationPlayer + +func test(): + anim.play(➡) + pass diff --git a/modules/gdscript/tests/scripts/completion/argument_options/play_untyped.cfg b/modules/gdscript/tests/scripts/completion/argument_options/play_untyped.cfg new file mode 100644 index 0000000000..ca108a18c2 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/argument_options/play_untyped.cfg @@ -0,0 +1,6 @@ +[input] +scene="res://completion/argument_options/argument_options.tscn" +[output] +include=[ + {"display": "\"bounce\""}, +] diff --git a/modules/gdscript/tests/scripts/completion/argument_options/play_untyped.gd b/modules/gdscript/tests/scripts/completion/argument_options/play_untyped.gd new file mode 100644 index 0000000000..4ddfd21ac6 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/argument_options/play_untyped.gd @@ -0,0 +1,5 @@ +@onready var anim = $AnimationPlayer + +func test(): + anim.play(➡) + pass diff --git a/modules/gltf/doc_classes/GLTFAccessor.xml b/modules/gltf/doc_classes/GLTFAccessor.xml index 04fa2a9835..271f098803 100644 --- a/modules/gltf/doc_classes/GLTFAccessor.xml +++ b/modules/gltf/doc_classes/GLTFAccessor.xml @@ -102,13 +102,13 @@ Component type "UNSIGNED_INT". The value is [code]0x1405[/code] which comes from OpenGL. This indicates data is stored in 4-byte or 32-bit unsigned integers. This is a core part of the glTF specification. </constant> <constant name="COMPONENT_TYPE_SINGLE_FLOAT" value="5126" enum="GLTFComponentType"> - Component type "FLOAT". The value is [code]0x1406[/code] which comes from OpenGL. This indicates data is stored in 4-byte or 32-bit floating point numbers. This is a core part of the glTF specification. + Component type "FLOAT". The value is [code]0x1406[/code] which comes from OpenGL. This indicates data is stored in 4-byte or 32-bit floating-point numbers. This is a core part of the glTF specification. </constant> <constant name="COMPONENT_TYPE_DOUBLE_FLOAT" value="5130" enum="GLTFComponentType"> - Component type "DOUBLE". The value is [code]0x140A[/code] which comes from OpenGL. This indicates data is stored in 8-byte or 64-bit floating point numbers. This is NOT a core part of the glTF specification, and may not be supported by all glTF importers. May be used by some extensions including [code]KHR_interactivity[/code]. + Component type "DOUBLE". The value is [code]0x140A[/code] which comes from OpenGL. This indicates data is stored in 8-byte or 64-bit floating-point numbers. This is NOT a core part of the glTF specification, and may not be supported by all glTF importers. May be used by some extensions including [code]KHR_interactivity[/code]. </constant> <constant name="COMPONENT_TYPE_HALF_FLOAT" value="5131" enum="GLTFComponentType"> - Component type "HALF_FLOAT". The value is [code]0x140B[/code] which comes from OpenGL. This indicates data is stored in 2-byte or 16-bit floating point numbers. This is NOT a core part of the glTF specification, and may not be supported by all glTF importers. May be used by some extensions including [code]KHR_interactivity[/code]. + Component type "HALF_FLOAT". The value is [code]0x140B[/code] which comes from OpenGL. This indicates data is stored in 2-byte or 16-bit floating-point numbers. This is NOT a core part of the glTF specification, and may not be supported by all glTF importers. May be used by some extensions including [code]KHR_interactivity[/code]. </constant> <constant name="COMPONENT_TYPE_SIGNED_LONG" value="5134" enum="GLTFComponentType"> Component type "LONG". The value is [code]0x140E[/code] which comes from OpenGL. This indicates data is stored in 8-byte or 64-bit signed integers. This is NOT a core part of the glTF specification, and may not be supported by all glTF importers. May be used by some extensions including [code]KHR_interactivity[/code]. diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp index 2db46adef4..5ba9ee3fa6 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.cpp +++ b/modules/gltf/editor/editor_scene_importer_blend.cpp @@ -80,7 +80,7 @@ static bool _get_blender_version(const String &p_path, int &r_major, int &r_mino } pipe = pipe.substr(bl); pipe = pipe.replace_first("Blender ", ""); - int pp = pipe.find("."); + int pp = pipe.find_char('.'); if (pp == -1) { if (r_err) { *r_err = vformat(TTR("Couldn't extract version information from Blender executable at: %s."), p_path); @@ -96,7 +96,7 @@ static bool _get_blender_version(const String &p_path, int &r_major, int &r_mino return false; } - int pp2 = pipe.find(".", pp + 1); + int pp2 = pipe.find_char('.', pp + 1); r_minor = pp2 > pp ? pipe.substr(pp + 1, pp2 - pp - 1).to_int() : 0; return true; diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 7cac61304f..2f36c29ec4 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -689,7 +689,7 @@ void GLTFDocument::_compute_node_heights(Ref<GLTFState> p_state) { } static Vector<uint8_t> _parse_base64_uri(const String &p_uri) { - int start = p_uri.find(","); + int start = p_uri.find_char(','); ERR_FAIL_COND_V(start == -1, Vector<uint8_t>()); CharString substr = p_uri.substr(start + 1).ascii(); diff --git a/modules/gridmap/editor/grid_map_editor_plugin.cpp b/modules/gridmap/editor/grid_map_editor_plugin.cpp index caa7a79874..99e3b02dea 100644 --- a/modules/gridmap/editor/grid_map_editor_plugin.cpp +++ b/modules/gridmap/editor/grid_map_editor_plugin.cpp @@ -646,6 +646,7 @@ EditorPlugin::AfterGUIInput GridMapEditor::forward_spatial_input_event(Camera3D Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed() && !k->is_echo()) { + // Transform mode (toggle button): // If we are in Transform mode we pass the events to the 3D editor, // but if the Transform mode shortcut is pressed again, we go back to Selection mode. if (mode_buttons_group->get_pressed_button() == transform_mode_button) { @@ -656,7 +657,7 @@ EditorPlugin::AfterGUIInput GridMapEditor::forward_spatial_input_event(Camera3D } return EditorPlugin::AFTER_GUI_INPUT_PASS; } - + // Tool modes and tool actions: for (BaseButton *b : viewport_shortcut_buttons) { if (b->is_disabled()) { continue; @@ -673,9 +674,7 @@ EditorPlugin::AfterGUIInput GridMapEditor::forward_spatial_input_event(Camera3D return EditorPlugin::AFTER_GUI_INPUT_STOP; } } - } - - if (k.is_valid() && k->is_pressed() && !k->is_echo()) { + // Hard key actions: if (k->get_keycode() == Key::ESCAPE) { if (input_action == INPUT_PASTE) { _clear_clipboard_data(); @@ -692,7 +691,7 @@ EditorPlugin::AfterGUIInput GridMapEditor::forward_spatial_input_event(Camera3D return EditorPlugin::AFTER_GUI_INPUT_STOP; } } - + // Options menu shortcuts: Ref<Shortcut> ed_shortcut = ED_GET_SHORTCUT("grid_map/previous_floor"); if (ed_shortcut.is_valid() && ed_shortcut->matches_event(p_event)) { accept_event(); @@ -1396,6 +1395,7 @@ GridMapEditor::GridMapEditor() { fill_action_button->connect(SceneStringName(pressed), callable_mp(this, &GridMapEditor::_menu_option).bind(MENU_OPTION_SELECTION_FILL)); action_buttons->add_child(fill_action_button); + viewport_shortcut_buttons.push_back(fill_action_button); move_action_button = memnew(Button); move_action_button->set_theme_type_variation("FlatButton"); @@ -1403,6 +1403,7 @@ GridMapEditor::GridMapEditor() { move_action_button->connect(SceneStringName(pressed), callable_mp(this, &GridMapEditor::_menu_option).bind(MENU_OPTION_SELECTION_CUT)); action_buttons->add_child(move_action_button); + viewport_shortcut_buttons.push_back(move_action_button); duplicate_action_button = memnew(Button); duplicate_action_button->set_theme_type_variation("FlatButton"); @@ -1410,6 +1411,7 @@ GridMapEditor::GridMapEditor() { duplicate_action_button->connect(SceneStringName(pressed), callable_mp(this, &GridMapEditor::_menu_option).bind(MENU_OPTION_SELECTION_DUPLICATE)); action_buttons->add_child(duplicate_action_button); + viewport_shortcut_buttons.push_back(duplicate_action_button); delete_action_button = memnew(Button); delete_action_button->set_theme_type_variation("FlatButton"); @@ -1417,6 +1419,7 @@ GridMapEditor::GridMapEditor() { delete_action_button->connect(SceneStringName(pressed), callable_mp(this, &GridMapEditor::_menu_option).bind(MENU_OPTION_SELECTION_CLEAR)); action_buttons->add_child(delete_action_button); + viewport_shortcut_buttons.push_back(delete_action_button); vsep = memnew(VSeparator); toolbar->add_child(vsep); @@ -1430,6 +1433,7 @@ GridMapEditor::GridMapEditor() { rotate_x_button->connect(SceneStringName(pressed), callable_mp(this, &GridMapEditor::_menu_option).bind(MENU_OPTION_CURSOR_ROTATE_X)); rotation_buttons->add_child(rotate_x_button); + viewport_shortcut_buttons.push_back(rotate_x_button); rotate_y_button = memnew(Button); rotate_y_button->set_theme_type_variation("FlatButton"); @@ -1437,6 +1441,7 @@ GridMapEditor::GridMapEditor() { rotate_y_button->connect(SceneStringName(pressed), callable_mp(this, &GridMapEditor::_menu_option).bind(MENU_OPTION_CURSOR_ROTATE_Y)); rotation_buttons->add_child(rotate_y_button); + viewport_shortcut_buttons.push_back(rotate_y_button); rotate_z_button = memnew(Button); rotate_z_button->set_theme_type_variation("FlatButton"); @@ -1444,6 +1449,7 @@ GridMapEditor::GridMapEditor() { rotate_z_button->connect(SceneStringName(pressed), callable_mp(this, &GridMapEditor::_menu_option).bind(MENU_OPTION_CURSOR_ROTATE_Z)); rotation_buttons->add_child(rotate_z_button); + viewport_shortcut_buttons.push_back(rotate_z_button); // Wide empty separation control. (like BoxContainer::add_spacer()) Control *c = memnew(Control); @@ -1456,9 +1462,9 @@ GridMapEditor::GridMapEditor() { floor->set_max(32767); floor->set_step(1); floor->set_tooltip_text( - TTR(vformat("Change Grid Floor:\nPrevious Plane (%s)\nNext Plane (%s)", + vformat(TTR("Change Grid Floor:\nPrevious Plane (%s)\nNext Plane (%s)"), ED_GET_SHORTCUT("grid_map/previous_floor")->get_as_text(), - ED_GET_SHORTCUT("grid_map/next_floor")->get_as_text()))); + ED_GET_SHORTCUT("grid_map/next_floor")->get_as_text())); toolbar->add_child(floor); floor->get_line_edit()->add_theme_constant_override("minimum_character_width", 2); floor->get_line_edit()->set_context_menu_enabled(false); diff --git a/modules/mbedtls/stream_peer_mbedtls.cpp b/modules/mbedtls/stream_peer_mbedtls.cpp index b4200410fb..3af66f6d83 100644 --- a/modules/mbedtls/stream_peer_mbedtls.cpp +++ b/modules/mbedtls/stream_peer_mbedtls.cpp @@ -166,21 +166,24 @@ Error StreamPeerMbedTLS::put_partial_data(const uint8_t *p_data, int p_bytes, in return OK; } - int ret = mbedtls_ssl_write(tls_ctx->get_context(), p_data, p_bytes); - if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) { - // Non blocking IO - ret = 0; - } else if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { - // Clean close - disconnect_from_stream(); - return ERR_FILE_EOF; - } else if (ret <= 0) { - TLSContextMbedTLS::print_mbedtls_error(ret); - disconnect_from_stream(); - return ERR_CONNECTION_ERROR; - } + do { + int ret = mbedtls_ssl_write(tls_ctx->get_context(), &p_data[r_sent], p_bytes - r_sent); + if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) { + // Non blocking IO. + break; + } else if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { + // Clean close + disconnect_from_stream(); + return ERR_FILE_EOF; + } else if (ret <= 0) { + TLSContextMbedTLS::print_mbedtls_error(ret); + disconnect_from_stream(); + return ERR_CONNECTION_ERROR; + } + r_sent += ret; + + } while (r_sent < p_bytes); - r_sent = ret; return OK; } @@ -209,20 +212,25 @@ Error StreamPeerMbedTLS::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r r_received = 0; - int ret = mbedtls_ssl_read(tls_ctx->get_context(), p_buffer, p_bytes); - if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) { - ret = 0; // non blocking io - } else if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { - // Clean close - disconnect_from_stream(); - return ERR_FILE_EOF; - } else if (ret <= 0) { - TLSContextMbedTLS::print_mbedtls_error(ret); - disconnect_from_stream(); - return ERR_CONNECTION_ERROR; - } + do { + int ret = mbedtls_ssl_read(tls_ctx->get_context(), &p_buffer[r_received], p_bytes - r_received); + if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) { + // Non blocking IO. + break; + } else if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { + // Clean close + disconnect_from_stream(); + return ERR_FILE_EOF; + } else if (ret <= 0) { + TLSContextMbedTLS::print_mbedtls_error(ret); + disconnect_from_stream(); + return ERR_CONNECTION_ERROR; + } + + r_received += ret; + + } while (r_received < p_bytes); - r_received = ret; return OK; } diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 380b401683..ec9c123f8d 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2817,7 +2817,7 @@ Ref<Resource> ResourceFormatLoaderCSharpScript::load(const String &p_path, const if (p_path.begins_with("csharp://")) { // This is a virtual path used by generic types, extract the real path. real_path = "res://" + p_path.trim_prefix("csharp://"); - real_path = real_path.substr(0, real_path.rfind(":")); + real_path = real_path.substr(0, real_path.rfind_char(':')); } Ref<CSharpScript> scr; diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs index fc67e4f592..f192bf0fb7 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs @@ -423,25 +423,10 @@ namespace Godot.SourceGenerators if (exportAttr != null && propertySymbol != null) { - if (propertySymbol.GetMethod == null) + if (propertySymbol.GetMethod == null || propertySymbol.SetMethod == null || propertySymbol.SetMethod.IsInitOnly) { - // This should never happen, as we filtered WriteOnly properties, but just in case. - context.ReportDiagnostic(Diagnostic.Create( - Common.ExportedPropertyIsWriteOnlyRule, - propertySymbol.Locations.FirstLocationWithSourceTreeOrDefault(), - propertySymbol.ToDisplayString() - )); - return null; - } - - if (propertySymbol.SetMethod == null || propertySymbol.SetMethod.IsInitOnly) - { - // This should never happen, as we filtered ReadOnly properties, but just in case. - context.ReportDiagnostic(Diagnostic.Create( - Common.ExportedMemberIsReadOnlyRule, - propertySymbol.Locations.FirstLocationWithSourceTreeOrDefault(), - propertySymbol.ToDisplayString() - )); + // Exports can be neither read-only nor write-only but the diagnostic errors for properties are already + // reported by ScriptPropertyDefValGenerator.cs so just quit early here. return null; } } diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index db90ac5a6e..c54d58d6a0 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -190,7 +190,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter int pos = 0; while (pos < bbcode.length()) { - int brk_pos = bbcode.find("[", pos); + int brk_pos = bbcode.find_char('[', pos); if (brk_pos < 0) { brk_pos = bbcode.length(); @@ -210,7 +210,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter break; } - int brk_end = bbcode.find("]", brk_pos + 1); + int brk_end = bbcode.find_char(']', brk_pos + 1); if (brk_end == -1) { String text = bbcode.substr(brk_pos, bbcode.length() - brk_pos); @@ -239,7 +239,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter output.append("["); pos = brk_pos + 1; } else if (tag.begins_with("method ") || tag.begins_with("constructor ") || tag.begins_with("operator ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ") || tag.begins_with("constant ") || tag.begins_with("theme_item ") || tag.begins_with("param ")) { - const int tag_end = tag.find(" "); + const int tag_end = tag.find_char(' '); const String link_tag = tag.substr(0, tag_end); const String link_target = tag.substr(tag_end + 1, tag.length()).lstrip(" "); @@ -385,7 +385,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "url") { - int end = bbcode.find("[", brk_end); + int end = bbcode.find_char('[', brk_end); if (end == -1) { end = bbcode.length(); } @@ -403,7 +403,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter pos = brk_end + 1; tag_stack.push_front("url"); } else if (tag == "img") { - int end = bbcode.find("[", brk_end); + int end = bbcode.find_char('[', brk_end); if (end == -1) { end = bbcode.length(); } @@ -455,7 +455,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf int pos = 0; while (pos < bbcode.length()) { - int brk_pos = bbcode.find("[", pos); + int brk_pos = bbcode.find_char('[', pos); if (brk_pos < 0) { brk_pos = bbcode.length(); @@ -488,7 +488,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf break; } - int brk_end = bbcode.find("]", brk_pos + 1); + int brk_end = bbcode.find_char(']', brk_pos + 1); if (brk_end == -1) { if (!line_del) { @@ -551,7 +551,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf xml_output.append("["); pos = brk_pos + 1; } else if (tag.begins_with("method ") || tag.begins_with("constructor ") || tag.begins_with("operator ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ") || tag.begins_with("constant ") || tag.begins_with("theme_item ") || tag.begins_with("param ")) { - const int tag_end = tag.find(" "); + const int tag_end = tag.find_char(' '); const String link_tag = tag.substr(0, tag_end); const String link_target = tag.substr(tag_end + 1, tag.length()).lstrip(" "); @@ -696,7 +696,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "code" || tag.begins_with("code ")) { - int end = bbcode.find("[", brk_end); + int end = bbcode.find_char('[', brk_end); if (end == -1) { end = bbcode.length(); } @@ -751,7 +751,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "url") { - int end = bbcode.find("[", brk_end); + int end = bbcode.find_char('[', brk_end); if (end == -1) { end = bbcode.length(); } @@ -772,7 +772,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf pos = brk_end + 1; tag_stack.push_front("url"); } else if (tag == "img") { - int end = bbcode.find("[", brk_end); + int end = bbcode.find_char('[', brk_end); if (end == -1) { end = bbcode.length(); } @@ -1619,7 +1619,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { bool enum_in_static_class = false; - if (enum_proxy_name.find(".") > 0) { + if (enum_proxy_name.find_char('.') > 0) { enum_in_static_class = true; String enum_class_name = enum_proxy_name.get_slicec('.', 0); enum_proxy_name = enum_proxy_name.get_slicec('.', 1); diff --git a/modules/mono/editor/code_completion.cpp b/modules/mono/editor/code_completion.cpp index ae914e71ef..94222f3d67 100644 --- a/modules/mono/editor/code_completion.cpp +++ b/modules/mono/editor/code_completion.cpp @@ -116,7 +116,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr continue; } - String name = prop.name.substr(prop.name.find("/") + 1, prop.name.length()); + String name = prop.name.substr(prop.name.find_char('/') + 1, prop.name.length()); suggestions.push_back(quoted(name)); } } break; diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index ee17a668d7..068ac8b4e1 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -212,7 +212,7 @@ String relative_to_impl(const String &p_path, const String &p_relative_to) { #ifdef WINDOWS_ENABLED String get_drive_letter(const String &p_norm_path) { int idx = p_norm_path.find(":/"); - if (idx != -1 && idx < p_norm_path.find("/")) { + if (idx != -1 && idx < p_norm_path.find_char('/')) { return p_norm_path.substr(0, idx + 1); } return String(); diff --git a/modules/multiplayer/doc_classes/MultiplayerSynchronizer.xml b/modules/multiplayer/doc_classes/MultiplayerSynchronizer.xml index c2d879962c..edcaa3baef 100644 --- a/modules/multiplayer/doc_classes/MultiplayerSynchronizer.xml +++ b/modules/multiplayer/doc_classes/MultiplayerSynchronizer.xml @@ -53,7 +53,7 @@ </methods> <members> <member name="delta_interval" type="float" setter="set_delta_interval" getter="get_delta_interval" default="0.0"> - Time interval between delta synchronizations. When set to [code]0.0[/code] (the default), delta synchronizations happen every network process frame. + Time interval between delta synchronizations. Used when the replication is set to [constant SceneReplicationConfig.REPLICATION_MODE_ON_CHANGE]. If set to [code]0.0[/code] (the default), delta synchronizations happen every network process frame. </member> <member name="public_visibility" type="bool" setter="set_visibility_public" getter="is_visibility_public" default="true"> Whether synchronization should be visible to all peers by default. See [method set_visibility_for] and [method add_visibility_filter] for ways of configuring fine-grained visibility options. @@ -62,7 +62,7 @@ Resource containing which properties to synchronize. </member> <member name="replication_interval" type="float" setter="set_replication_interval" getter="get_replication_interval" default="0.0"> - Time interval between synchronizations. When set to [code]0.0[/code] (the default), synchronizations happen every network process frame. + Time interval between synchronizations. Used when the replication is set to [constant SceneReplicationConfig.REPLICATION_MODE_ALWAYS]. If set to [code]0.0[/code] (the default), synchronizations happen every network process frame. </member> <member name="root_path" type="NodePath" setter="set_root_path" getter="get_root_path" default="NodePath("..")"> Node path that replicated properties are relative to. diff --git a/modules/multiplayer/editor/replication_editor.cpp b/modules/multiplayer/editor/replication_editor.cpp index 8de82ef409..4d5480eebf 100644 --- a/modules/multiplayer/editor/replication_editor.cpp +++ b/modules/multiplayer/editor/replication_editor.cpp @@ -375,7 +375,7 @@ void ReplicationEditor::_add_pressed() { return; } - int idx = np_text.find(":"); + int idx = np_text.find_char(':'); if (idx == -1) { np_text = ".:" + np_text; } else if (idx == 0) { @@ -554,7 +554,7 @@ void ReplicationEditor::_add_property(const NodePath &p_property, bool p_spawn, Node *root_node = current && !current->get_root_path().is_empty() ? current->get_node(current->get_root_path()) : nullptr; Ref<Texture2D> icon = _get_class_icon(root_node); if (root_node) { - String path = prop.substr(0, prop.find(":")); + String path = prop.substr(0, prop.find_char(':')); String subpath = prop.substr(path.size()); Node *node = root_node->get_node_or_null(path); if (!node) { diff --git a/modules/navigation/2d/nav_mesh_generator_2d.cpp b/modules/navigation/2d/nav_mesh_generator_2d.cpp index c996c9e935..a8eb07147c 100644 --- a/modules/navigation/2d/nav_mesh_generator_2d.cpp +++ b/modules/navigation/2d/nav_mesh_generator_2d.cpp @@ -850,7 +850,7 @@ void NavMeshGenerator2D::generator_bake_from_source_geometry_data(Ref<Navigation using namespace Clipper2Lib; PathsD traversable_polygon_paths; PathsD obstruction_polygon_paths; - int obstruction_polygon_path_size = 0; + bool empty_projected_obstructions = true; { RWLockRead read_lock(p_source_geometry_data->geometry_rwlock); @@ -886,7 +886,8 @@ void NavMeshGenerator2D::generator_bake_from_source_geometry_data(Ref<Navigation traversable_polygon_paths.push_back(std::move(subject_path)); } - if (!projected_obstructions.is_empty()) { + empty_projected_obstructions = projected_obstructions.is_empty(); + if (!empty_projected_obstructions) { for (const NavigationMeshSourceGeometryData2D::ProjectedObstruction &projected_obstruction : projected_obstructions) { if (projected_obstruction.carve) { continue; @@ -907,7 +908,6 @@ void NavMeshGenerator2D::generator_bake_from_source_geometry_data(Ref<Navigation } } - obstruction_polygon_path_size = obstruction_polygon_paths.size(); for (const Vector<Vector2> &obstruction_outline : obstruction_outlines) { PathD clip_path; clip_path.reserve(obstruction_outline.size()); @@ -919,7 +919,6 @@ void NavMeshGenerator2D::generator_bake_from_source_geometry_data(Ref<Navigation } Rect2 baking_rect = p_navigation_mesh->get_baking_rect(); - PathsD area_obstruction_polygon_paths; if (baking_rect.has_area()) { Vector2 baking_rect_offset = p_navigation_mesh->get_baking_rect_offset(); @@ -931,27 +930,48 @@ void NavMeshGenerator2D::generator_bake_from_source_geometry_data(Ref<Navigation RectD clipper_rect = RectD(rect_begin_x, rect_begin_y, rect_end_x, rect_end_y); traversable_polygon_paths = RectClip(clipper_rect, traversable_polygon_paths); - area_obstruction_polygon_paths = RectClip(clipper_rect, obstruction_polygon_paths); - } else { - area_obstruction_polygon_paths = obstruction_polygon_paths; + obstruction_polygon_paths = RectClip(clipper_rect, obstruction_polygon_paths); } // first merge all traversable polygons according to user specified fill rule PathsD dummy_clip_path; traversable_polygon_paths = Union(traversable_polygon_paths, dummy_clip_path, FillRule::NonZero); // merge all obstruction polygons, don't allow holes for what is considered "solid" 2D geometry - area_obstruction_polygon_paths = Union(area_obstruction_polygon_paths, dummy_clip_path, FillRule::NonZero); + obstruction_polygon_paths = Union(obstruction_polygon_paths, dummy_clip_path, FillRule::NonZero); - PathsD path_solution = Difference(traversable_polygon_paths, area_obstruction_polygon_paths, FillRule::NonZero); + PathsD path_solution = Difference(traversable_polygon_paths, obstruction_polygon_paths, FillRule::NonZero); real_t agent_radius_offset = p_navigation_mesh->get_agent_radius(); if (agent_radius_offset > 0.0) { path_solution = InflatePaths(path_solution, -agent_radius_offset, JoinType::Miter, EndType::Polygon); } - if (obstruction_polygon_path_size > 0) { - obstruction_polygon_paths.resize(obstruction_polygon_path_size); - path_solution = Difference(path_solution, obstruction_polygon_paths, FillRule::NonZero); + // Apply obstructions that are not affected by agent radius, the ones with carve enabled. + if (!empty_projected_obstructions) { + RWLockRead read_lock(p_source_geometry_data->geometry_rwlock); + const Vector<NavigationMeshSourceGeometryData2D::ProjectedObstruction> &projected_obstructions = p_source_geometry_data->_projected_obstructions; + obstruction_polygon_paths.resize(0); + for (const NavigationMeshSourceGeometryData2D::ProjectedObstruction &projected_obstruction : projected_obstructions) { + if (!projected_obstruction.carve) { + continue; + } + if (projected_obstruction.vertices.is_empty() || projected_obstruction.vertices.size() % 2 != 0) { + continue; + } + + PathD clip_path; + clip_path.reserve(projected_obstruction.vertices.size() / 2); + for (int i = 0; i < projected_obstruction.vertices.size() / 2; i++) { + clip_path.emplace_back(projected_obstruction.vertices[i * 2], projected_obstruction.vertices[i * 2 + 1]); + } + if (!IsPositive(clip_path)) { + std::reverse(clip_path.begin(), clip_path.end()); + } + obstruction_polygon_paths.push_back(std::move(clip_path)); + } + if (obstruction_polygon_paths.size() > 0) { + path_solution = Difference(path_solution, obstruction_polygon_paths, FillRule::NonZero); + } } //path_solution = RamerDouglasPeucker(path_solution, 0.025); // diff --git a/modules/openxr/doc_classes/OpenXRExtensionWrapperExtension.xml b/modules/openxr/doc_classes/OpenXRExtensionWrapperExtension.xml index 182fe32f9c..c174ee4d69 100644 --- a/modules/openxr/doc_classes/OpenXRExtensionWrapperExtension.xml +++ b/modules/openxr/doc_classes/OpenXRExtensionWrapperExtension.xml @@ -235,7 +235,7 @@ <return type="int" /> <param index="0" name="next_pointer" type="void*" /> <description> - Adds additional data structures when interogating OpenXR system abilities. + Adds additional data structures when querying OpenXR system abilities. </description> </method> <method name="_set_viewport_composition_layer_and_get_next_pointer" qualifiers="virtual"> diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp index a6fd727290..1775541757 100644 --- a/modules/openxr/openxr_api.cpp +++ b/modules/openxr/openxr_api.cpp @@ -2036,8 +2036,9 @@ bool OpenXRAPI::poll_events() { if (local_floor_emulation.enabled) { local_floor_emulation.should_reset_floor_height = true; } - if (event->poseValid && xr_interface) { - xr_interface->on_pose_recentered(); + + if (xr_interface) { + xr_interface->on_reference_space_change_pending(); } } break; case XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED: { diff --git a/modules/openxr/openxr_interface.cpp b/modules/openxr/openxr_interface.cpp index 8e0c672e58..68e04694e3 100644 --- a/modules/openxr/openxr_interface.cpp +++ b/modules/openxr/openxr_interface.cpp @@ -1134,6 +1134,12 @@ void OpenXRInterface::process() { if (head.is_valid()) { head->set_pose("default", head_transform, head_linear_velocity, head_angular_velocity, head_confidence); } + + if (reference_stage_changing) { + // Now that we have updated tracking information in our updated reference space, trigger our pose recentered signal. + emit_signal(SNAME("pose_recentered")); + reference_stage_changing = false; + } } void OpenXRInterface::pre_render() { @@ -1315,8 +1321,8 @@ void OpenXRInterface::on_state_exiting() { emit_signal(SNAME("instance_exiting")); } -void OpenXRInterface::on_pose_recentered() { - emit_signal(SNAME("pose_recentered")); +void OpenXRInterface::on_reference_space_change_pending() { + reference_stage_changing = true; } void OpenXRInterface::on_refresh_rate_changes(float p_new_rate) { diff --git a/modules/openxr/openxr_interface.h b/modules/openxr/openxr_interface.h index f0ee0dc3c4..d1bf2aaf78 100644 --- a/modules/openxr/openxr_interface.h +++ b/modules/openxr/openxr_interface.h @@ -70,6 +70,7 @@ class OpenXRInterface : public XRInterface { private: OpenXRAPI *openxr_api = nullptr; bool initialized = false; + bool reference_stage_changing = false; XRInterface::TrackingStatus tracking_state; // At a minimum we need a tracker for our head @@ -207,7 +208,7 @@ public: void on_state_stopping(); void on_state_loss_pending(); void on_state_exiting(); - void on_pose_recentered(); + void on_reference_space_change_pending(); void on_refresh_rate_changes(float p_new_rate); void tracker_profile_changed(RID p_tracker, RID p_interaction_profile); diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index b9d493b844..1f7d5504b6 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -53,7 +53,7 @@ void ImageLoaderSVG::_replace_color_property(const HashMap<Color, Color> &p_colo int pos = r_string.find(p_prefix); while (pos != -1) { pos += prefix_len; // Skip prefix. - int end_pos = r_string.find("\"", pos); + int end_pos = r_string.find_char('"', pos); ERR_FAIL_COND_MSG(end_pos == -1, vformat("Malformed SVG string after property \"%s\".", p_prefix)); const String color_code = r_string.substr(pos, end_pos - pos); if (color_code != "none" && !color_code.begins_with("url(")) { diff --git a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml index 0978e1fcee..b2e1cb345b 100644 --- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml +++ b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml @@ -60,7 +60,7 @@ <member name="inbound_buffer_size" type="int" setter="set_inbound_buffer_size" getter="get_inbound_buffer_size" default="65535"> The inbound buffer size for connected peers. See [member WebSocketPeer.inbound_buffer_size] for more details. </member> - <member name="max_queued_packets" type="int" setter="set_max_queued_packets" getter="get_max_queued_packets" default="2048"> + <member name="max_queued_packets" type="int" setter="set_max_queued_packets" getter="get_max_queued_packets" default="4096"> The maximum number of queued packets for connected peers. See [member WebSocketPeer.max_queued_packets] for more details. </member> <member name="outbound_buffer_size" type="int" setter="set_outbound_buffer_size" getter="get_outbound_buffer_size" default="65535"> diff --git a/modules/websocket/doc_classes/WebSocketPeer.xml b/modules/websocket/doc_classes/WebSocketPeer.xml index 59a2e2ac1a..d329e21b88 100644 --- a/modules/websocket/doc_classes/WebSocketPeer.xml +++ b/modules/websocket/doc_classes/WebSocketPeer.xml @@ -162,7 +162,7 @@ <member name="inbound_buffer_size" type="int" setter="set_inbound_buffer_size" getter="get_inbound_buffer_size" default="65535"> The size of the input buffer in bytes (roughly the maximum amount of memory that will be allocated for the inbound packets). </member> - <member name="max_queued_packets" type="int" setter="set_max_queued_packets" getter="get_max_queued_packets" default="2048"> + <member name="max_queued_packets" type="int" setter="set_max_queued_packets" getter="get_max_queued_packets" default="4096"> The maximum amount of packets that will be allowed in the queues (both inbound and outbound). </member> <member name="outbound_buffer_size" type="int" setter="set_outbound_buffer_size" getter="get_outbound_buffer_size" default="65535"> diff --git a/modules/websocket/packet_buffer.h b/modules/websocket/packet_buffer.h index f98ee12ef9..4ab0579912 100644 --- a/modules/websocket/packet_buffer.h +++ b/modules/websocket/packet_buffer.h @@ -104,6 +104,14 @@ public: return _queued; } + int payload_space_left() const { + return _payload.space_left(); + } + + int packets_space_left() const { + return _packets.size() - _queued; + } + void clear() { _payload.resize(0); _packets.resize(0); diff --git a/modules/websocket/websocket_peer.h b/modules/websocket/websocket_peer.h index 3696e787e1..4854122471 100644 --- a/modules/websocket/websocket_peer.h +++ b/modules/websocket/websocket_peer.h @@ -71,7 +71,7 @@ protected: int outbound_buffer_size = DEFAULT_BUFFER_SIZE; int inbound_buffer_size = DEFAULT_BUFFER_SIZE; - int max_queued_packets = 2048; + int max_queued_packets = 4096; uint64_t heartbeat_interval_msec = 0; public: diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp index b624da09e8..81e5673583 100644 --- a/modules/websocket/wsl_peer.cpp +++ b/modules/websocket/wsl_peer.cpp @@ -295,6 +295,7 @@ Error WSLPeer::_do_server_handshake() { resolver.stop(); // Response sent, initialize wslay context. wslay_event_context_server_init(&wsl_ctx, &_wsl_callbacks, this); + wslay_event_config_set_no_buffering(wsl_ctx, 1); wslay_event_config_set_max_recv_msg_length(wsl_ctx, inbound_buffer_size); in_buffer.resize(nearest_shift(inbound_buffer_size), max_queued_packets); packet_buffer.resize(inbound_buffer_size); @@ -403,6 +404,7 @@ void WSLPeer::_do_client_handshake() { ERR_FAIL_MSG("Invalid response headers."); } wslay_event_context_client_init(&wsl_ctx, &_wsl_callbacks, this); + wslay_event_config_set_no_buffering(wsl_ctx, 1); wslay_event_config_set_max_recv_msg_length(wsl_ctx, inbound_buffer_size); in_buffer.resize(nearest_shift(inbound_buffer_size), max_queued_packets); packet_buffer.resize(inbound_buffer_size); @@ -568,8 +570,15 @@ ssize_t WSLPeer::_wsl_recv_callback(wslay_event_context_ptr ctx, uint8_t *data, wslay_event_set_error(ctx, WSLAY_ERR_CALLBACK_FAILURE); return -1; } + // Make sure we don't read more than what our buffer can hold. + size_t buffer_limit = MIN(peer->in_buffer.payload_space_left(), peer->in_buffer.packets_space_left() * 2); // The minimum size of a websocket message is 2 bytes. + size_t to_read = MIN(len, buffer_limit); + if (to_read == 0) { + wslay_event_set_error(ctx, WSLAY_ERR_WOULDBLOCK); + return -1; + } int read = 0; - Error err = conn->get_partial_data(data, len, read); + Error err = conn->get_partial_data(data, to_read, read); if (err != OK) { print_verbose("Websocket get data error: " + itos(err) + ", read (should be 0!): " + itos(read)); wslay_event_set_error(ctx, WSLAY_ERR_CALLBACK_FAILURE); @@ -582,6 +591,37 @@ ssize_t WSLPeer::_wsl_recv_callback(wslay_event_context_ptr ctx, uint8_t *data, return read; } +void WSLPeer::_wsl_recv_start_callback(wslay_event_context_ptr ctx, const struct wslay_event_on_frame_recv_start_arg *arg, void *user_data) { + WSLPeer *peer = (WSLPeer *)user_data; + uint8_t op = arg->opcode; + if (op == WSLAY_TEXT_FRAME || op == WSLAY_BINARY_FRAME) { + // Get ready to process a data package. + PendingMessage &pm = peer->pending_message; + pm.opcode = op; + pm.payload_size = arg->payload_length; + } +} + +void WSLPeer::_wsl_frame_recv_chunk_callback(wslay_event_context_ptr ctx, const struct wslay_event_on_frame_recv_chunk_arg *arg, void *user_data) { + WSLPeer *peer = (WSLPeer *)user_data; + PendingMessage &pm = peer->pending_message; + if (pm.opcode != 0) { + // Only write the payload. + peer->in_buffer.write_packet(arg->data, arg->data_length, nullptr); + } +} + +void WSLPeer::_wsl_frame_recv_end_callback(wslay_event_context_ptr ctx, void *user_data) { + WSLPeer *peer = (WSLPeer *)user_data; + PendingMessage &pm = peer->pending_message; + if (pm.opcode != 0) { + // Only write the packet (since it's now completed). + uint8_t is_string = pm.opcode == WSLAY_TEXT_FRAME ? 1 : 0; + peer->in_buffer.write_packet(nullptr, pm.payload_size, &is_string); + pm.clear(); + } +} + ssize_t WSLPeer::_wsl_send_callback(wslay_event_context_ptr ctx, const uint8_t *data, size_t len, int flags, void *user_data) { WSLPeer *peer = (WSLPeer *)user_data; Ref<StreamPeer> conn = peer->connection; @@ -627,28 +667,19 @@ void WSLPeer::_wsl_msg_recv_callback(wslay_event_context_ptr ctx, const struct w return; } - if (peer->ready_state == STATE_CLOSING) { - return; - } - - if (op == WSLAY_TEXT_FRAME || op == WSLAY_BINARY_FRAME) { - // Message. - uint8_t is_string = arg->opcode == WSLAY_TEXT_FRAME ? 1 : 0; - peer->in_buffer.write_packet(arg->msg, arg->msg_length, &is_string); - } if (op == WSLAY_PONG) { peer->heartbeat_waiting = false; } - // Pong. + // Ping, or message (already parsed in chunks). } wslay_event_callbacks WSLPeer::_wsl_callbacks = { _wsl_recv_callback, _wsl_send_callback, _wsl_genmask_callback, - nullptr, /* on_frame_recv_start_callback */ - nullptr, /* on_frame_recv_callback */ - nullptr, /* on_frame_recv_end_callback */ + _wsl_recv_start_callback, + _wsl_frame_recv_chunk_callback, + _wsl_frame_recv_end_callback, _wsl_msg_recv_callback }; @@ -836,6 +867,7 @@ void WSLPeer::close(int p_code, String p_reason) { heartbeat_waiting = false; in_buffer.clear(); packet_buffer.resize(0); + pending_message.clear(); } IPAddress WSLPeer::get_connected_host() const { diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h index 07bd850607..45cca48224 100644 --- a/modules/websocket/wsl_peer.h +++ b/modules/websocket/wsl_peer.h @@ -53,6 +53,10 @@ private: // Callbacks. static ssize_t _wsl_recv_callback(wslay_event_context_ptr ctx, uint8_t *data, size_t len, int flags, void *user_data); + static void _wsl_recv_start_callback(wslay_event_context_ptr ctx, const struct wslay_event_on_frame_recv_start_arg *arg, void *user_data); + static void _wsl_frame_recv_chunk_callback(wslay_event_context_ptr ctx, const struct wslay_event_on_frame_recv_chunk_arg *arg, void *user_data); + static void _wsl_frame_recv_end_callback(wslay_event_context_ptr ctx, void *user_data); + static ssize_t _wsl_send_callback(wslay_event_context_ptr ctx, const uint8_t *data, size_t len, int flags, void *user_data); static int _wsl_genmask_callback(wslay_event_context_ptr ctx, uint8_t *buf, size_t len, void *user_data); static void _wsl_msg_recv_callback(wslay_event_context_ptr ctx, const struct wslay_event_on_msg_recv_arg *arg, void *user_data); @@ -80,6 +84,16 @@ private: Resolver() {} }; + struct PendingMessage { + size_t payload_size = 0; + uint8_t opcode = 0; + + void clear() { + payload_size = 0; + opcode = 0; + } + }; + Resolver resolver; // WebSocket connection state. @@ -101,6 +115,7 @@ private: uint8_t was_string = 0; uint64_t last_heartbeat = 0; bool heartbeat_waiting = false; + PendingMessage pending_message; // WebSocket configuration. bool use_tls = true; diff --git a/platform/android/doc_classes/EditorExportPlatformAndroid.xml b/platform/android/doc_classes/EditorExportPlatformAndroid.xml index 8c8bca2b7c..983683fd78 100644 --- a/platform/android/doc_classes/EditorExportPlatformAndroid.xml +++ b/platform/android/doc_classes/EditorExportPlatformAndroid.xml @@ -151,6 +151,9 @@ <member name="permissions/access_location_extra_commands" type="bool" setter="" getter=""> Allows access to the extra location provider commands. See [url=https://developer.android.com/reference/android/Manifest.permission#ACCESS_LOCATION_EXTRA_COMMANDS]ACCESS_LOCATION_EXTRA_COMMANDS[/url]. </member> + <member name="permissions/access_media_location" type="bool" setter="" getter=""> + Allows an application to access any geographic locations persisted in the user's shared collection. See [url=https://developer.android.com/reference/android/Manifest.permission#ACCESS_MEDIA_LOCATION]ACCESS_MEDIA_LOCATION[/url]. + </member> <member name="permissions/access_mock_location" type="bool" setter="" getter=""> Allows an application to create mock location providers for testing. </member> @@ -412,6 +415,18 @@ <member name="permissions/read_logs" type="bool" setter="" getter=""> Allows an application to read the low-level system log files. See [url=https://developer.android.com/reference/android/Manifest.permission#READ_LOGS]READ_LOGS[/url]. </member> + <member name="permissions/read_media_audio" type="bool" setter="" getter=""> + Allows an application to read audio files from external storage. See [url=https://developer.android.com/reference/android/Manifest.permission#READ_MEDIA_AUDIO]READ_MEDIA_AUDIO[/url]. + </member> + <member name="permissions/read_media_images" type="bool" setter="" getter=""> + Allows an application to read image files from external storage. See [url=https://developer.android.com/reference/android/Manifest.permission#READ_MEDIA_IMAGES]READ_MEDIA_IMAGES[/url]. + </member> + <member name="permissions/read_media_video" type="bool" setter="" getter=""> + Allows an application to read video files from external storage. See [url=https://developer.android.com/reference/android/Manifest.permission#READ_MEDIA_VIDEO]READ_MEDIA_VIDEO[/url]. + </member> + <member name="permissions/read_media_visual_user_selected" type="bool" setter="" getter=""> + Allows an application to read image or video files from external storage that a user has selected via the permission prompt photo picker. See [url=https://developer.android.com/reference/android/Manifest.permission#READ_MEDIA_VISUAL_USER_SELECTED]READ_MEDIA_VISUAL_USER_SELECTED[/url]. + </member> <member name="permissions/read_phone_state" type="bool" setter="" getter=""> Allows read only access to phone state. See [url=https://developer.android.com/reference/android/Manifest.permission#READ_PHONE_STATE]READ_PHONE_STATE[/url]. </member> diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index d2b64c74a4..dc7a287a91 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -37,6 +37,8 @@ #include "editor/editor_settings.h" #include "editor/export/editor_export.h" +String get_default_android_sdk_path(); + void register_android_exporter_types() { GDREGISTER_VIRTUAL_CLASS(EditorExportPlatformAndroid); } @@ -54,8 +56,10 @@ void register_android_exporter() { #else EDITOR_DEF_BASIC("export/android/java_sdk_path", OS::get_singleton()->get_environment("JAVA_HOME")); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/java_sdk_path", PROPERTY_HINT_GLOBAL_DIR)); - EDITOR_DEF_BASIC("export/android/android_sdk_path", OS::get_singleton()->get_environment("ANDROID_HOME")); + + EDITOR_DEF_BASIC("export/android/android_sdk_path", OS::get_singleton()->has_environment("ANDROID_HOME") ? OS::get_singleton()->get_environment("ANDROID_HOME") : get_default_android_sdk_path()); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/android_sdk_path", PROPERTY_HINT_GLOBAL_DIR)); + EDITOR_DEF("export/android/force_system_user", false); EDITOR_DEF("export/android/shutdown_adb_on_exit", true); @@ -69,3 +73,15 @@ void register_android_exporter() { Ref<EditorExportPlatformAndroid> exporter = Ref<EditorExportPlatformAndroid>(memnew(EditorExportPlatformAndroid)); EditorExport::get_singleton()->add_export_platform(exporter); } + +inline String get_default_android_sdk_path() { +#ifdef WINDOWS_ENABLED + return OS::get_singleton()->get_environment("LOCALAPPDATA").path_join("Android/Sdk"); +#elif LINUXBSD_ENABLED + return OS::get_singleton()->get_environment("HOME").path_join("Android/Sdk"); +#elif MACOS_ENABLED + return OS::get_singleton()->get_environment("HOME").path_join("Library/Android/sdk"); +#else + return String(); +#endif +} diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index b41122e0f1..0b506e60d6 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -68,6 +68,7 @@ static const char *android_perms[] = { "ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION", "ACCESS_LOCATION_EXTRA_COMMANDS", + "ACCESS_MEDIA_LOCATION", "ACCESS_MOCK_LOCATION", "ACCESS_NETWORK_STATE", "ACCESS_SURFACE_FLINGER", @@ -155,6 +156,10 @@ static const char *android_perms[] = { "READ_HISTORY_BOOKMARKS", "READ_INPUT_STATE", "READ_LOGS", + "READ_MEDIA_AUDIO", + "READ_MEDIA_IMAGES", + "READ_MEDIA_VIDEO", + "READ_MEDIA_VISUAL_USER_SELECTED", "READ_PHONE_STATE", "READ_PROFILE", "READ_SMS", @@ -783,7 +788,7 @@ Error EditorExportPlatformAndroid::save_apk_so(void *p_userdata, const SharedObj return OK; } -Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) { +Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) { APKExportData *ed = static_cast<APKExportData *>(p_userdata); String dst_path = p_path.replace_first("res://", "assets/"); @@ -791,7 +796,7 @@ Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata, const String return OK; } -Error EditorExportPlatformAndroid::ignore_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) { +Error EditorExportPlatformAndroid::ignore_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) { return OK; } @@ -1559,7 +1564,7 @@ void EditorExportPlatformAndroid::_fix_resources(const Ref<EditorExportPreset> & str = get_project_name(package_name); } else { - String lang = str.substr(str.rfind("-") + 1, str.length()).replace("-", "_"); + String lang = str.substr(str.rfind_char('-') + 1, str.length()).replace("-", "_"); if (appnames.has(lang)) { str = appnames[lang]; } else { diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h index 15e80f824d..23b6f9b193 100644 --- a/platform/android/export/export_plugin.h +++ b/platform/android/export/export_plugin.h @@ -142,9 +142,9 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { static Error save_apk_so(void *p_userdata, const SharedObject &p_so); - static Error save_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); + static Error save_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed); - static Error ignore_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); + static Error ignore_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed); static Error copy_gradle_so(void *p_userdata, const SharedObject &p_so); @@ -186,7 +186,7 @@ protected: void _notification(int p_what); public: - typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); + typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed); virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const override; diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp index b2aed9a0dc..3603565805 100644 --- a/platform/android/export/gradle_export_util.cpp +++ b/platform/android/export/gradle_export_util.cpp @@ -169,7 +169,7 @@ Error store_string_at_path(const String &p_path, const String &p_data) { // It is used by the export_project_files method to save all the asset files into the gradle project. // It's functionality mirrors that of the method save_apk_file. // This method will be called ONLY when gradle build is enabled. -Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) { +Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) { CustomExportData *export_data = static_cast<CustomExportData *>(p_userdata); String dst_path = p_path.replace_first("res://", export_data->assets_directory + "/"); print_verbose("Saving project files from " + p_path + " into " + dst_path); diff --git a/platform/android/export/gradle_export_util.h b/platform/android/export/gradle_export_util.h index a17fdf0e27..a528fd5211 100644 --- a/platform/android/export/gradle_export_util.h +++ b/platform/android/export/gradle_export_util.h @@ -93,7 +93,7 @@ Error store_string_at_path(const String &p_path, const String &p_data); // It is used by the export_project_files method to save all the asset files into the gradle project. // It's functionality mirrors that of the method save_apk_file. // This method will be called ONLY when gradle build is enabled. -Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); +Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed); // Creates strings.xml files inside the gradle project for different locales. Error _create_project_name_strings_files(const Ref<EditorExportPreset> &p_preset, const String &project_name, const String &p_gradle_build_dir); diff --git a/platform/android/java/editor/build.gradle b/platform/android/java/editor/build.gradle index 45222ca3b0..276d74b75b 100644 --- a/platform/android/java/editor/build.gradle +++ b/platform/android/java/editor/build.gradle @@ -173,7 +173,7 @@ dependencies { implementation "androidx.window:window:1.3.0" implementation "androidx.core:core-splashscreen:$versions.splashscreenVersion" implementation "androidx.constraintlayout:constraintlayout:2.1.4" - implementation "org.bouncycastle:bcprov-jdk15to18:1.77" + implementation "org.bouncycastle:bcprov-jdk15to18:1.78" // Meta dependencies horizonosImplementation "org.godotengine:godot-openxr-vendors-meta:3.0.0-stable" diff --git a/platform/android/java/lib/build.gradle b/platform/android/java/lib/build.gradle index f6aee434e5..f273105efc 100644 --- a/platform/android/java/lib/build.gradle +++ b/platform/android/java/lib/build.gradle @@ -106,8 +106,8 @@ android { boolean devBuild = buildType == "dev" boolean debugSymbols = devBuild boolean runTests = devBuild - boolean productionBuild = !devBuild boolean storeRelease = buildType == "release" + boolean productionBuild = storeRelease def sconsTarget = flavorName if (sconsTarget == "template") { diff --git a/platform/android/net_socket_android.cpp b/platform/android/net_socket_android.cpp index 8f0ee51fac..9ab7d6a04f 100644 --- a/platform/android/net_socket_android.cpp +++ b/platform/android/net_socket_android.cpp @@ -84,7 +84,7 @@ NetSocketAndroid::~NetSocketAndroid() { } void NetSocketAndroid::close() { - NetSocketPosix::close(); + NetSocketUnix::close(); if (wants_broadcast) { multicast_lock_release(); } @@ -96,7 +96,7 @@ void NetSocketAndroid::close() { } Error NetSocketAndroid::set_broadcasting_enabled(bool p_enabled) { - Error err = NetSocketPosix::set_broadcasting_enabled(p_enabled); + Error err = NetSocketUnix::set_broadcasting_enabled(p_enabled); if (err != OK) { return err; } @@ -115,7 +115,7 @@ Error NetSocketAndroid::set_broadcasting_enabled(bool p_enabled) { } Error NetSocketAndroid::join_multicast_group(const IPAddress &p_multi_address, const String &p_if_name) { - Error err = NetSocketPosix::join_multicast_group(p_multi_address, p_if_name); + Error err = NetSocketUnix::join_multicast_group(p_multi_address, p_if_name); if (err != OK) { return err; } @@ -129,7 +129,7 @@ Error NetSocketAndroid::join_multicast_group(const IPAddress &p_multi_address, c } Error NetSocketAndroid::leave_multicast_group(const IPAddress &p_multi_address, const String &p_if_name) { - Error err = NetSocketPosix::leave_multicast_group(p_multi_address, p_if_name); + Error err = NetSocketUnix::leave_multicast_group(p_multi_address, p_if_name); if (err != OK) { return err; } diff --git a/platform/android/net_socket_android.h b/platform/android/net_socket_android.h index 452553ab1c..c33146d2d8 100644 --- a/platform/android/net_socket_android.h +++ b/platform/android/net_socket_android.h @@ -44,7 +44,7 @@ * the lock when broadcasting is enabled/disabled on a socket, or that socket * joins/leaves a multicast group. */ -class NetSocketAndroid : public NetSocketPosix { +class NetSocketAndroid : public NetSocketUnix { private: static jobject net_utils; static jclass cls; diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py index 2fd573da75..c8202b147d 100644 --- a/platform/linuxbsd/detect.py +++ b/platform/linuxbsd/detect.py @@ -279,16 +279,18 @@ def configure(env: "SConsEnvironment"): env.ParseConfig("pkg-config libwebp --cflags --libs") if not env["builtin_mbedtls"]: - # mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228 - env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"]) + # mbedTLS only provides a pkgconfig file since 3.6.0, but we still support 2.28.x, + # so fallback to manually specifying LIBS if it fails. + if os.system("pkg-config --exists mbedtls") == 0: # 0 means found + env.ParseConfig("pkg-config mbedtls mbedcrypto mbedx509 --cflags --libs") + else: + env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"]) if not env["builtin_wslay"]: env.ParseConfig("pkg-config libwslay --cflags --libs") if not env["builtin_miniupnpc"]: - # No pkgconfig file so far, hardcode default paths. - env.Prepend(CPPPATH=["/usr/include/miniupnpc"]) - env.Append(LIBS=["miniupnpc"]) + env.ParseConfig("pkg-config miniupnpc --cflags --libs") # On Linux wchar_t should be 32-bits # 16-bit library shouldn't be required due to compiler optimizations diff --git a/platform/linuxbsd/freedesktop_portal_desktop.cpp b/platform/linuxbsd/freedesktop_portal_desktop.cpp index 94a748e414..63eed41cd3 100644 --- a/platform/linuxbsd/freedesktop_portal_desktop.cpp +++ b/platform/linuxbsd/freedesktop_portal_desktop.cpp @@ -394,7 +394,7 @@ Error FreeDesktopPortalDesktop::file_dialog_show(DisplayServer::WindowID p_windo } else { if (flt == "*.*") { filter_exts.push_back("*"); - filter_names.push_back(RTR("All Files")); + filter_names.push_back(RTR("All Files") + " (*)"); } else { filter_exts.push_back(flt); filter_names.push_back(flt); @@ -405,7 +405,7 @@ Error FreeDesktopPortalDesktop::file_dialog_show(DisplayServer::WindowID p_windo } if (filter_names.is_empty()) { filter_exts.push_back("*"); - filter_names.push_back(RTR("All Files")); + filter_names.push_back(RTR("All Files") + " (*)"); } DBusError err; diff --git a/platform/linuxbsd/wayland/wayland_thread.cpp b/platform/linuxbsd/wayland/wayland_thread.cpp index e066e78e5b..d8d58ba54b 100644 --- a/platform/linuxbsd/wayland/wayland_thread.cpp +++ b/platform/linuxbsd/wayland/wayland_thread.cpp @@ -3988,10 +3988,10 @@ void WaylandThread::selection_set_text(const String &p_text) { wl_data_source_add_listener(ss->wl_data_source_selection, &wl_data_source_listener, ss); wl_data_source_offer(ss->wl_data_source_selection, "text/plain;charset=utf-8"); wl_data_source_offer(ss->wl_data_source_selection, "text/plain"); - } - // TODO: Implement a good way of getting the latest serial from the user. - wl_data_device_set_selection(ss->wl_data_device, ss->wl_data_source_selection, MAX(ss->pointer_data.button_serial, ss->last_key_pressed_serial)); + // TODO: Implement a good way of getting the latest serial from the user. + wl_data_device_set_selection(ss->wl_data_device, ss->wl_data_source_selection, MAX(ss->pointer_data.button_serial, ss->last_key_pressed_serial)); + } // Wait for the message to get to the server before continuing, otherwise the // clipboard update might come with a delay. diff --git a/platform/macos/detect.py b/platform/macos/detect.py index cab91fd33c..3575e93c68 100644 --- a/platform/macos/detect.py +++ b/platform/macos/detect.py @@ -2,7 +2,7 @@ import os import sys from typing import TYPE_CHECKING -from methods import detect_darwin_sdk_path, get_compiler_version, is_vanilla_clang, print_error, print_warning +from methods import detect_darwin_sdk_path, get_compiler_version, is_apple_clang, print_error, print_warning from platform_methods import detect_arch, detect_mvk, validate_arch if TYPE_CHECKING: @@ -101,10 +101,9 @@ def configure(env: "SConsEnvironment"): cc_version = get_compiler_version(env) cc_version_major = cc_version["apple_major"] cc_version_minor = cc_version["apple_minor"] - vanilla = is_vanilla_clang(env) # Workaround for Xcode 15 linker bug. - if not vanilla and cc_version_major == 1500 and cc_version_minor == 0: + if is_apple_clang(env) and cc_version_major == 1500 and cc_version_minor == 0: env.Prepend(LINKFLAGS=["-ld_classic"]) env.Append(CCFLAGS=["-fobjc-arc"]) diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index bf5645d9a6..b9f9d8d613 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -970,7 +970,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres return Error::FAILED; } else { print_verbose("rcodesign (" + p_path + "):\n" + str); - int next_nl = str.find("\n", rq_offset); + int next_nl = str.find_char('\n', rq_offset); String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 23, -1) : str.substr(rq_offset + 23, next_nl - rq_offset - 23); add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid)); add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour.")); @@ -1054,7 +1054,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres return Error::FAILED; } else { print_verbose("notarytool (" + p_path + "):\n" + str); - int next_nl = str.find("\n", rq_offset); + int next_nl = str.find_char('\n', rq_offset); String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 4, -1) : str.substr(rq_offset + 4, next_nl - rq_offset - 4); add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid)); add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour.")); diff --git a/platform/macos/godot_open_save_delegate.mm b/platform/macos/godot_open_save_delegate.mm index 6ffd939545..0d6bfa0c53 100644 --- a/platform/macos/godot_open_save_delegate.mm +++ b/platform/macos/godot_open_save_delegate.mm @@ -130,7 +130,7 @@ } if ([type_filters count] > 0) { - NSString *name_str = [NSString stringWithUTF8String:((tokens.size() == 1) ? tokens[0] : vformat("%s (%s)", tokens[1].strip_edges(), tokens[0].strip_edges())).utf8().get_data()]; + NSString *name_str = [NSString stringWithUTF8String:((tokens.size() == 1) ? tokens[0] : tokens[1].strip_edges()).utf8().get_data()]; [new_allowed_types addObject:type_filters]; [popup addItemWithTitle:name_str]; } diff --git a/platform/web/api/web_tools_editor_plugin.cpp b/platform/web/api/web_tools_editor_plugin.cpp index d39773bde2..61801372ba 100644 --- a/platform/web/api/web_tools_editor_plugin.cpp +++ b/platform/web/api/web_tools_editor_plugin.cpp @@ -80,7 +80,7 @@ void WebToolsEditorPlugin::_download_zip() { 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("/")) + "/"; + const String base_path = resource_path.substr(0, resource_path.rfind_char('/')) + "/"; _zip_recursive(resource_path, base_path, zip); zipClose(zip, nullptr); { diff --git a/platform/web/detect.py b/platform/web/detect.py index 26bbbccffa..25a5bbe5a5 100644 --- a/platform/web/detect.py +++ b/platform/web/detect.py @@ -201,7 +201,7 @@ def configure(env: "SConsEnvironment"): sys.exit(255) env.Prepend(CPPPATH=["#platform/web"]) - env.Append(CPPDEFINES=["WEB_ENABLED", "UNIX_ENABLED"]) + env.Append(CPPDEFINES=["WEB_ENABLED", "UNIX_ENABLED", "UNIX_SOCKET_UNAVAILABLE"]) if env["opengl3"]: env.AppendUnique(CPPDEFINES=["GLES3_ENABLED"]) diff --git a/platform/web/package-lock.json b/platform/web/package-lock.json index a2e0fd3b27..7947fb96e4 100644 --- a/platform/web/package-lock.json +++ b/platform/web/package-lock.json @@ -9,14 +9,14 @@ "version": "1.0.0", "license": "MIT", "devDependencies": { - "@eslint/js": "^9.3.0", - "@html-eslint/eslint-plugin": "^0.24.1", - "@html-eslint/parser": "^0.24.1", - "@stylistic/eslint-plugin": "^2.1.0", - "eslint": "^9.3.0", + "@eslint/js": "^9.12.0", + "@html-eslint/eslint-plugin": "^0.27.0", + "@html-eslint/parser": "^0.27.0", + "@stylistic/eslint-plugin": "^2.9.0", + "eslint": "^9.12.0", "eslint-plugin-html": "^8.1.1", "espree": "^10.0.1", - "globals": "^15.3.0", + "globals": "^15.9.0", "jsdoc": "^4.0.3" } }, @@ -60,14 +60,40 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.10.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", - "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", "dev": true, + "license": "MIT", "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, + "node_modules/@eslint/config-array": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", + "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.4", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/core": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.6.0.tgz", + "integrity": "sha512-8I2Q8ykA4J0x0o7cg67FPVnehcqWTBehu/lmY+bolPFHGjh49YzGBMXTvpqVgEbBdvNCSxj6iFgiIyHzf03lzg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/@eslint/eslintrc": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", @@ -104,28 +130,54 @@ } }, "node_modules/@eslint/js": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.3.0.tgz", - "integrity": "sha512-niBqk8iwv96+yuTwjM6bWg8ovzAPF9qkICsGtcoa5/dmqcEMfdwNAX7+/OHcJHc7wj7XqPxH98oAHytFYlw6Sw==", + "version": "9.12.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.12.0.tgz", + "integrity": "sha512-eohesHH8WFRUprDNyEREgqP6beG6htMeUYeCpkEgBCieCMme5r9zFWjzAJp//9S+Kub4rqE+jXe9Cp1a7IYIIA==", "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", + "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.1.tgz", + "integrity": "sha512-HFZ4Mp26nbWk9d/BpvP0YNL6W4UoZF0VFcTw/aPPA8RpOxeFQgK+ClABGgAUXs9Y/RGX/l1vOmrqz1MQt9MNuw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "levn": "^0.4.1" + }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@html-eslint/eslint-plugin": { - "version": "0.24.1", - "resolved": "https://registry.npmjs.org/@html-eslint/eslint-plugin/-/eslint-plugin-0.24.1.tgz", - "integrity": "sha512-JwNDQBrNIWEPcxgSpla/2jaUXyQCqL7Xp8CmON4Bk5qg8MwiDLXOgjylfVC+tN52i8JeHWMca34I9DqBGRj9Qg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@html-eslint/eslint-plugin/-/eslint-plugin-0.27.0.tgz", + "integrity": "sha512-aAF14sgDKidMCCQpJ4kIhe+fwyAaAbvDlgVTIgd99F+HOWxokTTXDt39a3gewMBo76IeEHDaoizUDJQ/Vc7Mdg==", "dev": true, + "license": "MIT", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/@html-eslint/parser": { - "version": "0.24.1", - "resolved": "https://registry.npmjs.org/@html-eslint/parser/-/parser-0.24.1.tgz", - "integrity": "sha512-O13xX/+Ldh0P7VZMpDDYc3XtWiE1cYm5QhVJ0VB5i7D8Q69HrrGN+5BjS17vkCoLTz+3zWWIiJv4oFmyS5LReA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@html-eslint/parser/-/parser-0.27.0.tgz", + "integrity": "sha512-F/A1M0jnDAYoRvJiiSC7pIBD9DAsf4EhbndbvEi81aozD/wI8WWXON50xZPUaGHCI1C+2syTVifxDz8MvDKaQA==", "dev": true, + "license": "MIT", "dependencies": { "es-html-parser": "^0.0.9" }, @@ -133,18 +185,28 @@ "node": ">=8.10.0" } }, - "node_modules/@humanwhocodes/config-array": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", - "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", + "node_modules/@humanfs/core": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.0.tgz", + "integrity": "sha512-2cbWIHbZVEweE853g8jymffCA+NCMiuqeECeBBLm8dg2oFdjuGJhgN4UAbI+6v0CKbbhvtXA4qV8YR5Ji86nmw==", "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.5", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.5.tgz", + "integrity": "sha512-KSPA4umqSG4LHYRodq31VDwKAvaTF4xmVlzM8Aeh4PlU1JQ3IG0wiA8C25d3RQ9nJyM3mBHyI53K06VVL/oFFg==", + "dev": true, + "license": "Apache-2.0", "dependencies": { - "@humanwhocodes/object-schema": "^2.0.3", - "debug": "^4.3.1", - "minimatch": "^3.0.5" + "@humanfs/core": "^0.19.0", + "@humanwhocodes/retry": "^0.3.0" }, "engines": { - "node": ">=10.10.0" + "node": ">=18.18.0" } }, "node_modules/@humanwhocodes/module-importer": { @@ -160,17 +222,12 @@ "url": "https://github.com/sponsors/nzakas" } }, - "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", - "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", - "dev": true - }, "node_modules/@humanwhocodes/retry": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.0.tgz", - "integrity": "sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", + "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", "dev": true, + "license": "Apache-2.0", "engines": { "node": ">=18.18" }, @@ -227,50 +284,15 @@ } }, "node_modules/@stylistic/eslint-plugin": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-2.1.0.tgz", - "integrity": "sha512-cBBowKP2u/+uE5CzgH5w8pE9VKqcM7BXdIDPIbGt2rmLJGnA6MJPr9vYGaqgMoJFs7R/FzsMQerMvvEP40g2uw==", - "dev": true, - "dependencies": { - "@stylistic/eslint-plugin-js": "2.1.0", - "@stylistic/eslint-plugin-jsx": "2.1.0", - "@stylistic/eslint-plugin-plus": "2.1.0", - "@stylistic/eslint-plugin-ts": "2.1.0", - "@types/eslint": "^8.56.10" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "peerDependencies": { - "eslint": ">=8.40.0" - } - }, - "node_modules/@stylistic/eslint-plugin-js": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-2.1.0.tgz", - "integrity": "sha512-gdXUjGNSsnY6nPyqxu6lmDTtVrwCOjun4x8PUn0x04d5ucLI74N3MT1Q0UhdcOR9No3bo5PGDyBgXK+KmD787A==", - "dev": true, - "dependencies": { - "@types/eslint": "^8.56.10", - "acorn": "^8.11.3", - "eslint-visitor-keys": "^4.0.0", - "espree": "^10.0.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "peerDependencies": { - "eslint": ">=8.40.0" - } - }, - "node_modules/@stylistic/eslint-plugin-jsx": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-jsx/-/eslint-plugin-jsx-2.1.0.tgz", - "integrity": "sha512-mMD7S+IndZo2vxmwpHVTCwx2O1VdtE5tmpeNwgaEcXODzWV1WTWpnsc/PECQKIr/mkLPFWiSIqcuYNhQ/3l6AQ==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-2.9.0.tgz", + "integrity": "sha512-OrDyFAYjBT61122MIY1a3SfEgy3YCMgt2vL4eoPmvTwDBwyQhAXurxNQznlRD/jESNfYWfID8Ej+31LljvF7Xg==", "dev": true, + "license": "MIT", "dependencies": { - "@stylistic/eslint-plugin-js": "^2.1.0", - "@types/eslint": "^8.56.10", + "@typescript-eslint/utils": "^8.8.0", + "eslint-visitor-keys": "^4.1.0", + "espree": "^10.2.0", "estraverse": "^5.3.0", "picomatch": "^4.0.2" }, @@ -281,101 +303,19 @@ "eslint": ">=8.40.0" } }, - "node_modules/@stylistic/eslint-plugin-plus": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-plus/-/eslint-plugin-plus-2.1.0.tgz", - "integrity": "sha512-S5QAlgYXESJaSBFhBSBLZy9o36gXrXQwWSt6QkO+F0SrT9vpV5JF/VKoh+ojO7tHzd8Ckmyouq02TT9Sv2B0zQ==", - "dev": true, - "dependencies": { - "@types/eslint": "^8.56.10", - "@typescript-eslint/utils": "^7.8.0" - }, - "peerDependencies": { - "eslint": "*" - } - }, - "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/utils": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.10.0.tgz", - "integrity": "sha512-olzif1Fuo8R8m/qKkzJqT7qwy16CzPRWBvERS0uvyc+DHd8AKbO4Jb7kpAvVzMmZm8TrHnI7hvjN4I05zow+tg==", - "dev": true, - "dependencies": { - "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "7.10.0", - "@typescript-eslint/types": "7.10.0", - "@typescript-eslint/typescript-estree": "7.10.0" - }, - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.56.0" - } - }, - "node_modules/@stylistic/eslint-plugin-ts": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-ts/-/eslint-plugin-ts-2.1.0.tgz", - "integrity": "sha512-2ioFibufHYBALx2TBrU4KXovCkN8qCqcb9yIHc0fyOfTaO5jw4d56WW7YRcF3Zgde6qFyXwAN6z/+w4pnmos1g==", - "dev": true, - "dependencies": { - "@stylistic/eslint-plugin-js": "2.1.0", - "@types/eslint": "^8.56.10", - "@typescript-eslint/utils": "^7.8.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "peerDependencies": { - "eslint": ">=8.40.0" - } - }, - "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/utils": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.10.0.tgz", - "integrity": "sha512-olzif1Fuo8R8m/qKkzJqT7qwy16CzPRWBvERS0uvyc+DHd8AKbO4Jb7kpAvVzMmZm8TrHnI7hvjN4I05zow+tg==", - "dev": true, - "dependencies": { - "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "7.10.0", - "@typescript-eslint/types": "7.10.0", - "@typescript-eslint/typescript-estree": "7.10.0" - }, - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.56.0" - } - }, - "node_modules/@types/eslint": { - "version": "8.56.10", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.10.tgz", - "integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==", - "dev": true, - "dependencies": { - "@types/estree": "*", - "@types/json-schema": "*" - } - }, "node_modules/@types/estree": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", - "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", - "dev": true + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "dev": true, + "license": "MIT" }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/linkify-it": { "version": "5.0.0", @@ -400,16 +340,17 @@ "dev": true }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.10.0.tgz", - "integrity": "sha512-7L01/K8W/VGl7noe2mgH0K7BE29Sq6KAbVmxurj8GGaPDZXPr8EEQ2seOeAS+mEV9DnzxBQB6ax6qQQ5C6P4xg==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.11.0.tgz", + "integrity": "sha512-Uholz7tWhXmA4r6epo+vaeV7yjdKy5QFCERMjs1kMVsLRKIrSdM6o21W2He9ftp5PP6aWOVpD5zvrvuHZC0bMQ==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/types": "7.10.0", - "@typescript-eslint/visitor-keys": "7.10.0" + "@typescript-eslint/types": "8.11.0", + "@typescript-eslint/visitor-keys": "8.11.0" }, "engines": { - "node": "^18.18.0 || >=20.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "type": "opencollective", @@ -417,12 +358,13 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.10.0.tgz", - "integrity": "sha512-7fNj+Ya35aNyhuqrA1E/VayQX9Elwr8NKZ4WueClR3KwJ7Xx9jcCdOrLW04h51de/+gNbyFMs+IDxh5xIwfbNg==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.11.0.tgz", + "integrity": "sha512-tn6sNMHf6EBAYMvmPUaKaVeYvhUsrE6x+bXQTxjQRp360h1giATU0WvgeEys1spbvb5R+VpNOZ+XJmjD8wOUHw==", "dev": true, + "license": "MIT", "engines": { - "node": "^18.18.0 || >=20.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "type": "opencollective", @@ -430,22 +372,23 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.10.0.tgz", - "integrity": "sha512-LXFnQJjL9XIcxeVfqmNj60YhatpRLt6UhdlFwAkjNc6jSUlK8zQOl1oktAP8PlWFzPQC1jny/8Bai3/HPuvN5g==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.11.0.tgz", + "integrity": "sha512-yHC3s1z1RCHoCz5t06gf7jH24rr3vns08XXhfEqzYpd6Hll3z/3g23JRi0jM8A47UFKNc3u/y5KIMx8Ynbjohg==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/types": "7.10.0", - "@typescript-eslint/visitor-keys": "7.10.0", + "@typescript-eslint/types": "8.11.0", + "@typescript-eslint/visitor-keys": "8.11.0", "debug": "^4.3.4", - "globby": "^11.1.0", + "fast-glob": "^3.3.2", "is-glob": "^4.0.3", "minimatch": "^9.0.4", "semver": "^7.6.0", "ts-api-utils": "^1.3.0" }, "engines": { - "node": "^18.18.0 || >=20.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "type": "opencollective", @@ -462,15 +405,17 @@ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, + "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, + "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -481,17 +426,41 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/@typescript-eslint/utils": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.11.0.tgz", + "integrity": "sha512-CYiX6WZcbXNJV7UNB4PLDIBtSdRmRI/nb0FMyqHPTQD1rMjA0foPLaPUV39C/MxkTd/QKSeX+Gb34PPsDVC35g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.11.0", + "@typescript-eslint/types": "8.11.0", + "@typescript-eslint/typescript-estree": "8.11.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.10.0.tgz", - "integrity": "sha512-9ntIVgsi6gg6FIq9xjEO4VQJvwOqA3jaBFQJ/6TK5AvEup2+cECI6Fh7QiBxmfMHXU0V0J4RyPeOU1VDNzl9cg==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.11.0.tgz", + "integrity": "sha512-EaewX6lxSjRJnc+99+dqzTeoDZUfyrA52d2/HRrkI830kgovWsmIiTfmr0NZorzqic7ga+1bS60lRBUgR3n/Bw==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/types": "7.10.0", + "@typescript-eslint/types": "8.11.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { - "node": "^18.18.0 || >=20.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "type": "opencollective", @@ -503,6 +472,7 @@ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, + "license": "Apache-2.0", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -511,10 +481,11 @@ } }, "node_modules/acorn": { - "version": "8.11.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", - "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", "dev": true, + "license": "MIT", "bin": { "acorn": "bin/acorn" }, @@ -547,15 +518,6 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -577,15 +539,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "node_modules/array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -613,6 +566,7 @@ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, + "license": "MIT", "dependencies": { "fill-range": "^7.1.1" }, @@ -718,18 +672,6 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, - "node_modules/dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dev": true, - "dependencies": { - "path-type": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/dom-serializer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", @@ -816,28 +758,33 @@ } }, "node_modules/eslint": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.3.0.tgz", - "integrity": "sha512-5Iv4CsZW030lpUqHBapdPo3MJetAPtejVW8B84GIcIIv8+ohFaddXsrn1Gn8uD9ijDb+kcYKFUVmC8qG8B2ORQ==", + "version": "9.12.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.12.0.tgz", + "integrity": "sha512-UVIOlTEWxwIopRL1wgSQYdnVDcEvs2wyaO6DGo5mXqe3r16IoCNWkR29iHhyaP4cICWjbgbmFUGAhh0GJRuGZw==", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.6.1", + "@eslint-community/regexpp": "^4.11.0", + "@eslint/config-array": "^0.18.0", + "@eslint/core": "^0.6.0", "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "9.3.0", - "@humanwhocodes/config-array": "^0.13.0", + "@eslint/js": "9.12.0", + "@eslint/plugin-kit": "^0.2.0", + "@humanfs/node": "^0.16.5", "@humanwhocodes/module-importer": "^1.0.1", - "@humanwhocodes/retry": "^0.3.0", - "@nodelib/fs.walk": "^1.2.8", + "@humanwhocodes/retry": "^0.3.1", + "@types/estree": "^1.0.6", + "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^8.0.1", - "eslint-visitor-keys": "^4.0.0", - "espree": "^10.0.1", - "esquery": "^1.4.2", + "eslint-scope": "^8.1.0", + "eslint-visitor-keys": "^4.1.0", + "espree": "^10.2.0", + "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", @@ -846,14 +793,11 @@ "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3", - "strip-ansi": "^6.0.1", "text-table": "^0.2.0" }, "bin": { @@ -863,7 +807,15 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://opencollective.com/eslint" + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } } }, "node_modules/eslint-plugin-html": { @@ -879,10 +831,11 @@ } }, "node_modules/eslint-scope": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.1.tgz", - "integrity": "sha512-pL8XjgP4ZOmmwfFE8mEhSxA7ZY4C+LWyqjQ3o4yWkkmD0qcMT9kkW3zWHOczhWcjTSgqycYAgwSlXvZltv65og==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.1.0.tgz", + "integrity": "sha512-14dSvlhaVhKKsa9Fx1l8A17s7ah7Ef7wCakJ10LYk6+GYmP9yDti2oq2SEwcyndt6knfcZyhyxwY3i9yL78EQw==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" @@ -895,10 +848,11 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", - "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.1.0.tgz", + "integrity": "sha512-Q7lok0mqMUSf5a/AdAZkA5a/gHcO6snwQClVNNvFKCAVlxXucdU8pKydU5ZVZjBx5xr37vGbFFWtLQYreLzrZg==", "dev": true, + "license": "Apache-2.0", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, @@ -907,14 +861,15 @@ } }, "node_modules/espree": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.0.1.tgz", - "integrity": "sha512-MWkrWZbJsL2UwnjxTX3gG8FneachS/Mwg7tdGXce011sJd5b0JG54vat5KHnfSBODZ3Wvzd2WnjxyzsRoVv+ww==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.2.0.tgz", + "integrity": "sha512-upbkBJbckcCNBDBDXEbuhjbP68n+scUd3k/U2EkyM9nw+I/jPiL4cLF/Al06CF96wRltFda16sxDFrxsI1v0/g==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { - "acorn": "^8.11.3", + "acorn": "^8.12.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^4.0.0" + "eslint-visitor-keys": "^4.1.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -940,6 +895,7 @@ "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "estraverse": "^5.2.0" }, @@ -976,6 +932,7 @@ "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, + "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -992,6 +949,7 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, + "license": "ISC", "dependencies": { "is-glob": "^4.0.1" }, @@ -1037,6 +995,7 @@ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, + "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -1092,10 +1051,11 @@ } }, "node_modules/globals": { - "version": "15.3.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-15.3.0.tgz", - "integrity": "sha512-cCdyVjIUVTtX8ZsPkq1oCsOsLmGIswqnjZYMJJTGaNApj1yHtLSymKhwH51ttirREn75z3p4k051clwg7rvNKA==", + "version": "15.9.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.9.0.tgz", + "integrity": "sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA==", "dev": true, + "license": "MIT", "engines": { "node": ">=18" }, @@ -1103,26 +1063,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/globby": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", - "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", - "dev": true, - "dependencies": { - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.9", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -1217,19 +1157,11 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.12.0" } }, - "node_modules/is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -1430,15 +1362,17 @@ "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 8" } }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, + "license": "MIT", "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" @@ -1452,6 +1386,7 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true, + "license": "MIT", "engines": { "node": ">=8.6" }, @@ -1572,20 +1507,12 @@ "node": ">=8" } }, - "node_modules/path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/picomatch": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", "dev": true, + "license": "MIT", "engines": { "node": ">=12" }, @@ -1692,10 +1619,11 @@ } }, "node_modules/semver": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", - "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "dev": true, + "license": "ISC", "bin": { "semver": "bin/semver.js" }, @@ -1724,27 +1652,6 @@ "node": ">=8" } }, - "node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -1780,6 +1687,7 @@ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, + "license": "MIT", "dependencies": { "is-number": "^7.0.0" }, @@ -1792,6 +1700,7 @@ "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=16" }, @@ -1812,10 +1721,11 @@ } }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", "dev": true, + "license": "Apache-2.0", "peer": true, "bin": { "tsc": "bin/tsc", diff --git a/platform/web/package.json b/platform/web/package.json index 588af2ff3b..bf61eb184c 100644 --- a/platform/web/package.json +++ b/platform/web/package.json @@ -11,14 +11,14 @@ "format": "npm run lint -- --fix" }, "devDependencies": { - "@eslint/js": "^9.3.0", - "@html-eslint/eslint-plugin": "^0.24.1", - "@html-eslint/parser": "^0.24.1", - "@stylistic/eslint-plugin": "^2.1.0", - "eslint": "^9.3.0", + "@eslint/js": "^9.12.0", + "@html-eslint/eslint-plugin": "^0.27.0", + "@html-eslint/parser": "^0.27.0", + "@stylistic/eslint-plugin": "^2.9.0", + "eslint": "^9.12.0", "eslint-plugin-html": "^8.1.1", "espree": "^10.0.1", - "globals": "^15.3.0", + "globals": "^15.9.0", "jsdoc": "^4.0.3" } } diff --git a/platform/windows/SCsub b/platform/windows/SCsub index eaa5ceff88..1ddefb9c33 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -83,16 +83,6 @@ if env["windows_subsystem"] == "gui": env_wrap.Depends(prog_wrap, prog) sources += common_win_wrap + res_wrap_obj -# Microsoft Visual Studio Project Generation -if env["vsproj"]: - env.vs_srcs += ["platform/windows/" + res_file] - env.vs_srcs += ["platform/windows/godot.natvis"] - for x in common_win: - env.vs_srcs += ["platform/windows/" + str(x)] - if env["windows_subsystem"] == "gui": - for x in common_win_wrap: - env.vs_srcs += ["platform/windows/" + str(x)] - if env["d3d12"]: dxc_target_aliases = { "x86_32": "x86", diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index a6eab1bd29..467873ee7c 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -505,7 +505,7 @@ void DisplayServerWindows::_thread_fd_monitor(void *p_ud) { } if (filter_names.is_empty()) { filter_exts.push_back(String("*.*").utf16()); - filter_names.push_back(RTR("All Files").utf16()); + filter_names.push_back((RTR("All Files") + " (*)").utf16()); } Vector<COMDLG_FILTERSPEC> filters; @@ -4792,9 +4792,12 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA break; } - DisplayServer::WindowID receiving_window_id = _get_focused_window_or_popup(); - if (receiving_window_id == INVALID_WINDOW_ID) { - receiving_window_id = window_id; + DisplayServer::WindowID receiving_window_id = window_id; + if (mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED || mouse_mode == MOUSE_MODE_CONFINED_HIDDEN) { + receiving_window_id = _get_focused_window_or_popup(); + if (receiving_window_id == INVALID_WINDOW_ID) { + receiving_window_id = window_id; + } } const BitField<WinKeyModifierMask> &mods = _get_mods(); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 4d4a85e22a..416016b112 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -70,6 +70,7 @@ extern "C" { __declspec(dllexport) DWORD NvOptimusEnablement = 1; __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; +__declspec(dllexport) void NoHotPatch() {} // Disable Nahimic code injection. } // Workaround mingw-w64 < 4.0 bug @@ -157,6 +158,52 @@ void RedirectIOToConsole() { } } +bool OS_Windows::is_using_con_wrapper() const { + static String exe_renames[] = { + ".console.exe", + "_console.exe", + " console.exe", + "console.exe", + String(), + }; + + bool found_exe = false; + bool found_conwrap_exe = false; + String exe_name = get_executable_path().to_lower(); + String exe_dir = exe_name.get_base_dir(); + String exe_fname = exe_name.get_file().get_basename(); + + DWORD pids[256]; + DWORD count = GetConsoleProcessList(&pids[0], 256); + for (DWORD i = 0; i < count; i++) { + HANDLE process = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pids[i]); + if (process != NULL) { + WCHAR proc_name[MAX_PATH]; + DWORD len = MAX_PATH; + if (QueryFullProcessImageNameW(process, 0, &proc_name[0], &len)) { + String name = String::utf16((const char16_t *)&proc_name[0], len).replace("\\", "/").to_lower(); + if (name == exe_name) { + found_exe = true; + } + for (int j = 0; !exe_renames[j].is_empty(); j++) { + if (name == exe_dir.path_join(exe_fname + exe_renames[j])) { + found_conwrap_exe = true; + } + } + } + CloseHandle(process); + if (found_conwrap_exe && found_exe) { + break; + } + } + } + if (!found_exe) { + return true; // Unable to read console info, assume true. + } + + return found_conwrap_exe; +} + BOOL WINAPI HandlerRoutine(_In_ DWORD dwCtrlType) { if (!EngineDebugger::is_active()) { return FALSE; @@ -919,18 +966,10 @@ Dictionary OS_Windows::execute_with_pipe(const String &p_path, const List<String sa.lpSecurityDescriptor = nullptr; ERR_FAIL_COND_V(!CreatePipe(&pipe_in[0], &pipe_in[1], &sa, 0), ret); - if (!SetHandleInformation(pipe_in[1], HANDLE_FLAG_INHERIT, 0)) { - CLEAN_PIPES - ERR_FAIL_V(ret); - } if (!CreatePipe(&pipe_out[0], &pipe_out[1], &sa, 0)) { CLEAN_PIPES ERR_FAIL_V(ret); } - if (!SetHandleInformation(pipe_out[0], HANDLE_FLAG_INHERIT, 0)) { - CLEAN_PIPES - ERR_FAIL_V(ret); - } if (!CreatePipe(&pipe_err[0], &pipe_err[1], &sa, 0)) { CLEAN_PIPES ERR_FAIL_V(ret); @@ -940,16 +979,37 @@ Dictionary OS_Windows::execute_with_pipe(const String &p_path, const List<String // Create process. ProcessInfo pi; ZeroMemory(&pi.si, sizeof(pi.si)); - pi.si.cb = sizeof(pi.si); + pi.si.StartupInfo.cb = sizeof(pi.si); ZeroMemory(&pi.pi, sizeof(pi.pi)); - LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si; + LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si.StartupInfo; - pi.si.dwFlags |= STARTF_USESTDHANDLES; - pi.si.hStdInput = pipe_in[0]; - pi.si.hStdOutput = pipe_out[1]; - pi.si.hStdError = pipe_err[1]; + pi.si.StartupInfo.dwFlags |= STARTF_USESTDHANDLES; + pi.si.StartupInfo.hStdInput = pipe_in[0]; + pi.si.StartupInfo.hStdOutput = pipe_out[1]; + pi.si.StartupInfo.hStdError = pipe_err[1]; - DWORD creation_flags = NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW; + SIZE_T attr_list_size = 0; + InitializeProcThreadAttributeList(nullptr, 1, 0, &attr_list_size); + pi.si.lpAttributeList = (LPPROC_THREAD_ATTRIBUTE_LIST)alloca(attr_list_size); + if (!InitializeProcThreadAttributeList(pi.si.lpAttributeList, 1, 0, &attr_list_size)) { + CLEAN_PIPES + ERR_FAIL_V(ret); + } + HANDLE handles_to_inherit[] = { pipe_in[0], pipe_out[1], pipe_err[1] }; + if (!UpdateProcThreadAttribute( + pi.si.lpAttributeList, + 0, + PROC_THREAD_ATTRIBUTE_HANDLE_LIST, + handles_to_inherit, + sizeof(handles_to_inherit), + nullptr, + nullptr)) { + CLEAN_PIPES + DeleteProcThreadAttributeList(pi.si.lpAttributeList); + ERR_FAIL_V(ret); + } + + DWORD creation_flags = NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW | EXTENDED_STARTUPINFO_PRESENT; Char16String current_dir_name; size_t str_len = GetCurrentDirectoryW(0, nullptr); @@ -965,11 +1025,13 @@ Dictionary OS_Windows::execute_with_pipe(const String &p_path, const List<String if (!CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, true, creation_flags, nullptr, (LPWSTR)current_dir_name.ptr(), si_w, &pi.pi)) { CLEAN_PIPES + DeleteProcThreadAttributeList(pi.si.lpAttributeList); ERR_FAIL_V_MSG(ret, "Could not create child process: " + command); } CloseHandle(pipe_in[0]); CloseHandle(pipe_out[1]); CloseHandle(pipe_err[1]); + DeleteProcThreadAttributeList(pi.si.lpAttributeList); ProcessID pid = pi.pi.dwProcessId; process_map_mutex.lock(); @@ -1001,9 +1063,9 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, ProcessInfo pi; ZeroMemory(&pi.si, sizeof(pi.si)); - pi.si.cb = sizeof(pi.si); + pi.si.StartupInfo.cb = sizeof(pi.si); ZeroMemory(&pi.pi, sizeof(pi.pi)); - LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si; + LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si.StartupInfo; bool inherit_handles = false; HANDLE pipe[2] = { nullptr, nullptr }; @@ -1015,16 +1077,40 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, sa.lpSecurityDescriptor = nullptr; ERR_FAIL_COND_V(!CreatePipe(&pipe[0], &pipe[1], &sa, 0), ERR_CANT_FORK); - ERR_FAIL_COND_V(!SetHandleInformation(pipe[0], HANDLE_FLAG_INHERIT, 0), ERR_CANT_FORK); // Read handle is for host process only and should not be inherited. - pi.si.dwFlags |= STARTF_USESTDHANDLES; - pi.si.hStdOutput = pipe[1]; + pi.si.StartupInfo.dwFlags |= STARTF_USESTDHANDLES; + pi.si.StartupInfo.hStdOutput = pipe[1]; if (read_stderr) { - pi.si.hStdError = pipe[1]; + pi.si.StartupInfo.hStdError = pipe[1]; + } + + SIZE_T attr_list_size = 0; + InitializeProcThreadAttributeList(nullptr, 1, 0, &attr_list_size); + pi.si.lpAttributeList = (LPPROC_THREAD_ATTRIBUTE_LIST)alloca(attr_list_size); + if (!InitializeProcThreadAttributeList(pi.si.lpAttributeList, 1, 0, &attr_list_size)) { + CloseHandle(pipe[0]); // Cleanup pipe handles. + CloseHandle(pipe[1]); + ERR_FAIL_V(ERR_CANT_FORK); + } + if (!UpdateProcThreadAttribute( + pi.si.lpAttributeList, + 0, + PROC_THREAD_ATTRIBUTE_HANDLE_LIST, + &pipe[1], + sizeof(HANDLE), + nullptr, + nullptr)) { + CloseHandle(pipe[0]); // Cleanup pipe handles. + CloseHandle(pipe[1]); + DeleteProcThreadAttributeList(pi.si.lpAttributeList); + ERR_FAIL_V(ERR_CANT_FORK); } inherit_handles = true; } DWORD creation_flags = NORMAL_PRIORITY_CLASS; + if (inherit_handles) { + creation_flags |= EXTENDED_STARTUPINFO_PRESENT; + } if (p_open_console) { creation_flags |= CREATE_NEW_CONSOLE; } else { @@ -1047,6 +1133,7 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, if (!ret && r_pipe) { CloseHandle(pipe[0]); // Cleanup pipe handles. CloseHandle(pipe[1]); + DeleteProcThreadAttributeList(pi.si.lpAttributeList); } ERR_FAIL_COND_V_MSG(ret == 0, ERR_CANT_FORK, "Could not create child process: " + command); @@ -1102,6 +1189,9 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, CloseHandle(pi.pi.hProcess); CloseHandle(pi.pi.hThread); + if (r_pipe) { + DeleteProcThreadAttributeList(pi.si.lpAttributeList); + } return OK; } @@ -1115,9 +1205,9 @@ Error OS_Windows::create_process(const String &p_path, const List<String> &p_arg ProcessInfo pi; ZeroMemory(&pi.si, sizeof(pi.si)); - pi.si.cb = sizeof(pi.si); + pi.si.StartupInfo.cb = sizeof(pi.si.StartupInfo); ZeroMemory(&pi.pi, sizeof(pi.pi)); - LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si; + LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si.StartupInfo; DWORD creation_flags = NORMAL_PRIORITY_CLASS; if (p_open_console) { @@ -1640,16 +1730,115 @@ void OS_Windows::unset_environment(const String &p_var) const { SetEnvironmentVariableW((LPCWSTR)(p_var.utf16().get_data()), nullptr); // Null to delete. } -String OS_Windows::get_stdin_string() { - char buff[1024]; +String OS_Windows::get_stdin_string(int64_t p_buffer_size) { + if (get_stdin_type() == STD_HANDLE_INVALID) { + return String(); + } + + Vector<uint8_t> data; + data.resize(p_buffer_size); DWORD count = 0; - if (ReadFile(GetStdHandle(STD_INPUT_HANDLE), buff, 1024, &count, nullptr)) { - return String::utf8((const char *)buff, count); + if (ReadFile(GetStdHandle(STD_INPUT_HANDLE), data.ptrw(), data.size(), &count, nullptr)) { + return String::utf8((const char *)data.ptr(), count); } return String(); } +PackedByteArray OS_Windows::get_stdin_buffer(int64_t p_buffer_size) { + Vector<uint8_t> data; + data.resize(p_buffer_size); + DWORD count = 0; + if (ReadFile(GetStdHandle(STD_INPUT_HANDLE), data.ptrw(), data.size(), &count, nullptr)) { + return data; + } + + return PackedByteArray(); +} + +OS_Windows::StdHandleType OS_Windows::get_stdin_type() const { + HANDLE h = GetStdHandle(STD_INPUT_HANDLE); + if (h == 0 || h == INVALID_HANDLE_VALUE) { + return STD_HANDLE_INVALID; + } + DWORD ftype = GetFileType(h); + if (ftype == FILE_TYPE_UNKNOWN && GetLastError() != ERROR_SUCCESS) { + return STD_HANDLE_UNKNOWN; + } + ftype &= ~(FILE_TYPE_REMOTE); + + if (ftype == FILE_TYPE_DISK) { + return STD_HANDLE_FILE; + } else if (ftype == FILE_TYPE_PIPE) { + return STD_HANDLE_PIPE; + } else { + DWORD conmode = 0; + BOOL res = GetConsoleMode(h, &conmode); + if (!res && (GetLastError() == ERROR_INVALID_HANDLE)) { + return STD_HANDLE_UNKNOWN; // Unknown character device. + } else { +#ifndef WINDOWS_SUBSYSTEM_CONSOLE + if (!is_using_con_wrapper()) { + return STD_HANDLE_INVALID; // Window app can't read stdin input without werapper. + } +#endif + return STD_HANDLE_CONSOLE; + } + } +} + +OS_Windows::StdHandleType OS_Windows::get_stdout_type() const { + HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); + if (h == 0 || h == INVALID_HANDLE_VALUE) { + return STD_HANDLE_INVALID; + } + DWORD ftype = GetFileType(h); + if (ftype == FILE_TYPE_UNKNOWN && GetLastError() != ERROR_SUCCESS) { + return STD_HANDLE_UNKNOWN; + } + ftype &= ~(FILE_TYPE_REMOTE); + + if (ftype == FILE_TYPE_DISK) { + return STD_HANDLE_FILE; + } else if (ftype == FILE_TYPE_PIPE) { + return STD_HANDLE_PIPE; + } else { + DWORD conmode = 0; + BOOL res = GetConsoleMode(h, &conmode); + if (!res && (GetLastError() == ERROR_INVALID_HANDLE)) { + return STD_HANDLE_UNKNOWN; // Unknown character device. + } else { + return STD_HANDLE_CONSOLE; + } + } +} + +OS_Windows::StdHandleType OS_Windows::get_stderr_type() const { + HANDLE h = GetStdHandle(STD_ERROR_HANDLE); + if (h == 0 || h == INVALID_HANDLE_VALUE) { + return STD_HANDLE_INVALID; + } + DWORD ftype = GetFileType(h); + if (ftype == FILE_TYPE_UNKNOWN && GetLastError() != ERROR_SUCCESS) { + return STD_HANDLE_UNKNOWN; + } + ftype &= ~(FILE_TYPE_REMOTE); + + if (ftype == FILE_TYPE_DISK) { + return STD_HANDLE_FILE; + } else if (ftype == FILE_TYPE_PIPE) { + return STD_HANDLE_PIPE; + } else { + DWORD conmode = 0; + BOOL res = GetConsoleMode(h, &conmode); + if (!res && (GetLastError() == ERROR_INVALID_HANDLE)) { + return STD_HANDLE_UNKNOWN; // Unknown character device. + } else { + return STD_HANDLE_CONSOLE; + } + } +} + Error OS_Windows::shell_open(const String &p_uri) { INT_PTR ret = (INT_PTR)ShellExecuteW(nullptr, nullptr, (LPCWSTR)(p_uri.utf16().get_data()), nullptr, nullptr, SW_SHOWNORMAL); if (ret > 32) { diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index a8efd440ee..fd98f9b14b 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -133,6 +133,8 @@ class OS_Windows : public OS { DWRITE_FONT_WEIGHT _weight_to_dw(int p_weight) const; DWRITE_FONT_STRETCH _stretch_to_dw(int p_stretch) const; + bool is_using_con_wrapper() const; + // functions used by main to initialize/deinitialize the OS protected: virtual void initialize() override; @@ -142,12 +144,17 @@ protected: virtual void finalize() override; virtual void finalize_core() override; - virtual String get_stdin_string() override; + + virtual String get_stdin_string(int64_t p_buffer_size = 1024) override; + virtual PackedByteArray get_stdin_buffer(int64_t p_buffer_size = 1024) override; + virtual StdHandleType get_stdin_type() const override; + virtual StdHandleType get_stdout_type() const override; + virtual StdHandleType get_stderr_type() const override; String _quote_command_line_argument(const String &p_text) const; struct ProcessInfo { - STARTUPINFO si; + STARTUPINFOEX si; PROCESS_INFORMATION pi; mutable bool is_running = true; mutable int exit_code = -1; diff --git a/platform/windows/windows_terminal_logger.cpp b/platform/windows/windows_terminal_logger.cpp index 6c54faa13a..e25c612008 100644 --- a/platform/windows/windows_terminal_logger.cpp +++ b/platform/windows/windows_terminal_logger.cpp @@ -30,6 +30,8 @@ #include "windows_terminal_logger.h" +#include "core/os/os.h" + #ifdef WINDOWS_ENABLED #include <stdio.h> @@ -78,7 +80,7 @@ void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file } HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); - if (!hCon || hCon == INVALID_HANDLE_VALUE) { + if (OS::get_singleton()->get_stdout_type() != OS::STD_HANDLE_CONSOLE || !hCon || hCon == INVALID_HANDLE_VALUE) { StdLogger::log_error(p_function, p_file, p_line, p_code, p_rationale, p_type); } else { CONSOLE_SCREEN_BUFFER_INFO sbi; //original diff --git a/platform_methods.py b/platform_methods.py index 2c4eb0d1dd..201df3c0b5 100644 --- a/platform_methods.py +++ b/platform_methods.py @@ -8,6 +8,13 @@ import methods # NOTE: The multiprocessing module is not compatible with SCons due to conflict on cPickle +compatibility_platform_aliases = { + "osx": "macos", + "iphone": "ios", + "x11": "linuxbsd", + "javascript": "web", +} + # CPU architecture options. architectures = ["x86_32", "x86_64", "arm32", "arm64", "rv64", "ppc32", "ppc64", "wasm32"] architecture_aliases = { diff --git a/pyproject.toml b/pyproject.toml index a4bfd27816..403d9fd675 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,14 @@ [tool.mypy] -ignore_missing_imports = true disallow_any_generics = true +explicit_package_bases = true +ignore_missing_imports = true +namespace_packages = true no_implicit_optional = true pretty = true show_column_numbers = true warn_redundant_casts = true warn_return_any = true warn_unreachable = true -namespace_packages = true -explicit_package_bases = true exclude = ["thirdparty/"] python_version = "3.8" @@ -16,7 +16,7 @@ python_version = "3.8" extend-exclude = ["thirdparty"] extend-include = ["SConstruct", "SCsub"] line-length = 120 -target-version = "py37" +target-version = "py38" [tool.ruff.lint] extend-select = [ @@ -42,50 +42,50 @@ section-order = [ ] [tool.codespell] -enable-colors = "" -write-changes = "" -check-hidden = "" +enable-colors = true +write-changes = true +check-hidden = true quiet-level = 3 -builtin = "clear,rare,en-GB_to_en-US" -skip = """\ - .mailmap, - *.desktop, - *.gitignore, - *.po, - *.pot, - *.rc, - AUTHORS.md, - COPYRIGHT.txt, - core/input/gamecontrollerdb.txt, - core/string/locales.h, - DONORS.md, - editor/project_converter_3_to_4.cpp, - platform/android/java/lib/src/com/*, - platform/web/package-lock.json -""" -ignore-words-list = """\ - breaked, - cancelled, - checkin, - colour, - curvelinear, - doubleclick, - expct, - findn, - gird, - hel, - inout, - labelin, - lod, - mis, - nd, - numer, - ot, - outin, - parm, - requestor, - te, - textin, - thirdparty, - vai -""" +builtin = ["clear", "rare", "en-GB_to_en-US"] +skip = [ + ".mailmap", + "*.desktop", + "*.gitignore", + "*.po", + "*.pot", + "*.rc", + "AUTHORS.md", + "COPYRIGHT.txt", + "core/input/gamecontrollerdb.txt", + "core/string/locales.h", + "DONORS.md", + "editor/project_converter_3_to_4.cpp", + "platform/android/java/lib/src/com/*", + "platform/web/package-lock.json", +] +ignore-words-list = [ + "breaked", + "cancelled", + "checkin", + "colour", + "curvelinear", + "doubleclick", + "expct", + "findn", + "gird", + "hel", + "inout", + "labelin", + "lod", + "mis", + "nd", + "numer", + "ot", + "outin", + "parm", + "requestor", + "te", + "textin", + "thirdparty", + "vai", +] diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 20cbbc091a..8e9500cdbe 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -75,7 +75,7 @@ void TileMap::_set_tile_map_data_using_compatibility_format(int p_layer, TileMap for (int i = 0; i < c; i += offset) { const uint8_t *ptr = (const uint8_t *)&r[i]; uint8_t local[12]; - const int buffer_size = (format == TILE_MAP_DATA_FORMAT_2) ? 12 : 8; + const int buffer_size = (p_format >= TILE_MAP_DATA_FORMAT_2) ? 12 : 8; for (int j = 0; j < buffer_size; j++) { local[j] = ptr[j]; } diff --git a/scene/3d/lightmap_gi.cpp b/scene/3d/lightmap_gi.cpp index c658bfd799..cdbd95d930 100644 --- a/scene/3d/lightmap_gi.cpp +++ b/scene/3d/lightmap_gi.cpp @@ -333,9 +333,7 @@ void LightmapGI::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound> &m mf.node_path = get_path_to(mi); mf.subindex = -1; mf.mesh = mesh; - - static const int lightmap_scale[GeometryInstance3D::LIGHTMAP_SCALE_MAX] = { 1, 2, 4, 8 }; - mf.lightmap_scale = lightmap_scale[mi->get_lightmap_scale()]; + mf.lightmap_scale = mi->get_lightmap_texel_scale(); Ref<Material> all_override = mi->get_material_override(); for (int i = 0; i < mesh->get_surface_count(); i++) { @@ -369,7 +367,7 @@ void LightmapGI::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound> &m mf.xform = xf * mesh_xf; mf.node_path = get_path_to(s); mf.subindex = i / 2; - mf.lightmap_scale = 1; + mf.lightmap_scale = 1.0; mf.mesh = mesh; meshes.push_back(mf); diff --git a/scene/3d/lightmap_gi.h b/scene/3d/lightmap_gi.h index 0476061c60..faa8b84fa1 100644 --- a/scene/3d/lightmap_gi.h +++ b/scene/3d/lightmap_gi.h @@ -194,7 +194,7 @@ private: NodePath node_path; int32_t subindex = 0; Ref<Mesh> mesh; - int32_t lightmap_scale = 0; + float lightmap_scale = 0.0; Vector<Ref<Material>> overrides; }; diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index a59754c8cc..2c7a004dd0 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -454,14 +454,48 @@ AABB GeometryInstance3D::get_custom_aabb() const { return custom_aabb; } +void GeometryInstance3D::set_lightmap_texel_scale(float p_scale) { + lightmap_texel_scale = p_scale; +} + +float GeometryInstance3D::get_lightmap_texel_scale() const { + return lightmap_texel_scale; +} + +#ifndef DISABLE_DEPRECATED void GeometryInstance3D::set_lightmap_scale(LightmapScale p_scale) { ERR_FAIL_INDEX(p_scale, LIGHTMAP_SCALE_MAX); - lightmap_scale = p_scale; + switch (p_scale) { + case GeometryInstance3D::LIGHTMAP_SCALE_1X: + lightmap_texel_scale = 1.0f; + break; + case GeometryInstance3D::LIGHTMAP_SCALE_2X: + lightmap_texel_scale = 2.0f; + break; + case GeometryInstance3D::LIGHTMAP_SCALE_4X: + lightmap_texel_scale = 4.0f; + break; + case GeometryInstance3D::LIGHTMAP_SCALE_8X: + lightmap_texel_scale = 8.0f; + break; + case GeometryInstance3D::LIGHTMAP_SCALE_MAX: + break; // Can't happen, but silences warning. + } } GeometryInstance3D::LightmapScale GeometryInstance3D::get_lightmap_scale() const { - return lightmap_scale; + // Return closest approximation. + if (lightmap_texel_scale < 1.5f) { + return GeometryInstance3D::LIGHTMAP_SCALE_1X; + } else if (lightmap_texel_scale < 3.0f) { + return GeometryInstance3D::LIGHTMAP_SCALE_2X; + } else if (lightmap_texel_scale < 6.0f) { + return GeometryInstance3D::LIGHTMAP_SCALE_4X; + } + + return GeometryInstance3D::LIGHTMAP_SCALE_8X; } +#endif // DISABLE_DEPRECATED void GeometryInstance3D::set_gi_mode(GIMode p_mode) { switch (p_mode) { @@ -565,8 +599,13 @@ void GeometryInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_extra_cull_margin", "margin"), &GeometryInstance3D::set_extra_cull_margin); ClassDB::bind_method(D_METHOD("get_extra_cull_margin"), &GeometryInstance3D::get_extra_cull_margin); + ClassDB::bind_method(D_METHOD("set_lightmap_texel_scale", "scale"), &GeometryInstance3D::set_lightmap_texel_scale); + ClassDB::bind_method(D_METHOD("get_lightmap_texel_scale"), &GeometryInstance3D::get_lightmap_texel_scale); + +#ifndef DISABLE_DEPRECATED ClassDB::bind_method(D_METHOD("set_lightmap_scale", "scale"), &GeometryInstance3D::set_lightmap_scale); ClassDB::bind_method(D_METHOD("get_lightmap_scale"), &GeometryInstance3D::get_lightmap_scale); +#endif // DISABLE_DEPRECATED ClassDB::bind_method(D_METHOD("set_gi_mode", "mode"), &GeometryInstance3D::set_gi_mode); ClassDB::bind_method(D_METHOD("get_gi_mode"), &GeometryInstance3D::get_gi_mode); @@ -591,7 +630,10 @@ void GeometryInstance3D::_bind_methods() { ADD_GROUP("Global Illumination", "gi_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "gi_mode", PROPERTY_HINT_ENUM, "Disabled,Static,Dynamic"), "set_gi_mode", "get_gi_mode"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "gi_lightmap_scale", PROPERTY_HINT_ENUM, String::utf8("1×,2×,4×,8×")), "set_lightmap_scale", "get_lightmap_scale"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gi_lightmap_texel_scale", PROPERTY_HINT_RANGE, "0.01,10,0.0001,or_greater"), "set_lightmap_texel_scale", "get_lightmap_texel_scale"); +#ifndef DISABLE_DEPRECATED + ADD_PROPERTY(PropertyInfo(Variant::INT, "gi_lightmap_scale", PROPERTY_HINT_ENUM, String::utf8("1×,2×,4×,8×"), PROPERTY_USAGE_NONE), "set_lightmap_scale", "get_lightmap_scale"); +#endif // DISABLE_DEPRECATED ADD_GROUP("Visibility Range", "visibility_range_"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "visibility_range_begin", PROPERTY_HINT_RANGE, "0.0,4096.0,0.01,or_greater,suffix:m"), "set_visibility_range_begin", "get_visibility_range_begin"); diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h index 9b02c928b7..073fa74573 100644 --- a/scene/3d/visual_instance_3d.h +++ b/scene/3d/visual_instance_3d.h @@ -134,7 +134,7 @@ private: float extra_cull_margin = 0.0; AABB custom_aabb; - LightmapScale lightmap_scale = LIGHTMAP_SCALE_1X; + float lightmap_texel_scale = 1.0f; GIMode gi_mode = GI_MODE_STATIC; bool ignore_occlusion_culling = false; @@ -185,8 +185,13 @@ public: void set_gi_mode(GIMode p_mode); GIMode get_gi_mode() const; - void set_lightmap_scale(LightmapScale p_scale); + void set_lightmap_texel_scale(float p_scale); + float get_lightmap_texel_scale() const; + +#ifndef DISABLE_DEPRECATED + void set_lightmap_scale(GeometryInstance3D::LightmapScale p_scale); LightmapScale get_lightmap_scale() const; +#endif // DISABLE_DEPRECATED void set_instance_shader_parameter(const StringName &p_name, const Variant &p_value); Variant get_instance_shader_parameter(const StringName &p_name) const; @@ -203,8 +208,8 @@ public: }; VARIANT_ENUM_CAST(GeometryInstance3D::ShadowCastingSetting); -VARIANT_ENUM_CAST(GeometryInstance3D::LightmapScale); VARIANT_ENUM_CAST(GeometryInstance3D::GIMode); +VARIANT_ENUM_CAST(GeometryInstance3D::LightmapScale); VARIANT_ENUM_CAST(GeometryInstance3D::VisibilityRangeFadeMode); #endif // VISUAL_INSTANCE_3D_H diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index a2aef60417..e172286d05 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -93,7 +93,9 @@ AnimationNode::NodeTimeInfo AnimationNodeAnimation::process(const AnimationMixer AnimationMixer::PlaybackInfo pi = p_playback_info; if (p_playback_info.seeked) { - pi.delta = get_node_time_info().position - p_playback_info.time; + if (p_playback_info.is_external_seeking) { + pi.delta = get_node_time_info().position - p_playback_info.time; + } } else { pi.time = get_node_time_info().position + (backward ? -p_playback_info.delta : p_playback_info.delta); } @@ -140,6 +142,12 @@ AnimationNode::NodeTimeInfo AnimationNodeAnimation::_process(const AnimationMixe // 1. Progress for AnimationNode. bool will_end = Animation::is_greater_or_equal_approx(cur_time + cur_delta, cur_len); + bool is_started = p_seek && !p_is_external_seeking && Math::is_zero_approx(cur_time); + + // 1. Progress for AnimationNode. + if (is_started && advance_on_start) { + cur_time = cur_delta; + } if (cur_loop_mode != Animation::LOOP_NONE) { if (cur_loop_mode == Animation::LOOP_LINEAR) { if (!Math::is_zero_approx(cur_len)) { @@ -232,7 +240,7 @@ AnimationNode::NodeTimeInfo AnimationNodeAnimation::_process(const AnimationMixe // We should use call_deferred since the track keys are still being processed. if (process_state->tree && !p_test_only) { // AnimationTree uses seek to 0 "internally" to process the first key of the animation, which is used as the start detection. - if (p_seek && !p_is_external_seeking && Math::is_zero_approx(cur_playback_time)) { + if (is_started) { process_state->tree->call_deferred(SNAME("emit_signal"), SceneStringName(animation_started), animation); } // Finished. @@ -282,6 +290,14 @@ bool AnimationNodeAnimation::is_backward() const { return backward; } +void AnimationNodeAnimation::set_advance_on_start(bool p_advance_on_start) { + advance_on_start = p_advance_on_start; +} + +bool AnimationNodeAnimation::is_advance_on_start() const { + return advance_on_start; +} + void AnimationNodeAnimation::set_use_custom_timeline(bool p_use_custom_timeline) { use_custom_timeline = p_use_custom_timeline; notify_property_list_changed(); @@ -331,6 +347,9 @@ void AnimationNodeAnimation::_bind_methods() { ClassDB::bind_method(D_METHOD("set_play_mode", "mode"), &AnimationNodeAnimation::set_play_mode); ClassDB::bind_method(D_METHOD("get_play_mode"), &AnimationNodeAnimation::get_play_mode); + ClassDB::bind_method(D_METHOD("set_advance_on_start", "advance_on_start"), &AnimationNodeAnimation::set_advance_on_start); + ClassDB::bind_method(D_METHOD("is_advance_on_start"), &AnimationNodeAnimation::is_advance_on_start); + ClassDB::bind_method(D_METHOD("set_use_custom_timeline", "use_custom_timeline"), &AnimationNodeAnimation::set_use_custom_timeline); ClassDB::bind_method(D_METHOD("is_using_custom_timeline"), &AnimationNodeAnimation::is_using_custom_timeline); @@ -348,6 +367,7 @@ void AnimationNodeAnimation::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "animation"), "set_animation", "get_animation"); ADD_PROPERTY(PropertyInfo(Variant::INT, "play_mode", PROPERTY_HINT_ENUM, "Forward,Backward"), "set_play_mode", "get_play_mode"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "advance_on_start"), "set_advance_on_start", "is_advance_on_start"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_custom_timeline"), "set_use_custom_timeline", "is_using_custom_timeline"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "timeline_length", PROPERTY_HINT_RANGE, "0.001,60,0.001,or_greater,or_less,hide_slider,suffix:s"), "set_timeline_length", "get_timeline_length"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stretch_time_scale"), "set_stretch_time_scale", "is_stretching_time_scale"); diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h index 2add35d009..5c912f0095 100644 --- a/scene/animation/animation_blend_tree.h +++ b/scene/animation/animation_blend_tree.h @@ -38,6 +38,8 @@ class AnimationNodeAnimation : public AnimationRootNode { StringName animation; + bool advance_on_start = false; + bool use_custom_timeline = false; double timeline_length = 1.0; Animation::LoopMode loop_mode = Animation::LOOP_NONE; @@ -72,6 +74,9 @@ public: void set_backward(bool p_backward); bool is_backward() const; + void set_advance_on_start(bool p_advance_on_start); + bool is_advance_on_start() const; + void set_use_custom_timeline(bool p_use_custom_timeline); bool is_using_custom_timeline() const; diff --git a/scene/animation/animation_mixer.cpp b/scene/animation/animation_mixer.cpp index 0fa6810d23..b40c677f6e 100644 --- a/scene/animation/animation_mixer.cpp +++ b/scene/animation/animation_mixer.cpp @@ -600,6 +600,22 @@ void AnimationMixer::_init_root_motion_cache() { root_motion_scale_accumulator = Vector3(1, 1, 1); } +void AnimationMixer::_create_track_num_to_track_cashe_for_animation(Ref<Animation> &p_animation) { + ERR_FAIL_COND(animation_track_num_to_track_cashe.has(p_animation)); + LocalVector<TrackCache *> &track_num_to_track_cashe = animation_track_num_to_track_cashe.insert_new(p_animation, LocalVector<TrackCache *>())->value; + const Vector<Animation::Track *> &tracks = p_animation->get_tracks(); + + track_num_to_track_cashe.resize(tracks.size()); + for (int i = 0; i < tracks.size(); i++) { + TrackCache **track_ptr = track_cache.getptr(tracks[i]->thash); + if (track_ptr == nullptr) { + track_num_to_track_cashe[i] = nullptr; + } else { + track_num_to_track_cashe[i] = *track_ptr; + } + } +} + bool AnimationMixer::_update_caches() { setup_pass++; @@ -928,20 +944,9 @@ bool AnimationMixer::_update_caches() { } animation_track_num_to_track_cashe.clear(); - LocalVector<TrackCache *> track_num_to_track_cashe; for (const StringName &E : sname_list) { Ref<Animation> anim = get_animation(E); - const Vector<Animation::Track *> tracks = anim->get_tracks(); - track_num_to_track_cashe.resize(tracks.size()); - for (int i = 0; i < tracks.size(); i++) { - TrackCache **track_ptr = track_cache.getptr(tracks[i]->thash); - if (track_ptr == nullptr) { - track_num_to_track_cashe[i] = nullptr; - } else { - track_num_to_track_cashe[i] = *track_ptr; - } - } - animation_track_num_to_track_cashe.insert(anim, track_num_to_track_cashe); + _create_track_num_to_track_cashe_for_animation(anim); } track_count = idx; @@ -1074,6 +1079,9 @@ void AnimationMixer::blend_capture(double p_delta) { capture_cache.remain -= p_delta * capture_cache.step; if (Animation::is_less_or_equal_approx(capture_cache.remain, 0)) { + if (capture_cache.animation.is_valid()) { + animation_track_num_to_track_cashe.erase(capture_cache.animation); + } capture_cache.clear(); return; } @@ -2205,6 +2213,9 @@ void AnimationMixer::capture(const StringName &p_name, double p_duration, Tween: capture_cache.step = 1.0 / p_duration; capture_cache.trans_type = p_trans_type; capture_cache.ease_type = p_ease_type; + if (capture_cache.animation.is_valid()) { + animation_track_num_to_track_cashe.erase(capture_cache.animation); + } capture_cache.animation.instantiate(); bool is_valid = false; @@ -2228,6 +2239,8 @@ void AnimationMixer::capture(const StringName &p_name, double p_duration, Tween: } if (!is_valid) { capture_cache.clear(); + } else { + _create_track_num_to_track_cashe_for_animation(capture_cache.animation); } } diff --git a/scene/animation/animation_mixer.h b/scene/animation/animation_mixer.h index 1906146c56..3769fa268c 100644 --- a/scene/animation/animation_mixer.h +++ b/scene/animation/animation_mixer.h @@ -321,6 +321,7 @@ protected: void _clear_playing_caches(); void _init_root_motion_cache(); bool _update_caches(); + void _create_track_num_to_track_cashe_for_animation(Ref<Animation> &p_animation); /* ---- Audio ---- */ AudioServer::PlaybackType playback_type; diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index b3a75a75a0..7d28aead6e 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -876,6 +876,20 @@ Tween::EaseType AnimationPlayer::get_auto_capture_ease_type() const { return auto_capture_ease_type; } +#ifdef TOOLS_ENABLED +void AnimationPlayer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { + const String pf = p_function; + if (p_idx == 0 && (pf == "play" || pf == "play_backwards" || pf == "has_animation" || pf == "queue")) { + List<StringName> al; + get_animation_list(&al); + for (const StringName &name : al) { + r_options->push_back(String(name).quote()); + } + } + AnimationMixer::get_argument_options(p_function, p_idx, r_options); +} +#endif + void AnimationPlayer::_animation_removed(const StringName &p_name, const StringName &p_library) { AnimationMixer::_animation_removed(p_name, p_library); diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index 06b3eecb89..6d7e8aa996 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -178,6 +178,10 @@ public: void set_auto_capture_ease_type(Tween::EaseType p_auto_capture_ease_type); Tween::EaseType get_auto_capture_ease_type() const; +#ifdef TOOLS_ENABLED + void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override; +#endif + void play(const StringName &p_name = StringName(), double p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false); void play_section_with_markers(const StringName &p_name = StringName(), const StringName &p_start_marker = StringName(), const StringName &p_end_marker = StringName(), double p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false); void play_section(const StringName &p_name = StringName(), double p_start_time = -1, double p_end_time = -1, double p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false); diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index d676e2acf4..f2871cda79 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -371,7 +371,9 @@ AnimationNode::NodeTimeInfo AnimationNode::process(const AnimationMixer::Playbac AnimationMixer::PlaybackInfo pi = p_playback_info; if (p_playback_info.seeked) { - pi.delta = get_node_time_info().position - p_playback_info.time; + if (p_playback_info.is_external_seeking) { + pi.delta = get_node_time_info().position - p_playback_info.time; + } } else { pi.time = get_node_time_info().position + p_playback_info.delta; } diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index eb25a8db1b..5a2a822ff0 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -91,7 +91,7 @@ public: if (Math::is_zero_approx(remain)) { return 0; } - return length - position; + return remain; } }; diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index 9d7e2496a2..89f1564775 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -1498,9 +1498,9 @@ void CodeEdit::_line_number_draw_callback(int p_line, int p_gutter, const Rect2 ofs.y += TS->shaped_text_get_ascent(text_rid); if (rtl) { - ofs.x = p_region.position.x; - } else { ofs.x = p_region.get_end().x - text_size.width; + } else { + ofs.x = p_region.position.x; } Color number_color = get_line_gutter_item_color(p_line, line_number_gutter); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 9eda1a256f..e601f16843 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -50,7 +50,7 @@ void FileDialog::popup_file_dialog() { } void FileDialog::_focus_file_text() { - int lp = file->get_text().rfind("."); + int lp = file->get_text().rfind_char('.'); if (lp != -1) { file->select(0, lp); if (file->is_inside_tree() && !is_part_of_edited_scene()) { @@ -68,9 +68,9 @@ void FileDialog::_native_popup() { root = OS::get_singleton()->get_user_data_dir(); } if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE_EXTRA)) { - DisplayServer::get_singleton()->file_dialog_with_options_show(get_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, _get_options(), callable_mp(this, &FileDialog::_native_dialog_cb_with_options)); + DisplayServer::get_singleton()->file_dialog_with_options_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), processed_filters, _get_options(), callable_mp(this, &FileDialog::_native_dialog_cb_with_options)); } else { - DisplayServer::get_singleton()->file_dialog_show(get_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, callable_mp(this, &FileDialog::_native_dialog_cb)); + DisplayServer::get_singleton()->file_dialog_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), processed_filters, callable_mp(this, &FileDialog::_native_dialog_cb)); } } @@ -851,37 +851,54 @@ void FileDialog::_filename_filter_selected() { void FileDialog::update_filters() { filter->clear(); + processed_filters.clear(); if (filters.size() > 1) { String all_filters; + String all_filters_full; const int max_filters = 5; for (int i = 0; i < MIN(max_filters, filters.size()); i++) { - String flt = filters[i].get_slice(";", 0).strip_edges(); + String flt = filters[i].get_slicec(';', 0).strip_edges(); if (i > 0) { all_filters += ", "; } all_filters += flt; } + for (int i = 0; i < filters.size(); i++) { + String flt = filters[i].get_slicec(';', 0).strip_edges(); + if (i > 0) { + all_filters_full += ","; + } + all_filters_full += flt; + } if (max_filters < filters.size()) { all_filters += ", ..."; } - filter->add_item(atr(ETR("All Recognized")) + " (" + all_filters + ")"); + String f = atr(ETR("All Recognized")) + " (" + all_filters + ")"; + filter->add_item(f); + processed_filters.push_back(all_filters_full + ";" + f); } for (int i = 0; i < filters.size(); i++) { - String flt = filters[i].get_slice(";", 0).strip_edges(); + String flt = filters[i].get_slicec(';', 0).strip_edges(); String desc = filters[i].get_slice(";", 1).strip_edges(); if (desc.length()) { - filter->add_item(String(tr(desc)) + " (" + flt + ")"); + String f = atr(desc) + " (" + flt + ")"; + filter->add_item(f); + processed_filters.push_back(flt + ";" + f); } else { - filter->add_item("(" + flt + ")"); + String f = "(" + flt + ")"; + filter->add_item(f); + processed_filters.push_back(flt + ";" + f); } } - filter->add_item(atr(ETR("All Files")) + " (*)"); + String f = atr(ETR("All Files")) + " (*)"; + filter->add_item(f); + processed_filters.push_back("*.*;" + f); } void FileDialog::clear_filename_filter() { @@ -984,7 +1001,7 @@ void FileDialog::set_current_path(const String &p_path) { if (!p_path.size()) { return; } - int pos = MAX(p_path.rfind("/"), p_path.rfind("\\")); + int pos = MAX(p_path.rfind_char('/'), p_path.rfind_char('\\')); if (pos == -1) { set_current_file(p_path); } else { diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 28978dbed3..82067ac534 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -101,6 +101,7 @@ private: Button *show_filename_filter_button = nullptr; Vector<String> filters; + Vector<String> processed_filters; String file_name_filter; bool show_filename_filter = false; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 3f979f7c20..b7c7326172 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1452,13 +1452,12 @@ void LineEdit::undo() { return; } + if (!has_undo()) { + return; + } + if (undo_stack_pos == nullptr) { - if (undo_stack.size() <= 1) { - return; - } undo_stack_pos = undo_stack.back(); - } else if (undo_stack_pos == undo_stack.front()) { - return; } deselect(); @@ -1479,10 +1478,7 @@ void LineEdit::redo() { return; } - if (undo_stack_pos == nullptr) { - return; - } - if (undo_stack_pos == undo_stack.back()) { + if (!has_redo()) { return; } diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 79018c40f5..26d164a62d 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -178,7 +178,7 @@ bool OptionButton::_set(const StringName &p_name, const Variant &p_value) { } void OptionButton::_focused(int p_which) { - emit_signal(SNAME("item_focused"), p_which); + emit_signal(SNAME("item_focused"), popup->get_item_index(p_which)); } void OptionButton::_selected(int p_which) { diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 3c04094526..f6ebcc854c 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -474,7 +474,7 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) { for (int i = search_from; i < items.size(); i++) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); set_input_as_handled(); @@ -488,7 +488,7 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) { for (int i = 0; i < search_from; i++) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); set_input_as_handled(); @@ -512,7 +512,7 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) { for (int i = search_from; i >= 0; i--) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); set_input_as_handled(); @@ -526,7 +526,7 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) { for (int i = items.size() - 1; i >= search_from; i--) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); set_input_as_handled(); @@ -692,7 +692,7 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) { if (items[i].text.findn(search_string) == 0) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); set_input_as_handled(); @@ -1091,7 +1091,7 @@ void PopupMenu::_notification(int p_what) { for (int i = search_from; i < items.size(); i++) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); match_found = true; @@ -1104,7 +1104,7 @@ void PopupMenu::_notification(int p_what) { for (int i = 0; i < search_from; i++) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); break; @@ -1124,7 +1124,7 @@ void PopupMenu::_notification(int p_what) { for (int i = search_from; i >= 0; i--) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); match_found = true; @@ -1137,7 +1137,7 @@ void PopupMenu::_notification(int p_what) { for (int i = items.size() - 1; i >= search_from; i--) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); break; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 26141663c1..a349d50236 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -4845,7 +4845,7 @@ void RichTextLabel::append_text(const String &p_bbcode) { String tooltip; bool size_in_percent = false; if (!bbcode_value.is_empty()) { - int sep = bbcode_value.find("x"); + int sep = bbcode_value.find_char('x'); if (sep == -1) { width = bbcode_value.to_int(); } else { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index b1918ff23f..b8bb17eb2a 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -332,6 +332,7 @@ void TextEdit::Text::clear() { max_line_width_dirty = true; max_line_height_dirty = true; + total_visible_line_count = 0; Line line; line.gutters.resize(gutter_count); @@ -421,6 +422,10 @@ void TextEdit::Text::remove_range(int p_from_line, int p_to_line) { for (int i = p_from_line; i < p_to_line; i++) { const Line &text_line = text[i]; + if (text_line.hidden) { + continue; + } + if (text_line.height == max_line_height) { max_line_height_dirty = true; } @@ -435,6 +440,8 @@ void TextEdit::Text::remove_range(int p_from_line, int p_to_line) { text.write[(i - diff) + 1] = text[i + 1]; } text.resize(text.size() - diff); + + ERR_FAIL_COND(total_visible_line_count < 0); // BUG } void TextEdit::Text::add_gutter(int p_at) { @@ -4168,7 +4175,7 @@ void TextEdit::redo() { } _push_current_op(); - if (undo_stack_pos == nullptr) { + if (!has_redo()) { return; // Nothing to do. } @@ -7303,6 +7310,10 @@ void TextEdit::_paste_internal(int p_caret) { } String clipboard = DisplayServer::get_singleton()->clipboard_get(); + if (clipboard.is_empty()) { + // Nothing to paste. + return; + } // Paste a full line. Ignore '\r' characters that may have been added to the clipboard by the OS. if (get_caret_count() == 1 && !has_selection(0) && !cut_copy_line.is_empty() && cut_copy_line == clipboard.replace("\r", "")) { diff --git a/scene/gui/texture_progress_bar.cpp b/scene/gui/texture_progress_bar.cpp index 4ad56d21d3..24c68e0188 100644 --- a/scene/gui/texture_progress_bar.cpp +++ b/scene/gui/texture_progress_bar.cpp @@ -608,11 +608,10 @@ int TextureProgressBar::get_fill_mode() { } void TextureProgressBar::set_radial_initial_angle(float p_angle) { - while (p_angle > 360) { - p_angle -= 360; - } - while (p_angle < 0) { - p_angle += 360; + ERR_FAIL_COND_MSG(!Math::is_finite(p_angle), "Angle is non-finite."); + + if (p_angle < 0.0 || p_angle > 360.0) { + p_angle = Math::fposmodp(p_angle, 360.0f); } if (rad_init_angle == p_angle) { diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index 8526611093..986bd87af2 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -87,7 +87,7 @@ String HTTPRequest::get_header_value(const PackedStringArray &p_headers, const S String lowwer_case_header_name = p_header_name.to_lower(); for (int i = 0; i < p_headers.size(); i++) { - if (p_headers[i].find(":") > 0) { + if (p_headers[i].find_char(':') > 0) { Vector<String> parts = p_headers[i].split(":", false, 1); if (parts.size() > 1 && parts[0].strip_edges().to_lower() == lowwer_case_header_name) { value = parts[1].strip_edges(); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 8dc7b4a87c..5063f0d6d0 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -3055,11 +3055,12 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { if (copy && copytarget && E.callable.get_method() != StringName()) { Callable copy_callable = Callable(copytarget, E.callable.get_method()); if (!copy->is_connected(E.signal.get_name(), copy_callable)) { - int arg_count = E.callable.get_bound_arguments_count(); - if (arg_count > 0) { + int unbound_arg_count = E.callable.get_unbound_arguments_count(); + if (unbound_arg_count > 0) { + copy_callable = copy_callable.unbind(unbound_arg_count); + } + if (E.callable.get_bound_arguments_count() > 0) { copy_callable = copy_callable.bindv(E.callable.get_bound_arguments()); - } else if (arg_count < 0) { - copy_callable = copy_callable.unbind(-arg_count); } copy->connect(E.signal.get_name(), copy_callable, E.flags); } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 1ee99099ec..e70407f36e 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -330,7 +330,7 @@ void Viewport::_sub_window_update(Window *p_window) { int close_h_ofs = p_window->theme_cache.close_h_offset; int close_v_ofs = p_window->theme_cache.close_v_offset; - TextLine title_text = TextLine(p_window->atr(p_window->get_title()), title_font, font_size); + TextLine title_text = TextLine(p_window->get_translated_title(), title_font, font_size); title_text.set_width(r.size.width - panel->get_minimum_size().x - close_h_ofs); title_text.set_direction(p_window->is_layout_rtl() ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR); int x = (r.size.width - title_text.get_size().x) / 2; diff --git a/scene/main/window.cpp b/scene/main/window.cpp index fc2fe4320b..05904fa8f9 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -303,6 +303,11 @@ String Window::get_title() const { return title; } +String Window::get_translated_title() const { + ERR_READ_THREAD_GUARD_V(String()); + return tr_title; +} + void Window::_settings_changed() { if (visible && initial_position != WINDOW_INITIAL_POSITION_ABSOLUTE && is_in_edited_scene_root()) { Size2 screen_size = Size2(GLOBAL_GET("display/window/size/viewport_width"), GLOBAL_GET("display/window/size/viewport_height")); diff --git a/scene/main/window.h b/scene/main/window.h index 0994fc6012..a1d95ab91f 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -274,6 +274,7 @@ public: void set_title(const String &p_title); String get_title() const; + String get_translated_title() const; void set_initial_position(WindowInitialPosition p_initial_position); WindowInitialPosition get_initial_position() const; diff --git a/scene/property_utils.cpp b/scene/property_utils.cpp index f068e34beb..9cae7d2a3a 100644 --- a/scene/property_utils.cpp +++ b/scene/property_utils.cpp @@ -182,7 +182,7 @@ Variant PropertyUtils::get_property_default_value(const Object *p_object, const // Heuristically check if this is a synthetic property (whatever/0, whatever/1, etc.) // because they are not in the class DB yet must have a default (null). String prop_str = String(p_property); - int p = prop_str.rfind("/"); + int p = prop_str.rfind_char('/'); if (p != -1 && p < prop_str.length() - 1) { bool all_digits = true; for (int i = p + 1; i < prop_str.length(); i++) { diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index 765373ce99..91d3757590 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -1463,6 +1463,9 @@ void Curve3D::_remove_point(int p_index) { void Curve3D::remove_point(int p_index) { _remove_point(p_index); + if (closed && points.size() < 2) { + set_closed(false); + } notify_property_list_changed(); } @@ -1479,15 +1482,25 @@ Vector3 Curve3D::sample(int p_index, real_t p_offset) const { ERR_FAIL_COND_V(pc == 0, Vector3()); if (p_index >= pc - 1) { - return points[pc - 1].position; + if (!closed) { + return points[pc - 1].position; + } else { + p_index = pc - 1; + } } else if (p_index < 0) { return points[0].position; } Vector3 p0 = points[p_index].position; Vector3 p1 = p0 + points[p_index].out; - Vector3 p3 = points[p_index + 1].position; - Vector3 p2 = p3 + points[p_index + 1].in; + Vector3 p3, p2; + if (!closed || p_index < pc - 1) { + p3 = points[p_index + 1].position; + p2 = p3 + points[p_index + 1].in; + } else { + p3 = points[0].position; + p2 = p3 + points[0].in; + } return p0.bezier_interpolate(p1, p2, p3, p_offset); } @@ -1605,13 +1618,16 @@ void Curve3D::_bake() const { { Vector<RBMap<real_t, Vector3>> midpoints = _tessellate_even_length(10, bake_interval); + const int num_intervals = closed ? points.size() : points.size() - 1; + #ifdef TOOLS_ENABLED - points_in_cache.resize(points.size()); + points_in_cache.resize(closed ? (points.size() + 1) : points.size()); points_in_cache.set(0, 0); #endif + // Point Count: Begins at 1 to account for the last point. int pc = 1; - for (int i = 0; i < points.size() - 1; i++) { + for (int i = 0; i < num_intervals; i++) { pc++; pc += midpoints[i].size(); #ifdef TOOLS_ENABLED @@ -1634,18 +1650,29 @@ void Curve3D::_bake() const { btw[0] = points[0].tilt; int pidx = 0; - for (int i = 0; i < points.size() - 1; i++) { + for (int i = 0; i < num_intervals; i++) { for (const KeyValue<real_t, Vector3> &E : midpoints[i]) { pidx++; bpw[pidx] = E.value; - bfw[pidx] = _calculate_tangent(points[i].position, points[i].position + points[i].out, points[i + 1].position + points[i + 1].in, points[i + 1].position, E.key); - btw[pidx] = Math::lerp(points[i].tilt, points[i + 1].tilt, E.key); + if (!closed || i < num_intervals - 1) { + bfw[pidx] = _calculate_tangent(points[i].position, points[i].position + points[i].out, points[i + 1].position + points[i + 1].in, points[i + 1].position, E.key); + btw[pidx] = Math::lerp(points[i].tilt, points[i + 1].tilt, E.key); + } else { + bfw[pidx] = _calculate_tangent(points[i].position, points[i].position + points[i].out, points[0].position + points[0].in, points[0].position, E.key); + btw[pidx] = Math::lerp(points[i].tilt, points[0].tilt, E.key); + } } pidx++; - bpw[pidx] = points[i + 1].position; - bfw[pidx] = _calculate_tangent(points[i].position, points[i].position + points[i].out, points[i + 1].position + points[i + 1].in, points[i + 1].position, 1.0); - btw[pidx] = points[i + 1].tilt; + if (!closed || i < num_intervals - 1) { + bpw[pidx] = points[i + 1].position; + bfw[pidx] = _calculate_tangent(points[i].position, points[i].position + points[i].out, points[i + 1].position + points[i + 1].in, points[i + 1].position, 1.0); + btw[pidx] = points[i + 1].tilt; + } else { + bpw[pidx] = points[0].position; + bfw[pidx] = _calculate_tangent(points[i].position, points[i].position + points[i].out, points[0].position + points[0].in, points[0].position, 1.0); + btw[pidx] = points[0].tilt; + } } // Recalculate the baked distances. @@ -2096,6 +2123,20 @@ real_t Curve3D::get_closest_offset(const Vector3 &p_to_point) const { return nearest; } +void Curve3D::set_closed(bool p_closed) { + if (closed == p_closed) { + return; + } + + closed = p_closed; + mark_dirty(); + notify_property_list_changed(); +} + +bool Curve3D::is_closed() const { + return closed; +} + void Curve3D::set_bake_interval(real_t p_tolerance) { bake_interval = p_tolerance; mark_dirty(); @@ -2174,11 +2215,17 @@ PackedVector3Array Curve3D::tessellate(int p_max_stages, real_t p_tolerance) con } Vector<RBMap<real_t, Vector3>> midpoints; - midpoints.resize(points.size() - 1); + const int num_intervals = closed ? points.size() : points.size() - 1; + midpoints.resize(num_intervals); + // Point Count: Begins at 1 to account for the last point. int pc = 1; - for (int i = 0; i < points.size() - 1; i++) { - _bake_segment3d(midpoints.write[i], 0, 1, points[i].position, points[i].out, points[i + 1].position, points[i + 1].in, 0, p_max_stages, p_tolerance); + for (int i = 0; i < num_intervals; i++) { + if (!closed || i < num_intervals - 1) { + _bake_segment3d(midpoints.write[i], 0, 1, points[i].position, points[i].out, points[i + 1].position, points[i + 1].in, 0, p_max_stages, p_tolerance); + } else { + _bake_segment3d(midpoints.write[i], 0, 1, points[i].position, points[i].out, points[0].position, points[0].in, 0, p_max_stages, p_tolerance); + } pc++; pc += midpoints[i].size(); } @@ -2188,14 +2235,18 @@ PackedVector3Array Curve3D::tessellate(int p_max_stages, real_t p_tolerance) con bpw[0] = points[0].position; int pidx = 0; - for (int i = 0; i < points.size() - 1; i++) { + for (int i = 0; i < num_intervals; i++) { for (const KeyValue<real_t, Vector3> &E : midpoints[i]) { pidx++; bpw[pidx] = E.value; } pidx++; - bpw[pidx] = points[i + 1].position; + if (!closed || i < num_intervals - 1) { + bpw[pidx] = points[i + 1].position; + } else { + bpw[pidx] = points[0].position; + } } return tess; @@ -2205,10 +2256,15 @@ Vector<RBMap<real_t, Vector3>> Curve3D::_tessellate_even_length(int p_max_stages Vector<RBMap<real_t, Vector3>> midpoints; ERR_FAIL_COND_V_MSG(points.size() < 2, midpoints, "Curve must have at least 2 control point"); - midpoints.resize(points.size() - 1); + const int num_intervals = closed ? points.size() : points.size() - 1; + midpoints.resize(num_intervals); - for (int i = 0; i < points.size() - 1; i++) { - _bake_segment3d_even_length(midpoints.write[i], 0, 1, points[i].position, points[i].out, points[i + 1].position, points[i + 1].in, 0, p_max_stages, p_length); + for (int i = 0; i < num_intervals; i++) { + if (!closed || i < num_intervals - 1) { + _bake_segment3d_even_length(midpoints.write[i], 0, 1, points[i].position, points[i].out, points[i + 1].position, points[i + 1].in, 0, p_max_stages, p_length); + } else { + _bake_segment3d_even_length(midpoints.write[i], 0, 1, points[i].position, points[i].out, points[0].position, points[0].in, 0, p_max_stages, p_length); + } } return midpoints; } @@ -2221,8 +2277,10 @@ PackedVector3Array Curve3D::tessellate_even_length(int p_max_stages, real_t p_le return tess; } + const int num_intervals = closed ? points.size() : points.size() - 1; + // Point Count: Begins at 1 to account for the last point. int pc = 1; - for (int i = 0; i < points.size() - 1; i++) { + for (int i = 0; i < num_intervals; i++) { pc++; pc += midpoints[i].size(); } @@ -2232,14 +2290,18 @@ PackedVector3Array Curve3D::tessellate_even_length(int p_max_stages, real_t p_le bpw[0] = points[0].position; int pidx = 0; - for (int i = 0; i < points.size() - 1; i++) { + for (int i = 0; i < num_intervals; i++) { for (const KeyValue<real_t, Vector3> &E : midpoints[i]) { pidx++; bpw[pidx] = E.value; } pidx++; - bpw[pidx] = points[i + 1].position; + if (!closed || i < num_intervals - 1) { + bpw[pidx] = points[i + 1].position; + } else { + bpw[pidx] = points[0].position; + } } return tess; @@ -2295,13 +2357,13 @@ void Curve3D::_get_property_list(List<PropertyInfo> *p_list) const { pi.usage &= ~PROPERTY_USAGE_STORAGE; p_list->push_back(pi); - if (i != 0) { + if (closed || i != 0) { pi = PropertyInfo(Variant::VECTOR3, vformat("point_%d/in", i)); pi.usage &= ~PROPERTY_USAGE_STORAGE; p_list->push_back(pi); } - if (i != points.size() - 1) { + if (closed || i != points.size() - 1) { pi = PropertyInfo(Variant::VECTOR3, vformat("point_%d/out", i)); pi.usage &= ~PROPERTY_USAGE_STORAGE; p_list->push_back(pi); @@ -2329,6 +2391,8 @@ void Curve3D::_bind_methods() { ClassDB::bind_method(D_METHOD("clear_points"), &Curve3D::clear_points); ClassDB::bind_method(D_METHOD("sample", "idx", "t"), &Curve3D::sample); ClassDB::bind_method(D_METHOD("samplef", "fofs"), &Curve3D::samplef); + ClassDB::bind_method(D_METHOD("set_closed", "closed"), &Curve3D::set_closed); + ClassDB::bind_method(D_METHOD("is_closed"), &Curve3D::is_closed); //ClassDB::bind_method(D_METHOD("bake","subdivs"),&Curve3D::bake,DEFVAL(10)); ClassDB::bind_method(D_METHOD("set_bake_interval", "distance"), &Curve3D::set_bake_interval); ClassDB::bind_method(D_METHOD("get_bake_interval"), &Curve3D::get_bake_interval); @@ -2350,6 +2414,8 @@ void Curve3D::_bind_methods() { ClassDB::bind_method(D_METHOD("_get_data"), &Curve3D::_get_data); ClassDB::bind_method(D_METHOD("_set_data", "data"), &Curve3D::_set_data); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "closed"), "set_closed", "is_closed"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bake_interval", PROPERTY_HINT_RANGE, "0.01,512,0.01"), "set_bake_interval", "get_bake_interval"); ADD_PROPERTY(PropertyInfo(Variant::INT, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data"); ADD_ARRAY_COUNT("Points", "point_count", "set_point_count", "get_point_count", "point_"); diff --git a/scene/resources/curve.h b/scene/resources/curve.h index 6da337a93f..154d91e23b 100644 --- a/scene/resources/curve.h +++ b/scene/resources/curve.h @@ -264,6 +264,8 @@ class Curve3D : public Resource { mutable Vector<size_t> points_in_cache; #endif + bool closed = false; + mutable bool baked_cache_dirty = false; mutable PackedVector3Array baked_point_cache; mutable Vector<real_t> baked_tilt_cache; @@ -330,6 +332,8 @@ public: Vector3 sample(int p_index, real_t p_offset) const; Vector3 samplef(real_t p_findex) const; + void set_closed(bool p_closed); + bool is_closed() const; void set_bake_interval(real_t p_tolerance); real_t get_bake_interval() const; void set_up_vector_enabled(bool p_enable); diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index a4677d917d..ae70443e6a 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -1734,7 +1734,7 @@ Error FontFile::_load_bitmap_font(const String &p_path, List<String> *r_image_fi while (true) { String line = f->get_line(); - int delimiter = line.find(" "); + int delimiter = line.find_char(' '); String type = line.substr(0, delimiter); int pos = delimiter + 1; HashMap<String, String> keys; @@ -1744,7 +1744,7 @@ Error FontFile::_load_bitmap_font(const String &p_path, List<String> *r_image_fi } while (pos < line.size()) { - int eq = line.find("=", pos); + int eq = line.find_char('=', pos); if (eq == -1) { break; } @@ -1752,14 +1752,14 @@ Error FontFile::_load_bitmap_font(const String &p_path, List<String> *r_image_fi int end = -1; String value; if (line[eq + 1] == '"') { - end = line.find("\"", eq + 2); + end = line.find_char('"', eq + 2); if (end == -1) { break; } value = line.substr(eq + 2, end - 1 - eq - 1); pos = end + 1; } else { - end = line.find(" ", eq + 1); + end = line.find_char(' ', eq + 1); if (end == -1) { end = line.size(); } diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index b0353b4f2c..8c0e087902 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -1315,7 +1315,7 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { String sname = p_name; if (sname.begins_with("surface_")) { - int sl = sname.find("/"); + int sl = sname.find_char('/'); if (sl == -1) { return false; } @@ -1708,7 +1708,7 @@ bool ArrayMesh::_get(const StringName &p_name, Variant &r_ret) const { String sname = p_name; if (sname.begins_with("surface_")) { - int sl = sname.find("/"); + int sl = sname.find_char('/'); if (sl == -1) { return false; } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 809a77a487..d7036fd6d5 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -822,10 +822,10 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has value = missing_resource_properties[E.name]; } } else if (E.type == Variant::ARRAY && E.hint == PROPERTY_HINT_TYPE_STRING) { - int hint_subtype_separator = E.hint_string.find(":"); + int hint_subtype_separator = E.hint_string.find_char(':'); if (hint_subtype_separator >= 0) { String subtype_string = E.hint_string.substr(0, hint_subtype_separator); - int slash_pos = subtype_string.find("/"); + int slash_pos = subtype_string.find_char('/'); PropertyHint subtype_hint = PropertyHint::PROPERTY_HINT_NONE; if (slash_pos >= 0) { subtype_hint = PropertyHint(subtype_string.get_slice("/", 1).to_int()); @@ -851,11 +851,11 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has } } } else if (E.type == Variant::DICTIONARY && E.hint == PROPERTY_HINT_TYPE_STRING) { - int key_value_separator = E.hint_string.find(";"); + int key_value_separator = E.hint_string.find_char(';'); if (key_value_separator >= 0) { - int key_subtype_separator = E.hint_string.find(":"); + int key_subtype_separator = E.hint_string.find_char(':'); String key_subtype_string = E.hint_string.substr(0, key_subtype_separator); - int key_slash_pos = key_subtype_string.find("/"); + int key_slash_pos = key_subtype_string.find_char('/'); PropertyHint key_subtype_hint = PropertyHint::PROPERTY_HINT_NONE; if (key_slash_pos >= 0) { key_subtype_hint = PropertyHint(key_subtype_string.get_slice("/", 1).to_int()); @@ -864,9 +864,9 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has Variant::Type key_subtype = Variant::Type(key_subtype_string.to_int()); bool convert_key = key_subtype == Variant::OBJECT && key_subtype_hint == PROPERTY_HINT_NODE_TYPE; - int value_subtype_separator = E.hint_string.find(":", key_value_separator) - (key_value_separator + 1); + int value_subtype_separator = E.hint_string.find_char(':', key_value_separator) - (key_value_separator + 1); String value_subtype_string = E.hint_string.substr(key_value_separator + 1, value_subtype_separator); - int value_slash_pos = value_subtype_string.find("/"); + int value_slash_pos = value_subtype_string.find_char('/'); PropertyHint value_subtype_hint = PropertyHint::PROPERTY_HINT_NONE; if (value_slash_pos >= 0) { value_subtype_hint = PropertyHint(value_subtype_string.get_slice("/", 1).to_int()); diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 6e03fe25c9..03f0e107e4 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1782,7 +1782,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const Ref<Reso for (KeyValue<Ref<Resource>, String> &E : external_resources) { String cached_id = E.key->get_id_for_path(local_path); if (cached_id.is_empty() || cached_ids_found.has(cached_id)) { - int sep_pos = E.value.find("_"); + int sep_pos = E.value.find_char('_'); if (sep_pos != -1) { E.value = E.value.substr(0, sep_pos + 1); // Keep the order found, for improved thread loading performance. } else { diff --git a/scene/resources/syntax_highlighter.cpp b/scene/resources/syntax_highlighter.cpp index da90ba1ef2..4bc03a049a 100644 --- a/scene/resources/syntax_highlighter.cpp +++ b/scene/resources/syntax_highlighter.cpp @@ -205,7 +205,7 @@ Dictionary CodeHighlighter::_get_line_syntax_highlighting_impl(int p_line) { if (end_key_length == 0 || color_regions[c].line_only || from + end_key_length > line_length) { if (from + end_key_length > line_length && (color_regions[in_region].start_key == "\"" || color_regions[in_region].start_key == "\'")) { // If it's key length and there is a '\', dont skip to highlight esc chars. - if (str.find("\\", from) >= 0) { + if (str.find_char('\\', from) >= 0) { break; } } @@ -242,7 +242,7 @@ Dictionary CodeHighlighter::_get_line_syntax_highlighting_impl(int p_line) { for (; from < line_length; from++) { if (line_length - from < end_key_length) { // Don't break if '\' to highlight esc chars. - if (!is_string || str.find("\\", from) < 0) { + if (!is_string || str.find_char('\\', from) < 0) { break; } } diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp index 5ad92bd211..c9d5e51753 100644 --- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp @@ -2064,6 +2064,10 @@ void RenderForwardMobile::_fill_render_list(RenderListType p_render_list, const surf = surf->next; } } + + if (p_render_list == RENDER_LIST_OPAQUE && lightmap_captures_used) { + RD::get_singleton()->buffer_update(scene_state.lightmap_capture_buffer, 0, sizeof(LightmapCaptureData) * lightmap_captures_used, scene_state.lightmap_captures); + } } void RenderForwardMobile::_setup_environment(const RenderDataRD *p_render_data, bool p_no_fog, const Size2i &p_screen_size, const Color &p_default_bg_color, bool p_opaque_render_buffers, bool p_pancake_shadows, int p_index) { diff --git a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl index 404f658fa6..da8ad3db15 100644 --- a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl +++ b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl @@ -434,12 +434,12 @@ void main() { vertex_interp = vertex; #ifdef NORMAL_USED - normal_interp = normal; + normal_interp = normalize(normal); #endif #if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED) - tangent_interp = tangent; - binormal_interp = binormal; + tangent_interp = normalize(tangent); + binormal_interp = normalize(binormal); #endif // VERTEX LIGHTING @@ -456,13 +456,13 @@ void main() { uvec2 omni_light_indices = instances.data[draw_call.instance_index].omni_lights; for (uint i = 0; i < sc_omni_lights(); i++) { uint light_index = (i > 3) ? ((omni_light_indices.y >> ((i - 4) * 8)) & 0xFF) : ((omni_light_indices.x >> (i * 8)) & 0xFF); - light_process_omni_vertex(light_index, vertex, view, normal, roughness, diffuse_light_interp.rgb, specular_light_interp.rgb); + light_process_omni_vertex(light_index, vertex, view, normal_interp, roughness, diffuse_light_interp.rgb, specular_light_interp.rgb); } uvec2 spot_light_indices = instances.data[draw_call.instance_index].spot_lights; for (uint i = 0; i < sc_spot_lights(); i++) { uint light_index = (i > 3) ? ((spot_light_indices.y >> ((i - 4) * 8)) & 0xFF) : ((spot_light_indices.x >> (i * 8)) & 0xFF); - light_process_spot_vertex(light_index, vertex, view, normal, roughness, diffuse_light_interp.rgb, specular_light_interp.rgb); + light_process_spot_vertex(light_index, vertex, view, normal_interp, roughness, diffuse_light_interp.rgb, specular_light_interp.rgb); } if (sc_directional_lights() > 0) { @@ -479,13 +479,13 @@ void main() { continue; // Statically baked light and object uses lightmap, skip. } if (i == 0) { - light_compute_vertex(normal, directional_lights.data[0].direction, view, + light_compute_vertex(normal_interp, directional_lights.data[0].direction, view, directional_lights.data[0].color * directional_lights.data[0].energy, true, roughness, directional_diffuse, directional_specular); } else { - light_compute_vertex(normal, directional_lights.data[i].direction, view, + light_compute_vertex(normal_interp, directional_lights.data[i].direction, view, directional_lights.data[i].color * directional_lights.data[i].energy, true, roughness, diffuse_light_interp.rgb, diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index cc67873b24..ab5de3cb7f 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -5272,14 +5272,13 @@ void RenderingDevice::_wait_for_transfer_worker(TransferWorker *p_transfer_worke p_transfer_worker->operations_processed = p_transfer_worker->operations_submitted; } - if (!p_transfer_worker->texture_barriers.is_empty()) { - MutexLock transfer_worker_lock(transfer_worker_pool_mutex); - _flush_barriers_for_transfer_worker(p_transfer_worker); - } + _flush_barriers_for_transfer_worker(p_transfer_worker); } void RenderingDevice::_flush_barriers_for_transfer_worker(TransferWorker *p_transfer_worker) { + // Caller must have already acquired the mutex for the worker. if (!p_transfer_worker->texture_barriers.is_empty()) { + MutexLock transfer_worker_lock(transfer_worker_pool_texture_barriers_mutex); for (uint32_t i = 0; i < p_transfer_worker->texture_barriers.size(); i++) { transfer_worker_pool_texture_barriers.push_back(p_transfer_worker->texture_barriers[i]); } @@ -5352,8 +5351,11 @@ void RenderingDevice::_submit_transfer_workers(RDD::CommandBufferID p_draw_comma } } } +} - if (p_draw_command_buffer && !transfer_worker_pool_texture_barriers.is_empty()) { +void RenderingDevice::_submit_transfer_barriers(RDD::CommandBufferID p_draw_command_buffer) { + MutexLock transfer_worker_lock(transfer_worker_pool_texture_barriers_mutex); + if (!transfer_worker_pool_texture_barriers.is_empty()) { driver->command_pipeline_barrier(p_draw_command_buffer, RDD::PIPELINE_STAGE_COPY_BIT, RDD::PIPELINE_STAGE_ALL_COMMANDS_BIT, {}, {}, transfer_worker_pool_texture_barriers); transfer_worker_pool_texture_barriers.clear(); } @@ -5953,6 +5955,7 @@ void RenderingDevice::_end_frame() { // The command buffer must be copied into a stack variable as the driver workarounds can change the command buffer in use. RDD::CommandBufferID command_buffer = frames[frame].command_buffer; _submit_transfer_workers(command_buffer); + _submit_transfer_barriers(command_buffer); draw_graph.end(RENDER_GRAPH_REORDER, RENDER_GRAPH_FULL_BARRIERS, command_buffer, frames[frame].command_buffer_pool); driver->command_buffer_end(command_buffer); diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index 9939df976f..ccfe51043b 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -1285,6 +1285,7 @@ private: LocalVector<uint32_t> transfer_worker_pool_available_list; LocalVector<RDD::TextureBarrier> transfer_worker_pool_texture_barriers; BinaryMutex transfer_worker_pool_mutex; + BinaryMutex transfer_worker_pool_texture_barriers_mutex; ConditionVariable transfer_worker_pool_condition; TransferWorker *_acquire_transfer_worker(uint32_t p_transfer_size, uint32_t p_required_align, uint32_t &r_staging_offset); @@ -1299,6 +1300,7 @@ private: void _check_transfer_worker_vertex_array(VertexArray *p_vertex_array); void _check_transfer_worker_index_array(IndexArray *p_index_array); void _submit_transfer_workers(RDD::CommandBufferID p_draw_command_buffer = RDD::CommandBufferID()); + void _submit_transfer_barriers(RDD::CommandBufferID p_draw_command_buffer); void _wait_for_transfer_workers(); void _free_transfer_workers(); diff --git a/servers/rendering/rendering_device_graph.cpp b/servers/rendering/rendering_device_graph.cpp index ec2f336f3c..86b5f80e56 100644 --- a/servers/rendering/rendering_device_graph.cpp +++ b/servers/rendering/rendering_device_graph.cpp @@ -140,7 +140,7 @@ RDD::BarrierAccessBits RenderingDeviceGraph::_usage_to_access_bits(ResourceUsage #endif } -bool RenderingDeviceGraph::_check_command_intersection(ResourceTracker *p_resource_tracker, int32_t p_previous_command_index, int32_t p_command_index) const { +bool RenderingDeviceGraph::_check_command_intersection(ResourceTracker *p_resource_tracker, int32_t p_previous_command_index, int32_t p_command_index, bool &r_intersection_partial_coverage) const { if (p_resource_tracker->usage != RESOURCE_USAGE_ATTACHMENT_COLOR_READ_WRITE && p_resource_tracker->usage != RESOURCE_USAGE_ATTACHMENT_DEPTH_STENCIL_READ_WRITE) { // We don't check possible intersections for usages that aren't consecutive color or depth writes. return true; @@ -155,6 +155,11 @@ bool RenderingDeviceGraph::_check_command_intersection(ResourceTracker *p_resour return true; } + if (!r_intersection_partial_coverage) { + // Indicate if this draw list only partially covers the region of the previous draw list. + r_intersection_partial_coverage = !current_draw_list_command.region.encloses(previous_draw_list_command.region); + } + // We check if the region used by both draw lists have an intersection. return previous_draw_list_command.region.intersects(current_draw_list_command.region); } @@ -471,7 +476,7 @@ void RenderingDeviceGraph::_add_command_to_graph(ResourceTracker **p_resource_tr resource_tracker->usage = new_resource_usage; } - bool command_intersection_failed = false; + bool intersection_partial_coverage = false; if (search_tracker->write_command_or_list_index >= 0) { if (search_tracker->write_command_list_enabled) { // Make this command adjacent to any commands that wrote to this resource and intersect with the slice if it applies. @@ -483,7 +488,7 @@ void RenderingDeviceGraph::_add_command_to_graph(ResourceTracker **p_resource_tr if (!resource_has_parent || search_tracker_rect.intersects(write_list_node.subresources)) { if (write_list_node.command_index == p_command_index) { ERR_FAIL_COND_MSG(!resource_has_parent, "Command can't have itself as a dependency."); - } else if (_check_command_intersection(resource_tracker, write_list_node.command_index, p_command_index)) { + } else if (_check_command_intersection(resource_tracker, write_list_node.command_index, p_command_index, intersection_partial_coverage)) { // Command is dependent on this command. Add this command to the adjacency list of the write command. _add_adjacent_command(write_list_node.command_index, p_command_index, r_command); @@ -499,8 +504,6 @@ void RenderingDeviceGraph::_add_command_to_graph(ResourceTracker **p_resource_tr write_list_index = write_list_node.next_list_index; continue; } - } else { - command_intersection_failed = true; } } @@ -511,16 +514,14 @@ void RenderingDeviceGraph::_add_command_to_graph(ResourceTracker **p_resource_tr // The index is just the latest command index that wrote to the resource. if (search_tracker->write_command_or_list_index == p_command_index) { ERR_FAIL_MSG("Command can't have itself as a dependency."); - } else if (_check_command_intersection(resource_tracker, search_tracker->write_command_or_list_index, p_command_index)) { + } else if (_check_command_intersection(resource_tracker, search_tracker->write_command_or_list_index, p_command_index, intersection_partial_coverage)) { _add_adjacent_command(search_tracker->write_command_or_list_index, p_command_index, r_command); - } else { - command_intersection_failed = true; } } } if (write_usage) { - if (resource_has_parent || command_intersection_failed) { + if (resource_has_parent || intersection_partial_coverage) { if (!search_tracker->write_command_list_enabled && search_tracker->write_command_or_list_index >= 0) { // Write command list was not being used but there was a write command recorded. Add a new node with the entire parent resource's subresources and the recorded command index to the list. const RDD::TextureSubresourceRange &tracker_subresources = search_tracker->texture_subresources; diff --git a/servers/rendering/rendering_device_graph.h b/servers/rendering/rendering_device_graph.h index 9ddd70bc80..452e1700b6 100644 --- a/servers/rendering/rendering_device_graph.h +++ b/servers/rendering/rendering_device_graph.h @@ -649,7 +649,7 @@ private: static bool _is_write_usage(ResourceUsage p_usage); static RDD::TextureLayout _usage_to_image_layout(ResourceUsage p_usage); static RDD::BarrierAccessBits _usage_to_access_bits(ResourceUsage p_usage); - bool _check_command_intersection(ResourceTracker *p_resource_tracker, int32_t p_previous_command_index, int32_t p_command_index) const; + bool _check_command_intersection(ResourceTracker *p_resource_tracker, int32_t p_previous_command_index, int32_t p_command_index, bool &r_intersection_partial_coverage) const; int32_t _add_to_command_list(int32_t p_command_index, int32_t p_list_index); void _add_adjacent_command(int32_t p_previous_command_index, int32_t p_command_index, RecordedCommand *r_command); int32_t _add_to_slice_read_list(int32_t p_command_index, Rect2i p_subresources, int32_t p_list_index); diff --git a/tests/core/variant/test_callable.h b/tests/core/variant/test_callable.h index 3228e0a583..34ea8fad5c 100644 --- a/tests/core/variant/test_callable.h +++ b/tests/core/variant/test_callable.h @@ -135,6 +135,70 @@ TEST_CASE("[Callable] Argument count") { memdelete(my_test); } + +class TestBoundUnboundArgumentCount : public Object { + GDCLASS(TestBoundUnboundArgumentCount, Object); + +protected: + static void _bind_methods() { + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "test_func", &TestBoundUnboundArgumentCount::test_func, MethodInfo("test_func")); + } + +public: + Variant test_func(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { + Array result; + result.resize(p_argcount); + for (int i = 0; i < p_argcount; i++) { + result[i] = *p_args[i]; + } + return result; + } + + static String get_output(const Callable &p_callable) { + Array effective_args; + effective_args.push_back(7); + effective_args.push_back(8); + effective_args.push_back(9); + + effective_args.resize(3 - p_callable.get_unbound_arguments_count()); + effective_args.append_array(p_callable.get_bound_arguments()); + + return vformat( + "%d %d %s %s %s", + p_callable.get_unbound_arguments_count(), + p_callable.get_bound_arguments_count(), + p_callable.get_bound_arguments(), + p_callable.call(7, 8, 9), + effective_args); + } +}; + +TEST_CASE("[Callable] Bound and unbound argument count") { + String (*get_output)(const Callable &) = TestBoundUnboundArgumentCount::get_output; + + TestBoundUnboundArgumentCount *test_instance = memnew(TestBoundUnboundArgumentCount); + + Callable test_func = Callable(test_instance, "test_func"); + + CHECK(get_output(test_func) == "0 0 [] [7, 8, 9] [7, 8, 9]"); + CHECK(get_output(test_func.bind(1, 2)) == "0 2 [1, 2] [7, 8, 9, 1, 2] [7, 8, 9, 1, 2]"); + CHECK(get_output(test_func.bind(1, 2).unbind(1)) == "1 2 [1, 2] [7, 8, 1, 2] [7, 8, 1, 2]"); + CHECK(get_output(test_func.bind(1, 2).unbind(1).bind(3, 4)) == "0 3 [3, 1, 2] [7, 8, 9, 3, 1, 2] [7, 8, 9, 3, 1, 2]"); + CHECK(get_output(test_func.bind(1, 2).unbind(1).bind(3, 4).unbind(1)) == "1 3 [3, 1, 2] [7, 8, 3, 1, 2] [7, 8, 3, 1, 2]"); + + CHECK(get_output(test_func.bind(1).bind(2).bind(3).unbind(1)) == "1 3 [3, 2, 1] [7, 8, 3, 2, 1] [7, 8, 3, 2, 1]"); + CHECK(get_output(test_func.bind(1).bind(2).unbind(1).bind(3)) == "0 2 [2, 1] [7, 8, 9, 2, 1] [7, 8, 9, 2, 1]"); + CHECK(get_output(test_func.bind(1).unbind(1).bind(2).bind(3)) == "0 2 [3, 1] [7, 8, 9, 3, 1] [7, 8, 9, 3, 1]"); + CHECK(get_output(test_func.unbind(1).bind(1).bind(2).bind(3)) == "0 2 [3, 2] [7, 8, 9, 3, 2] [7, 8, 9, 3, 2]"); + + CHECK(get_output(test_func.unbind(1).unbind(1).unbind(1).bind(1, 2, 3)) == "0 0 [] [7, 8, 9] [7, 8, 9]"); + CHECK(get_output(test_func.unbind(1).unbind(1).bind(1, 2, 3).unbind(1)) == "1 1 [1] [7, 8, 1] [7, 8, 1]"); + CHECK(get_output(test_func.unbind(1).bind(1, 2, 3).unbind(1).unbind(1)) == "2 2 [1, 2] [7, 1, 2] [7, 1, 2]"); + CHECK(get_output(test_func.bind(1, 2, 3).unbind(1).unbind(1).unbind(1)) == "3 3 [1, 2, 3] [1, 2, 3] [1, 2, 3]"); + + memdelete(test_instance); +} + } // namespace TestCallable #endif // TEST_CALLABLE_H diff --git a/tests/scene/test_texture_progress_bar.h b/tests/scene/test_texture_progress_bar.h new file mode 100644 index 0000000000..5eb7495a29 --- /dev/null +++ b/tests/scene/test_texture_progress_bar.h @@ -0,0 +1,92 @@ +/**************************************************************************/ +/* test_texture_progress_bar.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef TEST_TEXTURE_PROGRESS_BAR_H +#define TEST_TEXTURE_PROGRESS_BAR_H + +#include "scene/gui/texture_progress_bar.h" + +#include "tests/test_macros.h" + +namespace TestTextureProgressBar { + +TEST_CASE("[SceneTree][TextureProgressBar]") { + TextureProgressBar *texture_progress_bar = memnew(TextureProgressBar); + + SUBCASE("[TextureProgressBar] set_radial_initial_angle() should wrap angle between 0 and 360 degrees (inclusive).") { + texture_progress_bar->set_radial_initial_angle(0.0); + CHECK(Math::is_equal_approx(texture_progress_bar->get_radial_initial_angle(), (float)0.0)); + + texture_progress_bar->set_radial_initial_angle(360.0); + CHECK(Math::is_equal_approx(texture_progress_bar->get_radial_initial_angle(), (float)360.0)); + + texture_progress_bar->set_radial_initial_angle(30.5); + CHECK(Math::is_equal_approx(texture_progress_bar->get_radial_initial_angle(), (float)30.5)); + + texture_progress_bar->set_radial_initial_angle(-30.5); + CHECK(Math::is_equal_approx(texture_progress_bar->get_radial_initial_angle(), (float)(360 - 30.5))); + + texture_progress_bar->set_radial_initial_angle(36000 + 30.5); + CHECK(Math::is_equal_approx(texture_progress_bar->get_radial_initial_angle(), (float)30.5)); + + texture_progress_bar->set_radial_initial_angle(-(36000 + 30.5)); + CHECK(Math::is_equal_approx(texture_progress_bar->get_radial_initial_angle(), (float)(360 - 30.5))); + } + + SUBCASE("[TextureProgressBar] set_radial_initial_angle() should not set non-finite values.") { + texture_progress_bar->set_radial_initial_angle(30.5); + + ERR_PRINT_OFF; + texture_progress_bar->set_radial_initial_angle(INFINITY); + ERR_PRINT_ON; + CHECK(Math::is_equal_approx(texture_progress_bar->get_radial_initial_angle(), (float)30.5)); + + ERR_PRINT_OFF; + texture_progress_bar->set_radial_initial_angle(-INFINITY); + ERR_PRINT_ON; + CHECK(Math::is_equal_approx(texture_progress_bar->get_radial_initial_angle(), (float)30.5)); + + ERR_PRINT_OFF; + texture_progress_bar->set_radial_initial_angle(NAN); + ERR_PRINT_ON; + CHECK(Math::is_equal_approx(texture_progress_bar->get_radial_initial_angle(), (float)30.5)); + + ERR_PRINT_OFF; + texture_progress_bar->set_radial_initial_angle(-NAN); + ERR_PRINT_ON; + CHECK(Math::is_equal_approx(texture_progress_bar->get_radial_initial_angle(), (float)30.5)); + } + + memdelete(texture_progress_bar); +} + +} // namespace TestTextureProgressBar + +#endif // TEST_TEXTURE_PROGRESS_BAR_H diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 65d45ae92f..d860f7b843 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -130,6 +130,7 @@ #include "tests/scene/test_physics_material.h" #include "tests/scene/test_sprite_frames.h" #include "tests/scene/test_style_box_texture.h" +#include "tests/scene/test_texture_progress_bar.h" #include "tests/scene/test_theme.h" #include "tests/scene/test_timer.h" #include "tests/scene/test_viewport.h" |